Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/ipp/ippconf.c
          +++ new/usr/src/uts/common/ipp/ippconf.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   26  #include <sys/types.h>
  29   27  #include <sys/param.h>
  30   28  #include <sys/modctl.h>
  31   29  #include <sys/sysmacros.h>
  32   30  #include <sys/kmem.h>
  33   31  #include <sys/cmn_err.h>
  34   32  #include <sys/ddi.h>
  35   33  #include <sys/sunddi.h>
  36   34  #include <sys/spl.h>
  37   35  #include <sys/time.h>
↓ open down ↓ 1333 lines elided ↑ open up ↑
1371 1369                           * it's being used.
1372 1370                           *
1373 1371                           * NOTE: We only have a read lock, so we need to use
1374 1372                           *       atomic_add_32(). The read lock is still
1375 1373                           *       important though as it is crucial to block
1376 1374                           *       out a destroy operation between the action
1377 1375                           *       state being checked and the packet count
1378 1376                           *       being incremented.
1379 1377                           */
1380 1378  
1381      -                        atomic_add_32(&(ap->ippa_packets), 1);
     1379 +                        atomic_inc_32(&(ap->ippa_packets));
1382 1380  
1383 1381                          imp = ap->ippa_mod;
1384 1382                          ASSERT(imp != NULL);
1385 1383                          UNLOCK_ACTION(ap);
1386 1384  
1387 1385                          ippo = imp->ippm_ops;
1388 1386                          ASSERT(ippo != NULL);
1389 1387  
1390 1388                          /*
1391 1389                           * If there's a log, grab the next entry and fill it
↓ open down ↓ 21 lines elided ↑ open up ↑
1413 1411                           * processing.
1414 1412                           */
1415 1413  
1416 1414                          if (lp != NULL)
1417 1415                                  gethrestime(&lp->ippl_end);
1418 1416  
1419 1417                          /*
1420 1418                           * Decrement the packet count.
1421 1419                           */
1422 1420  
1423      -                        atomic_add_32(&(ap->ippa_packets), -1);
     1421 +                        atomic_dec_32(&(ap->ippa_packets));
1424 1422  
1425 1423                          /*
1426 1424                           * If the class' action id is the same now as it was
1427 1425                           * before then clearly no 'next action' has been set.
1428 1426                           * This is a protocol error.
1429 1427                           */
1430 1428  
1431 1429                          if (cp->ippc_aid == aid) {
1432 1430                                  DBG1(DBG_PACKET,
1433 1431                                      "action '%s' did not set next action\n",
↓ open down ↓ 938 lines elided ↑ open up ↑
2372 2370                  rw_exit(ipp_mod_byid_lock);
2373 2371                  return (NULL);
2374 2372          }
2375 2373          UNLOCK_MOD(imp);
2376 2374  
2377 2375          /*
2378 2376           * Increment the hold count to prevent the structure from being
2379 2377           * freed.
2380 2378           */
2381 2379  
2382      -        atomic_add_32(&(imp->ippm_hold_count), 1);
     2380 +        atomic_inc_32(&(imp->ippm_hold_count));
2383 2381          rw_exit(ipp_mod_byid_lock);
2384 2382  
2385 2383          return (imp);
2386 2384  }
2387 2385  #undef  __FN__
2388 2386  
2389 2387  #define __FN__  "rele_mod"
2390 2388  static void
2391 2389  rele_mod(
2392 2390          ipp_mod_t       *imp)
2393 2391  {
2394 2392          /*
2395 2393           * This call means we're done with the pointer so we can drop the
2396 2394           * hold count.
2397 2395           */
2398 2396  
2399 2397          ASSERT(imp->ippm_hold_count != 0);
2400      -        atomic_add_32(&(imp->ippm_hold_count), -1);
     2398 +        atomic_dec_32(&(imp->ippm_hold_count));
2401 2399  
2402 2400          /*
2403 2401           * If the structure has 'destruct pending' set then we tried to free
2404 2402           * it but couldn't, so do it now.
2405 2403           */
2406 2404  
2407 2405          LOCK_MOD(imp, RW_READER);
2408 2406          if (imp->ippm_destruct_pending && imp->ippm_hold_count == 0) {
2409 2407                  UNLOCK_MOD(imp);
2410 2408                  kmem_cache_free(ipp_mod_cache, imp);
↓ open down ↓ 653 lines elided ↑ open up ↑
3064 3062                  rw_exit(ipp_action_byid_lock);
3065 3063                  return (NULL);
3066 3064          }
3067 3065          UNLOCK_ACTION(ap);
3068 3066  
3069 3067          /*
3070 3068           * Increment the hold count to prevent the structure from being
3071 3069           * freed.
3072 3070           */
3073 3071  
3074      -        atomic_add_32(&(ap->ippa_hold_count), 1);
     3072 +        atomic_inc_32(&(ap->ippa_hold_count));
3075 3073          rw_exit(ipp_action_byid_lock);
3076 3074  
3077 3075          return (ap);
3078 3076  }
3079 3077  #undef  __FN__
3080 3078  
3081 3079  #define __FN__  "rele_action"
3082 3080  static void
3083 3081  rele_action(
3084 3082          ipp_action_t    *ap)
3085 3083  {
3086 3084          /*
3087 3085           * This call means we're done with the pointer so we can drop the
3088 3086           * hold count.
3089 3087           */
3090 3088  
3091 3089          ASSERT(ap->ippa_hold_count != 0);
3092      -        atomic_add_32(&(ap->ippa_hold_count), -1);
     3090 +        atomic_dec_32(&(ap->ippa_hold_count));
3093 3091  
3094 3092          /*
3095 3093           * If the structure has 'destruct pending' set then we tried to free
3096 3094           * it but couldn't, so do it now.
3097 3095           */
3098 3096  
3099 3097          LOCK_ACTION(ap, RW_READER);
3100 3098          if (ap->ippa_destruct_pending && ap->ippa_hold_count == 0) {
3101 3099                  UNLOCK_ACTION(ap);
3102 3100                  kmem_cache_free(ipp_action_cache, ap);
↓ open down ↓ 506 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX