mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-30 08:19:09 +00:00
Replace hand-rolled unrefs if > 1 with refcount_release_if_not_last
Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
f07c942dd8
commit
6ff4688b09
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341698
@ -4023,13 +4023,11 @@ prison_racct_free_locked(struct prison_racct *prr)
|
||||
void
|
||||
prison_racct_free(struct prison_racct *prr)
|
||||
{
|
||||
int old;
|
||||
|
||||
ASSERT_RACCT_ENABLED();
|
||||
sx_assert(&allprison_lock, SA_UNLOCKED);
|
||||
|
||||
old = prr->prr_refcount;
|
||||
if (old > 1 && atomic_cmpset_int(&prr->prr_refcount, old, old - 1))
|
||||
if (refcount_release_if_not_last(&prr->prr_refcount))
|
||||
return;
|
||||
|
||||
sx_xlock(&allprison_lock);
|
||||
|
@ -84,10 +84,8 @@ loginclass_hold(struct loginclass *lc)
|
||||
void
|
||||
loginclass_free(struct loginclass *lc)
|
||||
{
|
||||
int old;
|
||||
|
||||
old = lc->lc_refcount;
|
||||
if (old > 1 && atomic_cmpset_int(&lc->lc_refcount, old, old - 1))
|
||||
if (refcount_release_if_not_last(&lc->lc_refcount))
|
||||
return;
|
||||
|
||||
rw_wlock(&loginclasses_lock);
|
||||
|
@ -1323,14 +1323,10 @@ uihold(struct uidinfo *uip)
|
||||
void
|
||||
uifree(struct uidinfo *uip)
|
||||
{
|
||||
int old;
|
||||
|
||||
/* Prepare for optimal case. */
|
||||
old = uip->ui_ref;
|
||||
if (old > 1 && atomic_cmpset_int(&uip->ui_ref, old, old - 1))
|
||||
if (refcount_release_if_not_last(&uip->ui_ref))
|
||||
return;
|
||||
|
||||
/* Prepare for suboptimal case. */
|
||||
rw_wlock(&uihashtbl_lock);
|
||||
if (refcount_release(&uip->ui_ref) == 0) {
|
||||
rw_wunlock(&uihashtbl_lock);
|
||||
|
Loading…
Reference in New Issue
Block a user