Skip to content

Commit

Permalink
5045 use atomic_{inc,dec}_* instead of atomic_add_*
Browse files Browse the repository at this point in the history
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Garrett D'Amore <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
  • Loading branch information
Josef 'Jeff' Sipek authored and rmustacc committed Aug 12, 2014
1 parent febac2a commit 1a5e258
Show file tree
Hide file tree
Showing 195 changed files with 768 additions and 810 deletions.
4 changes: 2 additions & 2 deletions usr/src/uts/common/crypto/io/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ crypto_hold_minor(minor_t minor)
mutex_enter(&mp->kl_lock);

if ((cm = crypto_minors[minor - 1]) != NULL) {
atomic_add_32(&cm->cm_refcnt, 1);
atomic_inc_32(&cm->cm_refcnt);
}
mutex_exit(&mp->kl_lock);
return (cm);
Expand All @@ -636,7 +636,7 @@ crypto_hold_minor(minor_t minor)
static void
crypto_release_minor(crypto_minor_t *cm)
{
if (atomic_add_32_nv(&cm->cm_refcnt, -1) == 0) {
if (atomic_dec_32_nv(&cm->cm_refcnt) == 0) {
cv_signal(&cm->cm_cv);
}
}
Expand Down
4 changes: 2 additions & 2 deletions usr/src/uts/common/crypto/io/dprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ typedef struct dprov_object {
* it REFHOLD()s.
*/
#define DPROV_OBJECT_REFHOLD(object) { \
atomic_add_32(&(object)->do_refcnt, 1); \
atomic_inc_32(&(object)->do_refcnt); \
ASSERT((object)->do_refcnt != 0); \
}

Expand All @@ -1112,7 +1112,7 @@ typedef struct dprov_object {
#define DPROV_OBJECT_REFRELE(object) { \
ASSERT((object)->do_refcnt != 0); \
membar_exit(); \
if (atomic_add_32_nv(&(object)->do_refcnt, -1) == 0) \
if (atomic_dec_32_nv(&(object)->do_refcnt) == 0) \
dprov_free_object(object); \
}

Expand Down
8 changes: 4 additions & 4 deletions usr/src/uts/common/disp/cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,9 @@ cmt_ev_thread_swtch(pg_t *pg, cpu_t *cp, hrtime_t now, kthread_t *old,
pg_cmt_t *cmt_pg = (pg_cmt_t *)pg;

if (old == cp->cpu_idle_thread) {
atomic_add_32(&cmt_pg->cmt_utilization, 1);
atomic_inc_32(&cmt_pg->cmt_utilization);
} else if (new == cp->cpu_idle_thread) {
atomic_add_32(&cmt_pg->cmt_utilization, -1);
atomic_dec_32(&cmt_pg->cmt_utilization);
}
}

Expand All @@ -1383,7 +1383,7 @@ cmt_ev_thread_swtch_pwr(pg_t *pg, cpu_t *cp, hrtime_t now, kthread_t *old,

if (old == cp->cpu_idle_thread) {
ASSERT(new != cp->cpu_idle_thread);
u = atomic_add_32_nv(&cmt->cmt_utilization, 1);
u = atomic_inc_32_nv(&cmt->cmt_utilization);
if (u == 1) {
/*
* Notify the CPU power manager that the domain
Expand All @@ -1395,7 +1395,7 @@ cmt_ev_thread_swtch_pwr(pg_t *pg, cpu_t *cp, hrtime_t now, kthread_t *old,
}
} else if (new == cp->cpu_idle_thread) {
ASSERT(old != cp->cpu_idle_thread);
u = atomic_add_32_nv(&cmt->cmt_utilization, -1);
u = atomic_dec_32_nv(&cmt->cmt_utilization);
if (u == 0) {
/*
* The domain is idle, notify the CPU power
Expand Down
12 changes: 6 additions & 6 deletions usr/src/uts/common/dtrace/fasttrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ fasttrap_proc_lookup(pid_t pid)
mutex_enter(&fprc->ftpc_mtx);
mutex_exit(&bucket->ftb_mtx);
fprc->ftpc_rcount++;
atomic_add_64(&fprc->ftpc_acount, 1);
atomic_inc_64(&fprc->ftpc_acount);
ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
mutex_exit(&fprc->ftpc_mtx);

Expand Down Expand Up @@ -1212,7 +1212,7 @@ fasttrap_proc_lookup(pid_t pid)
mutex_enter(&fprc->ftpc_mtx);
mutex_exit(&bucket->ftb_mtx);
fprc->ftpc_rcount++;
atomic_add_64(&fprc->ftpc_acount, 1);
atomic_inc_64(&fprc->ftpc_acount);
ASSERT(fprc->ftpc_acount <= fprc->ftpc_rcount);
mutex_exit(&fprc->ftpc_mtx);

Expand Down Expand Up @@ -1424,7 +1424,7 @@ fasttrap_provider_free(fasttrap_provider_t *provider)
* count of active providers on the associated process structure.
*/
if (!provider->ftp_retired) {
atomic_add_64(&provider->ftp_proc->ftpc_acount, -1);
atomic_dec_64(&provider->ftp_proc->ftpc_acount);
ASSERT(provider->ftp_proc->ftpc_acount <
provider->ftp_proc->ftpc_rcount);
}
Expand Down Expand Up @@ -1499,7 +1499,7 @@ fasttrap_provider_retire(pid_t pid, const char *name, int mprov)
* bucket lock therefore protects the integrity of the provider hash
* table.
*/
atomic_add_64(&fp->ftp_proc->ftpc_acount, -1);
atomic_dec_64(&fp->ftp_proc->ftpc_acount);
ASSERT(fp->ftp_proc->ftpc_acount < fp->ftp_proc->ftpc_rcount);

fp->ftp_retired = 1;
Expand Down Expand Up @@ -1595,10 +1595,10 @@ fasttrap_add_probe(fasttrap_probe_spec_t *pdata)
pdata->ftps_mod, pdata->ftps_func, name_str) != 0)
continue;

atomic_add_32(&fasttrap_total, 1);
atomic_inc_32(&fasttrap_total);

if (fasttrap_total > fasttrap_max) {
atomic_add_32(&fasttrap_total, -1);
atomic_dec_32(&fasttrap_total);
goto no_mem;
}

Expand Down
6 changes: 3 additions & 3 deletions usr/src/uts/common/dtrace/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ profile_create(hrtime_t interval, const char *name, int kind)
if (dtrace_probe_lookup(profile_id, NULL, NULL, name) != 0)
return;

atomic_add_32(&profile_total, 1);
atomic_inc_32(&profile_total);
if (profile_total > profile_max) {
atomic_add_32(&profile_total, -1);
atomic_dec_32(&profile_total);
return;
}

Expand Down Expand Up @@ -328,7 +328,7 @@ profile_destroy(void *arg, dtrace_id_t id, void *parg)
kmem_free(prof, sizeof (profile_probe_t));

ASSERT(profile_total >= 1);
atomic_add_32(&profile_total, -1);
atomic_dec_32(&profile_total);
}

/*ARGSUSED*/
Expand Down
2 changes: 1 addition & 1 deletion usr/src/uts/common/fs/ctfs/ctfs_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ ctfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
vfsp->vfs_fstype = ctfs_fstype;
do {
dev = makedevice(ctfs_major,
atomic_add_32_nv(&ctfs_minor, 1) & L_MAXMIN32);
atomic_inc_32_nv(&ctfs_minor) & L_MAXMIN32);
} while (vfs_devismounted(dev));
vfs_make_fsid(&vfsp->vfs_fsid, dev, ctfs_fstype);
vfsp->vfs_data = data;
Expand Down
4 changes: 2 additions & 2 deletions usr/src/uts/common/fs/dnlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ vnode_t negative_cache_vnode;
#define dnlc_free(ncp) \
{ \
kmem_free((ncp), sizeof (ncache_t) + (ncp)->namlen); \
atomic_add_32(&dnlc_nentries, -1); \
atomic_dec_32(&dnlc_nentries); \
}


