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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/ip/ip_ire.c
          +++ new/usr/src/uts/common/inet/ip/ip_ire.c
↓ open down ↓ 325 lines elided ↑ open up ↑
 326  326  
 327  327  /*
 328  328   * Bump up the reference count on the IRE. We cannot assert that the
 329  329   * bucket lock is being held as it is legal to bump up the reference
 330  330   * count after the first lookup has returned the IRE without
 331  331   * holding the lock.
 332  332   */
 333  333  void
 334  334  ire_refhold(ire_t *ire)
 335  335  {
 336      -        atomic_add_32(&(ire)->ire_refcnt, 1);
      336 +        atomic_inc_32(&(ire)->ire_refcnt);
 337  337          ASSERT((ire)->ire_refcnt != 0);
 338  338  #ifdef DEBUG
 339  339          ire_trace_ref(ire);
 340  340  #endif
 341  341  }
 342  342  
 343  343  void
 344  344  ire_refhold_notr(ire_t *ire)
 345  345  {
 346      -        atomic_add_32(&(ire)->ire_refcnt, 1);
      346 +        atomic_inc_32(&(ire)->ire_refcnt);
 347  347          ASSERT((ire)->ire_refcnt != 0);
 348  348  }
 349  349  
 350  350  void
 351  351  ire_refhold_locked(ire_t *ire)
 352  352  {
 353  353  #ifdef DEBUG
 354  354          ire_trace_ref(ire);
 355  355  #endif
 356  356          ire->ire_refcnt++;
↓ open down ↓ 15 lines elided ↑ open up ↑
 372  372   * before the cas is executed. membar_exit() does that here.
 373  373   */
 374  374  void
 375  375  ire_refrele(ire_t *ire)
 376  376  {
 377  377  #ifdef DEBUG
 378  378          ire_untrace_ref(ire);
 379  379  #endif
 380  380          ASSERT((ire)->ire_refcnt != 0);
 381  381          membar_exit();
 382      -        if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0)
      382 +        if (atomic_dec_32_nv(&(ire)->ire_refcnt) == 0)
 383  383                  ire_inactive(ire);
 384  384  }
 385  385  
 386  386  void
 387  387  ire_refrele_notr(ire_t *ire)
 388  388  {
 389  389          ASSERT((ire)->ire_refcnt != 0);
 390  390          membar_exit();
 391      -        if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0)
      391 +        if (atomic_dec_32_nv(&(ire)->ire_refcnt) == 0)
 392  392                  ire_inactive(ire);
 393  393  }
 394  394  
 395  395  /*
 396  396   * This function is associated with the IP_IOC_IRE_DELETE[_NO_REPLY]
 397  397   * IOCTL[s].  The NO_REPLY form is used by TCP to tell IP that it is
 398  398   * having problems reaching a particular destination.
 399  399   * This will make IP consider alternate routes (e.g., when there are
 400  400   * muliple default routes), and it will also make IP discard any (potentially)
 401  401   * stale redirect.
↓ open down ↓ 863 lines elided ↑ open up ↑
1265 1265                           * As most of the callers continue to use the IRE
1266 1266                           * after adding, we return a held ire. This will
1267 1267                           * avoid a lookup in the caller again. If the callers
1268 1268                           * don't want to use it, they need to do a REFRELE.
1269 1269                           *
1270 1270                           * We only allow exactly one IRE_IF_CLONE for any dst,
1271 1271                           * so, if the is an IF_CLONE, return the ire without
1272 1272                           * an identical_ref, but with an ire_ref held.
1273 1273                           */
1274 1274                          if (ire->ire_type != IRE_IF_CLONE) {
1275      -                                atomic_add_32(&ire1->ire_identical_ref, 1);
     1275 +                                atomic_inc_32(&ire1->ire_identical_ref);
1276 1276                                  DTRACE_PROBE2(ire__add__exist, ire_t *, ire1,
1277 1277                                      ire_t *, ire);
1278 1278                          }
1279 1279                          ire_refhold(ire1);
1280 1280                          ire_atomic_end(irb_ptr, ire);
1281 1281                          ire_delete(ire);
1282 1282                          irb_refrele(irb_ptr);
1283 1283                          return (ire1);
1284 1284                  }
1285 1285          }
↓ open down ↓ 240 lines elided ↑ open up ↑
1526 1526                   * Some other thread has removed us from the list.
1527 1527                   * It should have done the REFRELE for us.
1528 1528                   */
1529 1529                  rw_exit(&irb->irb_lock);
1530 1530                  return;
1531 1531          }
1532 1532  
1533 1533          if (!IRE_IS_CONDEMNED(ire)) {
1534 1534                  /* Is this an IRE representing multiple duplicate entries? */
1535 1535                  ASSERT(ire->ire_identical_ref >= 1);
1536      -                if (atomic_add_32_nv(&ire->ire_identical_ref, -1) != 0) {
     1536 +                if (atomic_dec_32_nv(&ire->ire_identical_ref) != 0) {
1537 1537                          /* Removed one of the identical parties */
1538 1538                          rw_exit(&irb->irb_lock);
1539 1539                          return;
1540 1540                  }
1541 1541  
1542 1542                  irb->irb_ire_cnt--;
1543 1543                  ire_make_condemned(ire);
1544 1544          }
1545 1545  
1546 1546          if (irb->irb_refcnt != 0) {
↓ open down ↓ 1064 lines elided ↑ open up ↑
2611 2611  {
2612 2612          ip_stack_t      *ipst = ire->ire_ipst;
2613 2613          nce_t           *nce;
2614 2614  
2615 2615          mutex_enter(&ire->ire_lock);
2616 2616          ASSERT(ire->ire_bucket == NULL ||
2617 2617              RW_WRITE_HELD(&ire->ire_bucket->irb_lock));
2618 2618          ASSERT(!IRE_IS_CONDEMNED(ire));
2619 2619          ire->ire_generation = IRE_GENERATION_CONDEMNED;
2620 2620          /* Count how many condemned ires for kmem_cache callback */
2621      -        atomic_add_32(&ipst->ips_num_ire_condemned, 1);
     2621 +        atomic_inc_32(&ipst->ips_num_ire_condemned);
2622 2622          nce = ire->ire_nce_cache;
2623 2623          ire->ire_nce_cache = NULL;
2624 2624          mutex_exit(&ire->ire_lock);
2625 2625          if (nce != NULL)
2626 2626                  nce_refrele(nce);
2627 2627  }
2628 2628  
2629 2629  /*
2630 2630   * Increment the generation avoiding the special condemned value
2631 2631   */
↓ open down ↓ 996 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX