Date: Tue, 19 Oct 2021 14:04:15 -0700 From: John Baldwin <jhb@FreeBSD.org> To: Cy Schubert <Cy.Schubert@cschubert.com> Cc: Konstantin Belousov <kib@FreeBSD.org>, src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 7ae879b14a20 - main - kern_procctl(): convert the function to be table-driven Message-ID: <d2c0d3d7-a993-37c2-3fa7-aac8f30e9508@FreeBSD.org> In-Reply-To: <202110192051.19JKpV66059807@slippy.cwsent.com> References: <202110192004.19JK4jN3069844@gitrepo.freebsd.org> <202110192035.19JKZDqM026085@slippy.cwsent.com> <91ebf9d8-5547-8570-18cb-26a58baf89ba@FreeBSD.org> <202110192051.19JKpV66059807@slippy.cwsent.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/19/21 1:51 PM, Cy Schubert wrote: > In message <91ebf9d8-5547-8570-18cb-26a58baf89ba@FreeBSD.org>, John Baldwin > wri > tes: >> 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=7ae879b14a2086df521c59c4a379d >> 3a0 >>>> 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. > > We'll need some #ifdefs for non-INVARIANTS built kernels, as it stands > buildkernel is broken. So it is helpeful if your e-mail starts with "the build is broken". :) That said, I think the issue is that SA_* (and LA_*) have to date only been used for assertions and are thus only relevant when INVARIANTS is defined. It's probably simplest to just expose SA_* always if that is what is needed. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d2c0d3d7-a993-37c2-3fa7-aac8f30e9508>