mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>,
	Kees Cook <kees@kernel.org>,
	Joel Granados <joel.granados@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [RFC PATCH v1 17/30] sysctl: net: use sysctl_field in SCTP sysctls
Date: Sat, 29 Aug 2026 18:14:43 +0200	[thread overview]
Message-ID: <cover.1788018958.git.legion@kernel.org> (raw)
In-Reply-To: <CAHk-=wjUmLrJd4KM4xvJHUN4P0r8oSu5LyvG4JipnhxizBrE9Q@mail.gmail.com>

On Wed, Aug 26, 2026 at 01:29:00PM -0700, Linus Torvalds wrote:
> I detest this series.
> 
> Maybe it makes technical sense, but as long as it makes no human
> visual sense, I'm NAK'ing it as being garbage.

You are right that my approach added too many macros and made the tables
harder to read. Sorry.

> On Wed, 26 Aug 2026 at 12:43, Alexey Gladkov <legion@kernel.org> wrote:
> >
>  [..]
> 
> The whole series is full of complete illegible noise like this:
> 
> > +static const struct sysctl_field sctp_net_table[] = {
> > +       SYSCTL_FIELD_CUSTOM("rto_min", 0644, sizeof(unsigned int),
> > +                        sctp_rto_min_data, proc_sctp_do_rto_min),
> > +       SYSCTL_FIELD_CUSTOM("rto_max", 0644, sizeof(unsigned int),
> > +                        sctp_rto_max_data, proc_sctp_do_rto_max),
> > +       SYSCTL_FIELD_INT_MINMAX("pf_retrans", 0644, sctp_pf_retrans_data,
> > +                            SYSCTL_ZERO, sctp_ps_retrans_data),
> > +       SYSCTL_FIELD_INT_MINMAX("ps_retrans", 0644, sctp_ps_retrans_data,
> > +                            sctp_pf_retrans_data, sctp_ps_retrans_max_data),
> > +       SYSCTL_FIELD_STATIC_UINT_MINMAX("rto_initial", 0644,
> > +                                    sctp_rto_initial_data,
> > +                                    SYSCTL_UINT_ONE, &timer_max),
> [...]
> 
> where apparently the indentation has been decided by a rodent on crack
> who was given an Ouija board and instructed to ask his dead ancestors
> what indentation to use.
> 
> So no.
> 
> That kind of complete random code is simply not acceptable.
> 
> I don't know what the correct answer is, but it is *not* this series.
> It needs to be consistent and visually parseable by humans *without*
> asking your dead ancestors for help.
> 
> And it's not just the indentation. That SYSCTL_FIELD_CUSTOM() thing
> needs to be usable and able to do some minimal type checking - not
> just passed a random sizeof() in a random argumentt. I'd suggest
> passing the actual type, and then checking that the type *matches* the
> data pointer it is passed too.
> 
> The old code may be ugly too, and have various other warts, but at
> least it had somewhat legible and understandable initializers:
> 
>         {
>                 .procname       = "prsctp_enable",
>                 .data           = &init_net.sctp.prsctp_enable,
>                 .maxlen         = sizeof(int),
>                 .mode           = 0644,
>                 .proc_handler   = proc_dointvec,
>         },
> 
> is at least something that can be read by a human and those things had
> consistent whitespace rather than some quantum randomness.
> 
> And this is also just complete line noise that only makes the code worse:
> 
>     +#define SCTP_DATA(type, field)                                         \
>     +static type *sctp_ ## field ## _data(const struct sysctl_context *ctx) \
>     +{                                                                      \
>     +       return &ctx->ns.net_ns->sctp.field;                             \
>     +}
>     +
>     +#define SCTP_CUSTOM_DATA(field)
>              \
>     +static void *sctp_ ## field ## _data(const struct sysctl_context *ctx) \
>     +{                                                                      \
>     +       return &ctx->ns.net_ns->sctp.field;                             \
>     +}
>     +
>     +SCTP_CUSTOM_DATA(rto_min)
>     +SCTP_CUSTOM_DATA(rto_max)
>     +SCTP_DATA(int, pf_retrans)
>     +SCTP_DATA(int, ps_retrans)
>     +SCTP_DATA(unsigned int, rto_initial)
>     [...]
> 
> If we're doing these kinds of changes, the end result has to look
> *BETTER* than the thing it replaces, not worse.
> 
> Yes, a few of the patches did look better. But the majority of them
> only looked worse. Some of it should be easy to fix: use consistent
> whitespace, and use sane argument ordering.
> 
> But honestly, the old setup didn't *rely* on argument ordering, and
> used named initializers to make things more legible and robust.
> 
> So I suspect that should be what you should aim for in the new setup
> too, and that probably means "completely different approach".
> 
>                Linus
> 

I tried an alternative based on offsets. The following four patches add the
infrastructure and convert IPC, SCTP, and MPLS as examples.

The remaining macros are short wrappers around offsetof() and are only used for
compile-time type checking. If they still hurt readability, I can drop that
checking and use plain offsetof() instead.

Does this look better for you, or should I just stop?


Alexey Gladkov (4):
  sysctl: add typed field descriptors
  sysctl: ipc: use typed fields for IPC namespace sysctls
  sctp: use typed fields for per-net sysctls
  mpls: use typed fields for per-device sysctls

 fs/proc/proc_sysctl.c  | 282 ++++++++++++++++++++++++++---
 include/linux/sysctl.h | 134 +++++++++++++-
 ipc/ipc_sysctl.c       | 188 +++++++++----------
 net/mpls/af_mpls.c     |  66 ++++---
 net/sctp/sysctl.c      | 398 +++++++++++++++++++++--------------------
 5 files changed, 703 insertions(+), 365 deletions(-)

-- 
Rgrds, legion


  reply	other threads:[~2026-08-29 16:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1787771905.git.legion@kernel.org>
2026-08-26 19:42 ` [RFC PATCH v1 01/30] proc: sysctl: address table entries by index Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 02/30] sysctl: add unsigned int limit constants Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 03/30] sysctl: add typed field descriptors Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 04/30] sysctl: use sysctl_field in ucounts Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 05/30] sysctl: ipc: use sysctl_field in mq_sysctl Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 06/30] sysctl: ipc: use sysctl_field in ipc_sysctl Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 07/30] sysctl: use sysctl_field in pid sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 08/30] sysctl: net: use sysctl_field in unix sysctl Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 09/30] sysctl: net: use sysctl_field in xfrm sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 10/30] sysctl: net: use sysctl_field for simple IPv4 per-net sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 11/30] sysctl: net: use sysctl_field in IPv4 sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 12/30] sysctl: net: use sysctl_field in IPv6 xfrm sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 13/30] sysctl: net: use sysctl_field in IPv6 fragment sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 14/30] sysctl: net: use sysctl_field in 6lowpan " Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 15/30] sysctl: net: use sysctl_field in vsock sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 16/30] sysctl: net: use sysctl_field in MPTCP sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 17/30] sysctl: net: use sysctl_field in SCTP sysctls Alexey Gladkov
2026-08-26 20:29   ` Linus Torvalds
2026-08-29 16:14     ` Alexey Gladkov [this message]
2026-08-29 16:14       ` [RFC PATCH 1/4] sysctl: add typed field descriptors Alexey Gladkov
2026-08-29 16:14       ` [RFC PATCH 2/4] sysctl: ipc: use typed fields for IPC namespace sysctls Alexey Gladkov
2026-08-29 16:14       ` [RFC PATCH 3/4] sctp: use typed fields for per-net sysctls Alexey Gladkov
2026-08-29 16:14       ` [RFC PATCH 4/4] mpls: use typed fields for per-device sysctls Alexey Gladkov
2026-08-30 15:38       ` [RFC PATCH v1 17/30] sysctl: net: use sysctl_field in SCTP sysctls Linus Torvalds
2026-08-26 19:42 ` [RFC PATCH v1 18/30] sysctl: net: use sysctl_field in core IPv6 sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 19/30] sysctl: net: use sysctl_field in net core per-net sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 20/30] sysctl: net: use sysctl_field in SMC sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 21/30] sysctl: net: use sysctl_field in VRF sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 22/30] sysctl: net: use sysctl_field in RDS sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 23/30] sysctl: netfilter: use sysctl_field for per-net sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 24/30] sysctl: ipvs: " Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 25/30] sysctl: bridge: use sysctl_field for br_netfilter sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 26/30] sysctl: net: use sysctl_field for MPLS sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 27/30] sysctl: net: use sysctl_field in IPv4 devconf sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 28/30] sysctl: net: use sysctl_field in IPv6 " Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 29/30] sysctl: net: use sysctl_field in neighbour sysctls Alexey Gladkov
2026-08-26 19:42 ` [RFC PATCH v1 30/30] sysctl: parport: use sysctl_field for dynamic sysctls Alexey Gladkov

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=cover.1788018958.git.legion@kernel.org \
    --to=legion@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=joel.granados@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®