Expand Down Expand Up @@ -1024,7 +1024,7 @@ dnlc_get(uchar_t namlen)
return (NULL);
}
ncp->namlen = namlen;
atomic_add_32(&dnlc_nentries, 1);
atomic_inc_32(&dnlc_nentries);
dnlc_reduce_cache(NULL);
return (ncp);
}
Expand Down
4 changes: 2 additions & 2 deletions usr/src/uts/common/fs/fem.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,13 @@ fem_unlock(struct fem_head *fp)
static void
fem_addref(struct fem_list *sp)
{
atomic_add_32(&sp->feml_refc, 1);
atomic_inc_32(&sp->feml_refc);
}

static uint32_t
fem_delref(struct fem_list *sp)
{
return (atomic_add_32_nv(&sp->feml_refc, -1));
return (atomic_dec_32_nv(&sp->feml_refc));
}

static struct fem_list *
Expand Down
8 changes: 3 additions & 5 deletions usr/src/uts/common/fs/lofs/lofs_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

/*
* The idea behind composition-based stacked filesystems is to add a
* vnode to the stack of vnodes for each mount. These vnodes have their
Expand Down Expand Up @@ -289,7 +287,7 @@ makelonode(struct vnode *vp, struct loinfo *li, int flag)
}
lp = tlp;
}
atomic_add_32(&li->li_refct, 1);
atomic_inc_32(&li->li_refct);
vfsp = makelfsnode(vp->v_vfsp, li);
lp->lo_vnode = nvp;
VN_SET_VFS_TYPE_DEV(nvp, vfsp, vp->v_type, vp->v_rdev);
Expand Down Expand Up @@ -632,7 +630,7 @@ lfs_rele(struct lfsnode *lfs, struct loinfo *li)

ASSERT(MUTEX_HELD(&li->li_lfslock));
ASSERT(vfsp->vfs_count > 1);
if (atomic_add_32_nv(&vfsp->vfs_count, -1) == 1)
if (atomic_dec_32_nv(&vfsp->vfs_count) == 1)
freelfsnode(lfs, li);
}

Expand Down Expand Up @@ -672,7 +670,7 @@ freelonode(lnode_t *lp)
lo_dprint(4, "freeing %p, vfsp %p\n",
vp, vp->v_vfsp);
#endif
atomic_add_32(&li->li_refct, -1);
atomic_dec_32(&li->li_refct);
vfsp = vp->v_vfsp;
vn_invalid(vp);
if (vfsp != li->li_mountvfs) {
Expand Down
4 changes: 2 additions & 2 deletions usr/src/uts/common/fs/mntfs/mntvnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ mntopen(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
nmnp = mntgetnode(vp);

*vpp = MTOV(nmnp);
atomic_add_32(&MTOD(nmnp)->mnt_nopen, 1);
atomic_inc_32(&MTOD(nmnp)->mnt_nopen);
VN_RELE(vp);
return (0);
}
Expand All @@ -875,7 +875,7 @@ mntclose(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr,
mntfs_freesnap(mnp, &mnp->mnt_read);
mntfs_freesnap(mnp, &mnp->mnt_ioctl);
rw_exit(&mnp->mnt_contents);
atomic_add_32(&MTOD(mnp)->mnt_nopen, -1);
atomic_dec_32(&MTOD(mnp)->mnt_nopen);
}
return (0);
}
Expand Down
6 changes: 3 additions & 3 deletions usr/src/uts/common/fs/nfs/nfs3_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -5276,11 +5276,11 @@ nfs3_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,

if (nfs_rw_enter_sig(&rp->r_rwlock, RW_WRITER, INTR(vp)))
return (EINTR);
atomic_add_int(&rp->r_inmap, 1);
atomic_inc_uint(&rp->r_inmap);
nfs_rw_exit(&rp->r_rwlock);

if (nfs_rw_enter_sig(&rp->r_lkserlock, RW_READER, INTR(vp))) {
atomic_add_int(&rp->r_inmap, -1);
atomic_dec_uint(&rp->r_inmap);
return (EINTR);
}

Expand Down Expand Up @@ -5322,7 +5322,7 @@ nfs3_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,

done:
nfs_rw_exit(&rp->r_lkserlock);
atomic_add_int(&rp->r_inmap, -1);
atomic_dec_uint(&rp->r_inmap);
return (error);
}

Expand Down
8 changes: 4 additions & 4 deletions usr/src/uts/common/fs/nfs/nfs4_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3148,15 +3148,15 @@ nfs_free_mi4(mntinfo4_t *mi)
void
mi_hold(mntinfo4_t *mi)
{
atomic_add_32(&mi->mi_count, 1);
atomic_inc_32(&mi->mi_count);
ASSERT(mi->mi_count != 0);
}

void
mi_rele(mntinfo4_t *mi)
{
ASSERT(mi->mi_count != 0);
if (atomic_add_32_nv(&mi->mi_count, -1) == 0) {
if (atomic_dec_32_nv(&mi->mi_count) == 0) {
nfs_free_mi4(mi);
}
}
Expand Down Expand Up @@ -4111,7 +4111,7 @@ fn_get(nfs4_fname_t *parent, char *name, nfs4_sharedfh_t *sfh)
void
fn_hold(nfs4_fname_t *fnp)
{
atomic_add_32(&fnp->fn_refcnt, 1);
atomic_inc_32(&fnp->fn_refcnt);
NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
"fn_hold %p:%s, new refcnt=%d",
(void *)fnp, fnp->fn_name, fnp->fn_refcnt));
Expand All @@ -4137,7 +4137,7 @@ fn_rele(nfs4_fname_t **fnpp)
parent = fnp->fn_parent;
if (parent != NULL)
mutex_enter(&parent->fn_lock); /* prevent new references */
newref = atomic_add_32_nv(&fnp->fn_refcnt, -1);
newref = atomic_dec_32_nv(&fnp->fn_refcnt);
if (newref > 0) {
NFS4_DEBUG(nfs4_fname_debug, (CE_NOTE,
"fn_rele %p:%s, new refcnt=%d",
Expand Down
6 changes: 3 additions & 3 deletions usr/src/uts/common/fs/nfs/nfs4_client_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ static uint64_t open_owner_seq_num = 0;
uint64_t
nfs4_get_new_oo_name(void)
{
return (atomic_add_64_nv(&open_owner_seq_num, 1));
return (atomic_inc_64_nv(&open_owner_seq_num));
}

/*
Expand Down Expand Up @@ -836,7 +836,7 @@ create_lock_owner(rnode4_t *rp, pid_t pid)
* A Solaris lock_owner is <seq_num><pid>
*/
lop->lock_owner_name.ln_seq_num =
atomic_add_64_nv(&lock_owner_seq_num, 1);
atomic_inc_64_nv(&lock_owner_seq_num);
lop->lock_owner_name.ln_pid = pid;

cv_init(&lop->lo_cv_seqid_sync, NULL, CV_DEFAULT, NULL);
Expand Down Expand Up @@ -883,7 +883,7 @@ nfs4_set_new_lock_owner_args(lock_owner4 *owner, pid_t pid)
* A Solaris lock_owner is <seq_num><pid>
*/
cast_namep = (nfs4_lo_name_t *)owner->owner_val;
cast_namep->ln_seq_num = atomic_add_64_nv(&lock_owner_seq_num, 1);
cast_namep->ln_seq_num = atomic_inc_64_nv(&lock_owner_seq_num);
cast_namep->ln_pid = pid;
}

Expand Down
6 changes: 3 additions & 3 deletions usr/src/uts/common/fs/nfs/nfs4_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rfs4_dbe_getid(rfs4_dbe_t *entry)
void
rfs4_dbe_hold(rfs4_dbe_t *entry)
{
atomic_add_32(&entry->dbe_refcnt, 1);
atomic_inc_32(&entry->dbe_refcnt);
}

/*
Expand All @@ -69,7 +69,7 @@ rfs4_dbe_hold(rfs4_dbe_t *entry)
void
rfs4_dbe_rele_nolock(rfs4_dbe_t *entry)
{
atomic_add_32(&entry->dbe_refcnt, -1);
atomic_dec_32(&entry->dbe_refcnt);
}


Expand Down Expand Up @@ -129,7 +129,7 @@ rfs4_dbe_rele(rfs4_dbe_t *entry)
{
mutex_enter(entry->dbe_lock);
ASSERT(entry->dbe_refcnt > 1);
atomic_add_32(&entry->dbe_refcnt, -1);
atomic_dec_32(&entry->dbe_refcnt);
entry->dbe_time_rele = gethrestime_sec();
mutex_exit(entry->dbe_lock);
}
Expand Down
4 changes: 2 additions & 2 deletions usr/src/uts/common/fs/nfs/nfs4_rnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ make_rnode4(nfs4_sharedfh_t *fh, r4hashq_t *rhtp, struct vfs *vfsp,
rp = kmem_cache_alloc(rnode4_cache, KM_SLEEP);
new_vp = vn_alloc(KM_SLEEP);

atomic_add_long((ulong_t *)&rnode4_new, 1);
atomic_inc_ulong((ulong_t *)&rnode4_new);
#ifdef DEBUG
clstat4_debug.nrnode.value.ui64++;
#endif
Expand Down Expand Up @@ -1220,7 +1220,7 @@ destroy_rnode4(rnode4_t *rp)
vfsp = vp->v_vfsp;

uninit_rnode4(rp);
atomic_add_long((ulong_t *)&rnode4_new, -1);
atomic_dec_ulong((ulong_t *)&rnode4_new);
#ifdef DEBUG
clstat4_debug.nrnode.value.ui64--;
#endif
Expand Down
Loading

0 comments on commit 1a5e258

Please sign in to comment.