Article View: linux.kernel.netdev
Article #25711Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type
From: Joel Granados
Date: Wed, 02 Dec 2026 09:36
Date: Wed, 02 Dec 2026 09:36
98 lines
11794 bytes
11794 bytes
--shzvw6gp52lynawk
Content-Type: text/plain; protected-headers=v1; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct
template type
MIME-Version: 1.0
On Thu, Nov 26, 2026 at 09:04:40AM -0800, Linus Torvalds wrote:
> On Thu, 26 Nov 2026 at 03:47, Joel Granados <joel.granados@kernel.org> wr=
ote:
> >
> > +/* Template version of struct ctl_table. Used for registering ctl_tabl=
e templates */
> > +struct ctl_table_tmpl {
> > + struct ctl_table t;
> > +};
>=20
> So I really don't like members named 't'.
>=20
> I see why you are doing it, but maybe you aren't aware that we already
> enabled ms-extensions, and you can actually use *unnamed* structs in
> templates.
>=20
> So you can do
>=20
> struct ctl_table_tmpl { struct ctl_table; }
>=20
> and that gives you a new type that you can use without any "t." kind
> of thing, but is still distinct from 'struct ctl_table".
That looks cleaner; I'll try to use it for the V1.
>=20
> Note: being unnamed is very convenient in some situations, less so in
> others. If you actually then want to access not the individual fields
> (which is very easy), but get from the template to an actual "struct
> ctl_table", you'd have to use some explicit helper wrapper, something
> like
>=20
> static inline struct ctl_table *template_to_inner(struct ctl_table_tmp=
l *a)
> { return container_of(&a->procname, struct ctl_table, procname); }
>=20
> or whatever.
>=20
> Honestly, right now you seem to do something really ugly: you have
> that 'template', but then you hardly ever *use* it as anything but a
> top-level interface, and you turn it into a 'struct ctl_table *' very
> early. And that looks like it's done exactly to avoid the whole
> messiness with the 't' member - but it also measn that internally that
> "template" has lost almost all meaning, and it looks like a regular
> ctl_table.
I used the ctl_table_tmpl type as a way for the caller to signal the
type of registration. I agree, it is superficial. And the caller already
signals it buy using the template registration function.
>=20
> Maybe that's fine. But it feels like the template is less of a real
> template than just a wrapper that is only used at the top-level
> wrapper and then never again. That does *not* work well if you were to
> add a few extra fields to the template (that is then *not* in the
> struct ctl_table. because they are only used to set it up). Hmm?
>=20
> Linus
Thx for the review.
I'll either remove the template altogether and just have a ""context"
registration function that accepts two ctl_table and inits the context
or I'll make more use of the template in sysctl core as I might have
missed an advantage to having the template within the sysctl core.
Best
--shzvw6gp52lynawk
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmsP5pMACgkQupfNUreW
QU+3ewv/ZF8UXw+ghOokDd4QECIvblmO2MzsVAUWRrEYPSoc9PhjL3EAggfdHfaV
+Lo7TAY3mStJ22HvZaSIpeuLxhguTXVx1V8CacDHIXxDYY5QdvItOK2bQRKu/khD
NwqEsjFcUM9BwtcCha552EC2YRqPlMSr+uFTnLH8uf2gsdu0gkg96gfYIgof+9Lb
N6xJza0KHtGIyt5+50worlLqwhjm3ZJxXlzGKM87b13GkMdGWwP7Qtly+M112ArK
Ww8gil0peJpZ5W11AWd6SZOrztvdAgMKwAXyWcDnmYzQJLX+aqHUFPf+lDTnHS/A
1RkFkAxLBHKilZvCuwvJIPY/oF4tJdpIeAt77gauM38W26E/8ewko2SEzQ0B2dMn
GGHW3q1JkNfM9DMt5XPTyYTEMJstIIYdt+6DJqAEu8XjkGwD99yAsqvJl+7M6y7w
JBEMmmYVYiHaY3tB5bjFXg+5l8Hrqmt1j1VXLu8XEAsxG4348mcM0XzeSG585z96
QVZrg5+X
=c/KX
-----END PGP SIGNATURE-----
--shzvw6gp52lynawk--
Technical Details
Message-ID:
<aw_Z0mTMuhQb7W2w@hobbes>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375692-linux-kernel-netdev=dewy.ruReferences:
<20261126-lklm-sysctl-ctx-flatarray-v1-0-d7fc9cc9b03e@kernel.org> <20261126-lklm-sysctl-ctx-flatarray-v1-1-d7fc9cc9b03e@kernel.org> <CAHk-=wir6u-wFF8+V6DZTqJUsgvRrSpkZ_FV9QcK58G-b1N7bA@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375692-linux-kernel-netdev=dewy.ru From: joel.granados@kernel.org (Joel Granados) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type Date: Wed, 2 Dec 2026 10:36:39 +0100 Organization: Usenet Network Message-ID: <aw_Z0mTMuhQb7W2w@hobbes> References: <20261126-lklm-sysctl-ctx-flatarray-v1-0-d7fc9cc9b03e@kernel.org> <20261126-lklm-sysctl-ctx-flatarray-v1-1-d7fc9cc9b03e@kernel.org> <CAHk-=wir6u-wFF8+V6DZTqJUsgvRrSpkZ_FV9QcK58G-b1N7bA@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="shzvw6gp52lynawk" Injection-Info: usenet.network; logging-data="1937472"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rg8L6OJUFSW4gHiwzN39wXKoFtA= sha256:Gcijeqq8Tx5A3UM+DMlJScKEoVN7xwbCkALDR/9omD4= sha1:Fwx4pGqwABn9g7JfTwTFBD0i7IE= sha256:mY8z111Liw8ZmsQs5JO1btAqLkLj5Ns2YbhNGOcAGrg= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 77C231175DF; Wed, 2 Dec 2026 12:37:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zBoM4c5eZR5S; Wed, 2 Dec 2026 12:37:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375692-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 6B40E1175DB; Wed, 2 Dec 2026 12:37:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C9EE929E7B; Wed, 2 Dec 2026 09:37:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796204249; b=tNXNFbUOhp2HyuhllONs/Za2FDFpYxj7N/oOhaOa8s0l6JltNAv/69h/UN7OIgbrf1RH 4RYCNccVe3sZo1yHWjYMk3IL1SELu2Woc4p+jT+gtr1Sv2ANyIU0y+2hu67CJfUSmv9yn YyhUZtuXoiToZByYb9sAkJk1oKVOjuG14yK4/iBVGmGGmIyhZh2BWHM09CgvnoNUsmrOz 8tMNupZg+y0eHSUVUztnQStNtz2iitRmMmISTk/AZoNHlrVLDIfQNjkzgnwF2MUrdJTKc /Z29VCYmqpu4j2g6/Dikzz2UORmGQgzQCLurt/n6XGE0HYjgFqQmSMufTXgsS+W59Mw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204249; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=zD7HRHmFDRR0eCef9A3a14Jf6qExzTTX4Xappx3Ox90=; b=eUPC3bSDIpQZQGm+TaQb4ywpR094drUiUkhXFSxvPCNAVSYDhqSBv7TDbUv66Qsp3FI3 9b47KSAhUqM9U1KUtLxJlw103BeszkeyBTDzkYuv97g/jNrDiXHvo98mwSxXLluAmYQXc ZMLzSjSPHLHTNekNBpEaloLf9QuN7PJlYvNVLxesRfISKYnLK3I1UTbhQXHMfCJd4ulus mt0Yg68YN+KamMRxd6co/I8ih8goNVxg+yEz4FffhcVGCFUdJ7fFvg4WS6rg/KGbWNbsz 5eKB39Ow0PdEaXs3jw8bHjY6AE3wHL6kpbwpxysa4JEnHuK371DVoqAK8zKkI2w6uZw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wss1+Bfy; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19E93606A33B; Wed, 2 Dec 2026 09:37:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wss1+Bfy X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796204248; b=vBPPYQkyfKUyAwchVGkntwd49rit9RDgitiANiFGtwmKxCXq1JoVPNy7K10o9xtw2hrf NqUOC82CZM+yZQI8ZJGL9ORSiHC8TJt+TR/aLrYUrQZmBCUrQHbZ0ZCxKEr0Ii6LwPZ/b 3Jq89zi4wMbAS5u9aae/8RqymqPBB1jH4FnoN3uFO3GDXmy4h3ufMcm12FMUvLGvgojhL lxsr+LssBn/XaaIkacUk5DC40AokkKu7bwbC4fQZoVjp5bk3/nrmUkvjpY3T1oGanvYdw kS7AFBp3Hu9q6YyOl0eCSKc5vg9IYzX1HtlFGVPNI7kvKX6fec3DA+zKqExP1bJAANQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204248; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=zD7HRHmFDRR0eCef9A3a14Jf6qExzTTX4Xappx3Ox90=; b=5JTxUNG8JKTXVcOVsJON8Omb0kKGmXgJvx26MFUf0KjP1AsJdLo7A8JZFZ/cnyJaOUxk hsdoZuNudESY4I9T49tqeDb2Uo42o2380KdE6JlnOpFQ0+tibjqX2/Zm6rgWDKLtKep2O OG6A7WHlyGN14MLJ0lu3yXVZTDOZdL6FxSnidEPpjljm+JLxP8wbvtW+wWrrCREuRVJiA /O54lVsUq52MU+qAC5UvGaWocNcaQJQkixOLYJQd6WAlbNy+85TLRwvdb5U2VXVCyQC4O YD1PabqRBn+9CrLn8YkjD0FObuC3U4YeZRkNVIH7NshbDsIEUJHFEdRkbM/lkQFt1lQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wss1+Bfy; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CE90606A325; Wed, 2 Dec 2026 09:37:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 426DB1F008A0; Wed, 2 Dec 2026 09:37:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796204247; bh=zD7HRHmFDRR0eCef9A3a14Jf6qExzTTX4Xappx3Ox90=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Wss1+BfyzaqlV0BlcyLW/johNgphjwUcvE0+k4ZArlqNWO7vaAj6xQUJ875dmn6bc b8ezJfpll8sMlfd0UvVstzno+oFd3OZUfnH3mJ6myYgquxGu4x9Jz3bImghEeMs2RE i4wQRALIBEEEg8PRtd92DOn3+n+MpZGxk2OdiK7HtsMFOYDubENwvtaoPDkUaNOMgj k5hcg7jyWlAqrtes8cPwFYNnwTMv59LvvmKtNhY1AbB/j2NiIwiRtiM58c+6zReysn BRXZeiLUrwOnK9FJYdLmqaKTWzrlhPzl8NXSHNrqlf9oTGRptcCsJ7Wj2G0WhDXfRZ 2KluWmExoeMYA== X-Cc: Kees Cook <kees@kernel.org>, Alexey Gladkov <legion@kernel.org>, David Laight <david.laight.linux@gmail.com>, Wen Yang <wen.yang@linux.dev>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <CAHk-=wir6u-wFF8+V6DZTqJUsgvRrSpkZ_FV9QcK58G-b1N7bA@mail.gmail.com>