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_attr.c
          +++ new/usr/src/uts/common/inet/ip/ip_attr.c
↓ open down ↓ 92 lines elided ↑ open up ↑
  93   93  
  94   94  #include <sys/tsol/label.h>
  95   95  #include <sys/tsol/tnet.h>
  96   96  
  97   97  /*
  98   98   * Release a reference on ip_xmit_attr.
  99   99   * The reference is acquired by conn_get_ixa()
 100  100   */
 101  101  #define IXA_REFRELE(ixa)                                        \
 102  102  {                                                               \
 103      -        if (atomic_add_32_nv(&(ixa)->ixa_refcnt, -1) == 0)      \
      103 +        if (atomic_dec_32_nv(&(ixa)->ixa_refcnt) == 0)  \
 104  104                  ixa_inactive(ixa);                              \
 105  105  }
 106  106  
 107  107  #define IXA_REFHOLD(ixa)                                        \
 108  108  {                                                               \
 109  109          ASSERT((ixa)->ixa_refcnt != 0);                         \
 110      -        atomic_add_32(&(ixa)->ixa_refcnt, 1);                   \
      110 +        atomic_inc_32(&(ixa)->ixa_refcnt);                      \
 111  111  }
 112  112  
 113  113  /*
 114  114   * When we need to handle a transmit side asynchronous operation, then we need
 115  115   * to save sufficient information so that we can call the fragment and postfrag
 116  116   * functions. That information is captured in an mblk containing this structure.
 117  117   *
 118  118   * Since this is currently only used for IPsec, we include information for
 119  119   * the kernel crypto framework.
 120  120   */
↓ open down ↓ 626 lines elided ↑ open up ↑
 747  747  conn_get_ixa_impl(conn_t *connp, boolean_t replace, int kmflag)
 748  748  {
 749  749          ip_xmit_attr_t  *ixa;
 750  750          ip_xmit_attr_t  *oldixa;
 751  751  
 752  752          mutex_enter(&connp->conn_lock);
 753  753          ixa = connp->conn_ixa;
 754  754  
 755  755          /* At least one references for the conn_t */
 756  756          ASSERT(ixa->ixa_refcnt >= 1);
 757      -        if (atomic_add_32_nv(&ixa->ixa_refcnt, 1) == 2) {
      757 +        if (atomic_inc_32_nv(&ixa->ixa_refcnt) == 2) {
 758  758                  /* No other thread using conn_ixa */
 759  759                  mutex_exit(&connp->conn_lock);
 760  760                  return (ixa);
 761  761          }
 762  762          ixa = kmem_alloc(sizeof (*ixa), kmflag);
 763  763          if (ixa == NULL) {
 764  764                  mutex_exit(&connp->conn_lock);
 765  765                  ixa_refrele(connp->conn_ixa);
 766  766                  return (NULL);
 767  767          }
↓ open down ↓ 81 lines elided ↑ open up ↑
 849  849  {
 850  850          ip_xmit_attr_t *ixa;
 851  851  
 852  852          mutex_enter(&connp->conn_lock);
 853  853          ixa = connp->conn_ixa;
 854  854  
 855  855          /* At least one references for the conn_t */
 856  856          ASSERT(ixa->ixa_refcnt >= 1);
 857  857  
 858  858          /* Make sure conn_ixa doesn't disappear while we copy it */
 859      -        atomic_add_32(&ixa->ixa_refcnt, 1);
      859 +        atomic_inc_32(&ixa->ixa_refcnt);
 860  860  
 861  861          ixa = kmem_alloc(sizeof (*ixa), KM_NOSLEEP);
 862  862          if (ixa == NULL) {
 863  863                  mutex_exit(&connp->conn_lock);
 864  864                  ixa_refrele(connp->conn_ixa);
 865  865                  return (NULL);
 866  866          }
 867  867          ixa_safe_copy(connp->conn_ixa, ixa);
 868  868          mutex_exit(&connp->conn_lock);
 869  869          IXA_REFRELE(connp->conn_ixa);
↓ open down ↓ 551 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX