Article View: linux.kernel.netdev
Article #27350Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type
From: Alexey Gladkov
Date: Sat, 05 Dec 2026 11:34
Date: Sat, 05 Dec 2026 11:34
78 lines
11048 bytes
11048 bytes
On Wed, Dec 02, 2026 at 10:36:39AM +0100, Joel Granados wrote:
> 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> wrote:
> > >
> > > +/* Template version of struct ctl_table. Used for registering ctl_table templates */
> > > +struct ctl_table_tmpl {
> > > + struct ctl_table t;
> > > +};
> >
> > So I really don't like members named 't'.
> >
> > 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.
> >
> > So you can do
> >
> > struct ctl_table_tmpl { struct ctl_table; }
> >
> > 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.
>
> >
> > 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
> >
> > static inline struct ctl_table *template_to_inner(struct ctl_table_tmpl *a)
> > { return container_of(&a->procname, struct ctl_table, procname); }
> >
> > or whatever.
> >
> > 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.
>
> >
> > 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?
> >
> > 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
>
I just wanted to ask. Should we go back to my patches [1], or do they
still not make sense to you?
They do not have void pointers to pointers, and no memory is allocated for
customizing the ctl_table.
[1] https://lore.kernel.org/all/cover.1790439358.git.legion@kernel.org/
--
Rgrds, legion
Technical Details
Message-ID:
<axP21TKjzXZR5jth@example.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377954-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> <aw_Z0mTMuhQb7W2w@hobbes>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377954-linux-kernel-netdev=dewy.ru From: legion@kernel.org (Alexey Gladkov) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type Date: Sat, 5 Dec 2026 12:34:45 +0100 Organization: Usenet Network Message-ID: <axP21TKjzXZR5jth@example.org> 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> <aw_Z0mTMuhQb7W2w@hobbes> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3016293"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XqfH5YR+Loh5fXL54Jch7MSwDyQ= sha256:ji7Y7a/HEXpt4yx4Yz/6M2xqFe+xi8HnLRXgVQRY03I= sha1:G0y27xZD3wkZaEVfA72qbsz2sGY= sha256:PUjdHNMP0H4NpKVARTIEDOtO5WAwIYu/1qVoXx3SICY= 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 72238117DFC; Sat, 5 Dec 2026 14:35:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.54 X-Spam-Status: No, score=-3.54 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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 BdnP4co4l88g; Sat, 5 Dec 2026 14:35:11 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377954-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id DE332117DEE; Sat, 5 Dec 2026 14:35:01 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 50BF034885; Sat, 5 Dec 2026 11:34:58 +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=1796470498; b=AvnREvkH8zvEFovXKZIUIMstPxAcYrZBa+lCLYCDsxyHNcGlYVmxu20CJ0q4BcgEU+fc CN7OEm/Pr6TNOhSm5EvLRAlOeqzojcC0eF4sNnKdwyrapY8boCyZ4+a7B9ScEl5maJMX/ Xe0GtEhfwPlifA7HYVa3swEKwj8UK3JfHhxawk0BmVzGnt31GRiKS7vfyWKrtxUGyVk3D PsYpHluePNZDWlrNf65Sl5nCNLCTa10TSL5ynH35PWHBCn6CgBHooC82nuu61iNW4WW9J bcJp+mRAUXZ3vJlxguZVkfeo6NnANZoi1bD29FmomOoY0d1x7Qw7g8Mldr9gJMifVrw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796470498; 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=sODtVeATeBh4Wh+JlgIAipzSANpo+RUs459a9xEMLrw=; b=jgV8SV3673iGX4Q89YeWFXfJdRXgk9CgB/6xxpEmCu3ZGjuksHFhSWsQ5/A567cw9irv pWUO15b+t5FMq2VnE0I82lWjj9wne5C7sQD5JJ4Lgxr5VJBYC98jFDC5Pj7Q8jB3smHqU gajnq69qL0cVusYII1AMsaa7hkjZUus9fICrIm88ocyHIsexx9ZiLc2mp3vkCKhlozZ2s vnugxEeLh6d7DjMUhmuw13GbGZ2Wt4fsXj4AQQCIjGIASsVwArwTlGTZwaLuSs7s2uHi8 6idmUSIqyUTG2B5sR0qhVWaTKM2ouznrWCuMgeTFbX6VZFJOa3p30fYZ97UpYOHrhjg== 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=gF1AzGy2; 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 29095606A335; Sat, 5 Dec 2026 11:34:58 +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=gF1AzGy2 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=1796470492; b=OlwHLo1djrenkhx4uMHuaI6p/sZYyEvdtnhS9/J43AikJsd8TEtJajqZxx1gFyOf+inQ oaPMv0K0yDWvIrTEe9g95DFv8BWBxOoj7aUmAgHmXwNeyLPcYsSf/+ju4SGy9xS1FdbwU j0ctLW31KlXqbfTuihUgNs2zwhVSg5f81aGqeuYj5iXknzzmoXFtNC34DJbY9RiqRLDeY LagN5BEFPXSRuoRJJs73hSde+q9zD+rTORqbnBddnWi/bH4QZe4uRkPlBYPBBFMz26coD FWVCAT1NGIm1dsez6WhK1kYQcI0DlCwZKFneh80Ty1r2TMiuU3Rans9Iz/SfIA0Ed3A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796470492; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=sODtVeATeBh4Wh+JlgIAipzSANpo+RUs459a9xEMLrw=; b=RpYIb1GEEOVKK43fttgVJ/GiSBzEiu4duaZ18giw/auFVjH6qGlgFKcUkMNky6FlcJvl UM2r8D5IR2gVNP4RTEQAIdu7oNYQnNHzc6TzdzxjUkQrRK52XwfVEIv43KSPEx1Z9uflF 2VJVKSZjs1fr8iZCV7ZW+C8cZfuN+6YOB+CdbmW9+ix187R2RqQO6bozVvExdUj1844/z prt/Oshp99xhQCpKog4LlzRZD1ark8NtrrMcpdWzVRrBmAjWnVFJ9oRdLVu7yKvVrriJC 0zpYceJD1KtZt5gdXRqgXkC0CMBYPQtcl/dZ0XJHCtAITl9HzZJ/MFKWrXQ/gDNj/Ag== 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=gF1AzGy2; 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 46D54606A322; Sat, 5 Dec 2026 11:34:52 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760A31F0092B; Sat, 5 Dec 2026 11:34:49 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796470492; bh=sODtVeATeBh4Wh+JlgIAipzSANpo+RUs459a9xEMLrw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gF1AzGy2H5edm2lO9EldX1YZBtjWPQ5kuRGhjBssCu6mrJy6CT1bdEo/KUuzuryXB N8XbEpZ+tqubbeJO0Da8bD+ZzDo1Bga+Nbsm30yLvMwA1Letzmh9bfJQvFXTmRPUh2 +2W43b4pimA9SQBp8GERTyija+vNEfUSeE1APvgKDf2MCCQBy+BK/RCGjPz+b86Ojc lAgEJm93SrGtLBtV+Dma4BELthqLO3DRYbm6ZN3ZtD1MSLtb6RYNyIvPmmE0bzrMs+ g5m0kRJhGkR1SUWGus75G601wCqpn6DSzTg4cyr+x7yofudVSfWb7ntIZTnSxiBsB/ cbbNMyyVDJXqg== X-Cc: Linus Torvalds <torvalds@linux-foundation.org>, Kees Cook <kees@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: <aw_Z0mTMuhQb7W2w@hobbes>