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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/sctp/sctp_addr.c
          +++ new/usr/src/uts/common/inet/sctp/sctp_addr.c
↓ open down ↓ 129 lines elided ↑ open up ↑
 130  130                  rw_exit(&sctps->sctps_g_ills_lock);
 131  131                  return;
 132  132          }
 133  133          list_remove(&sctps->sctps_g_ipifs[hindex].sctp_ipif_list,
 134  134              sctp_ipif);
 135  135          sctps->sctps_g_ipifs[hindex].ipif_count--;
 136  136          sctps->sctps_g_ipifs_count--;
 137  137          rw_destroy(&sctp_ipif->sctp_ipif_lock);
 138  138          kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
 139  139  
 140      -        (void) atomic_add_32_nv(&sctp_ill->sctp_ill_ipifcnt, -1);
      140 +        (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
 141  141          if (rw_tryupgrade(&sctps->sctps_g_ills_lock) != 0) {
 142  142                  rw_downgrade(&sctps->sctps_g_ipifs_lock);
 143  143                  if (sctp_ill->sctp_ill_ipifcnt == 0 &&
 144  144                      sctp_ill->sctp_ill_state == SCTP_ILLS_CONDEMNED) {
 145  145                          list_remove(&sctps->sctps_g_ills[ill_index].
 146  146                              sctp_ill_list, (void *)sctp_ill);
 147  147                          sctps->sctps_g_ills[ill_index].ill_count--;
 148  148                          sctps->sctps_ills_count--;
 149  149                          kmem_free(sctp_ill->sctp_ill_name,
 150  150                              sctp_ill->sctp_ill_name_length);
↓ open down ↓ 726 lines elided ↑ open up ↑
 877  877                  ip1dbg(("sctp_move_ipif: error moving ipif %p from %p to %p\n",
 878  878                      (void *)ipif, (void *)f_ill, (void *)t_ill));
 879  879                  rw_exit(&sctps->sctps_g_ipifs_lock);
 880  880                  rw_exit(&sctps->sctps_g_ills_lock);
 881  881                  return;
 882  882          }
 883  883          rw_enter(&sctp_ipif->sctp_ipif_lock, RW_WRITER);
 884  884          ASSERT(sctp_ipif->sctp_ipif_ill == fsctp_ill);
 885  885          sctp_ipif->sctp_ipif_ill = tsctp_ill;
 886  886          rw_exit(&sctp_ipif->sctp_ipif_lock);
 887      -        (void) atomic_add_32_nv(&fsctp_ill->sctp_ill_ipifcnt, -1);
 888      -        atomic_add_32(&tsctp_ill->sctp_ill_ipifcnt, 1);
      887 +        (void) atomic_dec_32_nv(&fsctp_ill->sctp_ill_ipifcnt);
      888 +        atomic_inc_32(&tsctp_ill->sctp_ill_ipifcnt);
 889  889          rw_exit(&sctps->sctps_g_ipifs_lock);
 890  890          rw_exit(&sctps->sctps_g_ills_lock);
 891  891  }
 892  892  
 893  893  /*
 894  894   * Walk the list of SCTPs and find each that has oipif in it's saddr list, and
 895  895   * if so replace it with nipif.
 896  896   */
 897  897  void
 898  898  sctp_update_saddrs(sctp_ipif_t *oipif, sctp_ipif_t *nipif, int idx,
↓ open down ↓ 191 lines elided ↑ open up ↑
1090 1090                              osctp_ipif->sctp_ipif_isv6);
1091 1091  
1092 1092                          ipif_list =
1093 1093                              &sctps->sctps_g_ipifs[ohindex].sctp_ipif_list;
1094 1094  
1095 1095                          list_remove(ipif_list, (void *)osctp_ipif);
1096 1096                          sctps->sctps_g_ipifs[ohindex].ipif_count--;
1097 1097                          sctps->sctps_g_ipifs_count--;
1098 1098                          rw_destroy(&osctp_ipif->sctp_ipif_lock);
1099 1099                          kmem_free(osctp_ipif, sizeof (sctp_ipif_t));
1100      -                        (void) atomic_add_32_nv(&osctp_ill->sctp_ill_ipifcnt,
1101      -                            -1);
     1100 +                        (void) atomic_dec_32_nv(&osctp_ill->sctp_ill_ipifcnt);
1102 1101                  }
1103 1102          }
1104 1103  
1105 1104          sctp_ipif = kmem_zalloc(sizeof (sctp_ipif_t), KM_NOSLEEP);
1106 1105          /* Try again? */
1107 1106          if (sctp_ipif == NULL) {
1108 1107                  cmn_err(CE_WARN, "sctp_update_ipif_addr: error adding "
1109 1108                      "IPIF %p to SCTP's IPIF list", (void *)ipif);
1110 1109                  rw_exit(&sctps->sctps_g_ipifs_lock);
1111 1110                  rw_exit(&sctps->sctps_g_ills_lock);
↓ open down ↓ 11 lines elided ↑ open up ↑
1123 1122          else
1124 1123                  sctp_ipif->sctp_ipif_state = SCTP_IPIFS_DOWN;
1125 1124          sctp_ipif->sctp_ipif_flags = ipif->ipif_flags;
1126 1125          /*
1127 1126           * We add it to the head so that it is quicker to find good/recent
1128 1127           * additions.
1129 1128           */
1130 1129          list_insert_head(&sctps->sctps_g_ipifs[hindex].sctp_ipif_list,
1131 1130              (void *)sctp_ipif);
1132 1131          sctps->sctps_g_ipifs[hindex].ipif_count++;
1133      -        atomic_add_32(&sctp_ill->sctp_ill_ipifcnt, 1);
     1132 +        atomic_inc_32(&sctp_ill->sctp_ill_ipifcnt);
1134 1133          if (sctp_ipif->sctp_ipif_state == SCTP_IPIFS_UP)
1135 1134                  sctp_chk_and_updt_saddr(hindex, sctp_ipif, sctps);
1136 1135          rw_exit(&sctps->sctps_g_ipifs_lock);
1137 1136          rw_exit(&sctps->sctps_g_ills_lock);
1138 1137  }
1139 1138  
1140 1139  /* Insert, Remove,  Mark up or Mark down the ipif */
1141 1140  void
1142 1141  sctp_update_ipif(ipif_t *ipif, int op)
1143 1142  {
↓ open down ↓ 59 lines elided ↑ open up ↑
1203 1202                          sctp_ipif->sctp_ipif_state = SCTP_IPIFS_CONDEMNED;
1204 1203                          rw_exit(&sctps->sctps_g_ipifs_lock);
1205 1204                          rw_exit(&sctps->sctps_g_ills_lock);
1206 1205                          return;
1207 1206                  }
1208 1207                  list_remove(ipif_list, (void *)sctp_ipif);
1209 1208                  sctps->sctps_g_ipifs[hindex].ipif_count--;
1210 1209                  sctps->sctps_g_ipifs_count--;
1211 1210                  rw_destroy(&sctp_ipif->sctp_ipif_lock);
1212 1211                  kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
1213      -                (void) atomic_add_32_nv(&sctp_ill->sctp_ill_ipifcnt, -1);
     1212 +                (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
1214 1213                  if (rw_tryupgrade(&sctps->sctps_g_ills_lock) != 0) {
1215 1214                          rw_downgrade(&sctps->sctps_g_ipifs_lock);
1216 1215                          if (sctp_ill->sctp_ill_ipifcnt == 0 &&
1217 1216                              sctp_ill->sctp_ill_state == SCTP_ILLS_CONDEMNED) {
1218 1217                                  list_remove(ill_list, (void *)sctp_ill);
1219 1218                                  sctps->sctps_ills_count--;
1220 1219                                  sctps->sctps_g_ills[ill_index].ill_count--;
1221 1220                                  kmem_free(sctp_ill->sctp_ill_name,
1222 1221                                      sctp_ill->sctp_ill_name_length);
1223 1222                                  kmem_free(sctp_ill, sizeof (sctp_ill_t));
↓ open down ↓ 799 lines elided ↑ open up ↑
2023 2022                  return;
2024 2023  
2025 2024          for (i = 0; i < SCTP_IPIF_HASH; i++) {
2026 2025                  sctp_ipif = list_tail(&sctps->sctps_g_ipifs[i].sctp_ipif_list);
2027 2026                  for (l = 0; l < sctps->sctps_g_ipifs[i].ipif_count; l++) {
2028 2027                          sctp_ill = sctp_ipif->sctp_ipif_ill;
2029 2028  
2030 2029                          list_remove(&sctps->sctps_g_ipifs[i].sctp_ipif_list,
2031 2030                              sctp_ipif);
2032 2031                          sctps->sctps_g_ipifs_count--;
2033      -                        (void) atomic_add_32_nv(&sctp_ill->sctp_ill_ipifcnt,
2034      -                            -1);
     2032 +                        (void) atomic_dec_32_nv(&sctp_ill->sctp_ill_ipifcnt);
2035 2033                          kmem_free(sctp_ipif, sizeof (sctp_ipif_t));
2036 2034                          sctp_ipif =
2037 2035                              list_tail(&sctps->sctps_g_ipifs[i].sctp_ipif_list);
2038 2036                  }
2039 2037                  sctps->sctps_g_ipifs[i].ipif_count = 0;
2040 2038          }
2041 2039          ASSERT(sctps->sctps_g_ipifs_count == 0);
2042 2040  }
2043 2041  
2044 2042  
↓ open down ↓ 50 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX