HomeFreeBSD

MFC jail: Change the locking around pr_ref and pr_uref

Description

MFC jail: Change the locking around pr_ref and pr_uref

Require both the prison mutex and allprison_lock when pr_ref or
pr_uref go to/from zero. Adding a non-first or removing a non-last
reference remain lock-free. This means that a shared hold on
allprison_lock is sufficient for prison_isalive() to be useful, which
removes a number of cases of lock/check/unlock on the prison mutex.

Expand the locking in kern_jail_set() to keep allprison_lock held
exclusive until the new prison is valid, thus making invalid prisons
invisible to any thread holding allprison_lock (except of course the
one creating or destroying the prison). This renders prison_isvalid()
nearly redundant, now used only in asserts.

Differential Revision: https://reviews.freebsd.org/D28419
Differential Revision: https://reviews.freebsd.org/D28458

(cherry picked from commit f7496dcab0360a74bfb00cd6118f66323fffda61)

MFC jail: fix build after the previous commit
Noted by: Michael Butler <imb protected-networks.net>

(cherry picked from commit ee9b37ae5c115c41835119bb5c9d2e14c83abd65)

Details

Provenance
jamieAuthored on Feb 21 2021, 6:55 PM
Differential Revision
D28419: Require allprison_lock and prison mutex when to free last prison reference
Parents
rGfe6b360a6293: MFC jail: Improve locking when removing prisons
Branches
Unknown
Tags
Unknown