From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760A31F0092B; Sat, 5 Dec 2026 11:34:49 +0000 (UTC) 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== Date: Sat, 5 Dec 2026 12:34:45 +0100 From: Alexey Gladkov To: Joel Granados Cc: Linus Torvalds , Kees Cook , David Laight , Wen Yang , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type Message-ID: References: <20261126-lklm-sysctl-ctx-flatarray-v1-0-d7fc9cc9b03e@kernel.org> <20261126-lklm-sysctl-ctx-flatarray-v1-1-d7fc9cc9b03e@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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