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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/dtrace/fasttrap.c
          +++ new/usr/src/uts/common/dtrace/fasttrap.c
↓ open down ↓ 1174 lines elided ↑ open up ↑
1175 1175          fasttrap_proc_t *fprc, *new_fprc;
1176 1176  
1177 1177          bucket = &fasttrap_procs.fth_table[FASTTRAP_PROCS_INDEX(pid)];
1178 1178          mutex_enter(&bucket->ftb_mtx);
1179 1179  
1180 1180          for (fprc = bucket->ftb_data; fprc != NULL; fprc = fprc->ftpc_next) {
1181 1181                  if (fprc->ftpc_pid == pid && fprc->ftpc_acount != 0) {
1182 1182                          mutex_enter(&fprc->ftpc_mtx);
1183 1183                          mutex_exit(&bucket->ftb_mtx);
1184 1184                          fprc->ftpc_rcount++;
1185      -                        atomic_add_64(&fprc->ftpc_acount, 1);
     1185 +                        atomic_inc_64(&fprc->ftpc_acount);
1186 1186                          ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
1187 1187                          mutex_exit(&fprc->ftpc_mtx);
1188 1188  
1189 1189                          return (fprc);
1190 1190                  }
1191 1191          }
1192 1192  
1193 1193          /*
1194 1194           * Drop the bucket lock so we don't try to perform a sleeping
1195 1195           * allocation under it.
↓ open down ↓ 9 lines elided ↑ open up ↑
1205 1205  
1206 1206          /*
1207 1207           * Take another lap through the list to make sure a proc hasn't
1208 1208           * been created for this pid while we weren't under the bucket lock.
1209 1209           */
1210 1210          for (fprc = bucket->ftb_data; fprc != NULL; fprc = fprc->ftpc_next) {
1211 1211                  if (fprc->ftpc_pid == pid && fprc->ftpc_acount != 0) {
1212 1212                          mutex_enter(&fprc->ftpc_mtx);
1213 1213                          mutex_exit(&bucket->ftb_mtx);
1214 1214                          fprc->ftpc_rcount++;
1215      -                        atomic_add_64(&fprc->ftpc_acount, 1);
     1215 +                        atomic_inc_64(&fprc->ftpc_acount);
1216 1216                          ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
1217 1217                          mutex_exit(&fprc->ftpc_mtx);
1218 1218  
1219 1219                          kmem_free(new_fprc, sizeof (fasttrap_proc_t));
1220 1220  
1221 1221                          return (fprc);
1222 1222                  }
1223 1223          }
1224 1224  
1225 1225          new_fprc->ftpc_next = bucket->ftb_data;
↓ open down ↓ 191 lines elided ↑ open up ↑
1417 1417           */
1418 1418          ASSERT(provider->ftp_rcount == 0);
1419 1419          ASSERT(provider->ftp_ccount == 0);
1420 1420          ASSERT(provider->ftp_mcount == 0);
1421 1421  
1422 1422          /*
1423 1423           * If this provider hasn't been retired, we need to explicitly drop the
1424 1424           * count of active providers on the associated process structure.
1425 1425           */
1426 1426          if (!provider->ftp_retired) {
1427      -                atomic_add_64(&provider->ftp_proc->ftpc_acount, -1);
     1427 +                atomic_dec_64(&provider->ftp_proc->ftpc_acount);
1428 1428                  ASSERT(provider->ftp_proc->ftpc_acount <
1429 1429                      provider->ftp_proc->ftpc_rcount);
1430 1430          }
1431 1431  
1432 1432          fasttrap_proc_release(provider->ftp_proc);
1433 1433  
1434 1434          kmem_free(provider, sizeof (fasttrap_provider_t));
1435 1435  
1436 1436          /*
1437 1437           * Decrement p_dtrace_probes on the process whose provider we're
↓ open down ↓ 54 lines elided ↑ open up ↑
1492 1492           * releases our hold, and when this reaches zero (as it will during
1493 1493           * exit or exec) the proc and associated providers become defunct.
1494 1494           *
1495 1495           * We obviously need to take the bucket lock before the provider lock
1496 1496           * to perform the lookup, but we need to drop the provider lock
1497 1497           * before calling into the DTrace framework since we acquire the
1498 1498           * provider lock in callbacks invoked from the DTrace framework. The
1499 1499           * bucket lock therefore protects the integrity of the provider hash
1500 1500           * table.
1501 1501           */
1502      -        atomic_add_64(&fp->ftp_proc->ftpc_acount, -1);
     1502 +        atomic_dec_64(&fp->ftp_proc->ftpc_acount);
1503 1503          ASSERT(fp->ftp_proc->ftpc_acount < fp->ftp_proc->ftpc_rcount);
1504 1504  
1505 1505          fp->ftp_retired = 1;
1506 1506          fp->ftp_marked = 1;
1507 1507          provid = fp->ftp_provid;
1508 1508          mutex_exit(&fp->ftp_mtx);
1509 1509  
1510 1510          /*
1511 1511           * We don't have to worry about invalidating the same provider twice
1512 1512           * since fasttrap_provider_lookup() will ignore provider that have
↓ open down ↓ 75 lines elided ↑ open up ↑
1588 1588                  for (i = 0; i < pdata->ftps_noffs; i++) {
1589 1589                          char name_str[17];
1590 1590  
1591 1591                          (void) sprintf(name_str, "%llx",
1592 1592                              (unsigned long long)pdata->ftps_offs[i]);
1593 1593  
1594 1594                          if (dtrace_probe_lookup(provider->ftp_provid,
1595 1595                              pdata->ftps_mod, pdata->ftps_func, name_str) != 0)
1596 1596                                  continue;
1597 1597  
1598      -                        atomic_add_32(&fasttrap_total, 1);
     1598 +                        atomic_inc_32(&fasttrap_total);
1599 1599  
1600 1600                          if (fasttrap_total > fasttrap_max) {
1601      -                                atomic_add_32(&fasttrap_total, -1);
     1601 +                                atomic_dec_32(&fasttrap_total);
1602 1602                                  goto no_mem;
1603 1603                          }
1604 1604  
1605 1605                          pp = kmem_zalloc(sizeof (fasttrap_probe_t), KM_SLEEP);
1606 1606  
1607 1607                          pp->ftp_prov = provider;
1608 1608                          pp->ftp_faddr = pdata->ftps_pc;
1609 1609                          pp->ftp_fsize = pdata->ftps_size;
1610 1610                          pp->ftp_pid = pdata->ftps_pid;
1611 1611                          pp->ftp_ntps = 1;
↓ open down ↓ 775 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX