From nobody Tue Oct 19 21:04:15 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4DAEB1812198; Tue, 19 Oct 2021 21:04:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HYmSx1XDWz3F70; Tue, 19 Oct 2021 21:04:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 847F71C84; Tue, 19 Oct 2021 21:04:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: 7ae879b14a20 - main - kern_procctl(): convert the function to be table-driven To: Cy Schubert Cc: Konstantin Belousov , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202110192004.19JK4jN3069844@gitrepo.freebsd.org> <202110192035.19JKZDqM026085@slippy.cwsent.com> <91ebf9d8-5547-8570-18cb-26a58baf89ba@FreeBSD.org> <202110192051.19JKpV66059807@slippy.cwsent.com> From: John Baldwin Message-ID: Date: Tue, 19 Oct 2021 14:04:15 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 In-Reply-To: <202110192051.19JKpV66059807@slippy.cwsent.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N 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 >>>> AuthorDate: 2021-10-15 18:57:17 +0000 >>>> Commit: Konstantin Belousov >>>> 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