Re: git: 7ae879b14a20 - main - kern_procctl(): convert the function to be table-driven
Date: Tue, 19 Oct 2021 20:40:26 UTC
On 10/19/21 1:35 PM, Cy Schubert wrote: > In message <202110192004.19JK4jN3069844@gitrepo.freebsd.org>, Konstantin > Belous > ov writes: >> The branch main has been updated by kib: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=7ae879b14a2086df521c59c4a379d3a0 >> 72e08bc6 >> >> commit 7ae879b14a2086df521c59c4a379d3a072e08bc6 >> Author: Konstantin Belousov <kib@FreeBSD.org> >> AuthorDate: 2021-10-15 18:57:17 +0000 >> Commit: Konstantin Belousov <kib@FreeBSD.org> >> CommitDate: 2021-10-19 20:04:34 +0000 >> >> kern_procctl(): convert the function to be table-driven >> >> Reviewed by: emaste, markj >> Sponsored by: The FreeBSD Foundation >> MFC after: 1 week >> Differential revision: https://reviews.freebsd.org/D32513 >> --- >> sys/kern/kern_procctl.c | 123 +++++++++++++++++++++++++++------------------- >> -- >> 1 file changed, 69 insertions(+), 54 deletions(-) >> >> diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c >> index eb36f0822938..90c5e63c7219 100644 >> --- a/sys/kern/kern_procctl.c >> +++ b/sys/kern/kern_procctl.c >> @@ -949,7 +957,14 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t id >> , int com, void *data) >> error = EINVAL; >> break; >> } >> - if (tree_locked) >> - sx_unlock(&proctree_lock); >> + >> + switch (cmd_info->lock_tree) { >> + case SA_XLOCKED: >> + sx_xunlock(&proctree_lock); >> + break; >> + case SA_SLOCKED: >> + sx_sunlock(&proctree_lock); >> + break; >> + } >> return (error); >> } >> > > Should SA_* in fact be LA_*? SA_* in sys/sx.h assumes INVARIANTS whereas > LA_* in sys/lock.h has no such requirement. Both are for "assertions". The LA_* constants aren't really public but are the values used for witness_assert() that various foo_assert() routines in locking APIs (mtx_assert/sx_assert, etc.) can use. For locking APIs, the type-specific macros are the ones you use, e.g. SA_* with sx_assert(). Given that, SA_* is the closest match here. -- John Baldwin