Linux filesystem development
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel.org>
To: Joel Granados <joel.granados@kernel.org>
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
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	[thread overview]
Message-ID: <axP21TKjzXZR5jth@example.org> (raw)
In-Reply-To: <aw_Z0mTMuhQb7W2w@hobbes>

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


  reply	other threads:[~2026-12-05 11:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 11:47 [PATCH RFC 0/9] sysctl: Replace ARRAY kmemdup with overlay mechanism for NS registration Joel Granados
2026-11-26 11:47 ` [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type Joel Granados
2026-11-26 17:04   ` Linus Torvalds
2026-12-02  9:36     ` Joel Granados
2026-12-05 11:34       ` Alexey Gladkov [this message]
2026-11-26 11:47 ` [PATCH RFC 2/9] sysctl: Add flags to struct ctl_table Joel Granados
2026-11-26 11:47 ` [PATCH RFC 3/9] sysctl: Add overlay mechanism for flagged ctl_table members Joel Granados
2026-11-26 11:47 ` [PATCH RFC 4/9] sysctl: Add sysctl template registration Joel Granados
2026-11-26 11:47 ` [PATCH RFC 5/9] net: sysctl: Add sysctl registration to networking Joel Granados
2026-11-26 11:47 ` [PATCH RFC 6/9] ipv4: Register ipv4_net_table as a template Joel Granados
2026-11-26 11:47 ` [PATCH RFC 7/9] ipc: Register ipc_sysctls " Joel Granados
2026-11-26 11:47 ` [PATCH RFC 8/9] ipc: Register mq_sysctls " Joel Granados
2026-11-26 11:47 ` [PATCH RFC 9/9] ucount: Register user_table " Joel Granados

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axP21TKjzXZR5jth@example.org \
    --to=legion@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=joel.granados@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=wen.yang@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox