Re: [RFC PATCH v2 0/6] sysctl: replace overloaded extra pointers with typed bounds and core stride

From: Wen Yang

Date: Wed Nov 25 2026 - 12:37:34 EST




On 11/24/26 21:26, Joel Granados wrote:
On Tue, Nov 17, 2026 at 12:07:32AM +0800, wen.yang@xxxxxxxxx wrote:
From: Wen Yang <wen.yang@xxxxxxxxx>
Thx for taking the time to put this out. This gives perspective and adds
to the discussion of how best to move forward with "struct ctl_table".


struct ctl_table has long relied on extra1 and extra2 pointers to serve
multiple unrelated duties, including range limits and caller-specific
context. This series addresses both:

1. Replace bound pointers with plain unsigned long min and max fields
directly in struct ctl_table.

2. Replace per-entry context pointers with a core stride mechanism,
allowing callers to register arrays of structures embedding struct
ctl_table and recover enclosing context via standard container_of().
I think having these two at the same time is not the way to go. We need
to figure out where to put the non-bound context pointers first. And
after that is settled, we address the bound pointers.

Yes, we are doing the first to get to the later, but mixing them just
adds to the confusion. One thing at a time!


This RFC focuses on the core stride infrastructure and two representative
complex users (netfilter nf_log and IPv4 devinet), as suggested by Joel
Granados. The remaining treewide callers are converted in a single
My suggestion was **not** for this implementation specifically. I
suggested you create an RFC to clearly understand your idea. Apologies
if that was not clear.

squashed commit to ensure the tree builds and tests pass cleanly.

Changes from v1:
=================
v1: https://lore.kernel.org/all/cover.1793204511.git.wen.yang@xxxxxxxxx/

1. Abandoned per-entry 'void *priv' (David Laight):
Though not adding yet another entry in ctl_table is commendable, I
prefer adding a priv entry over the stride mechanism in this series.
Here are my thoughts:

1. The type should set the stride in sysctl core. The situation where
the stride of a type might be different from its size should be avoided.
In these cases I would prefer a whole new type.

2. Having ctl_table as the grounding entry inside another struct and, at
the same time, it be a regular (non-grounding) entry is asking for
trouble.
- A proc_handler assumes there is a containing entry around only to
realize that it was passed just a pointer.
- The core might start overlaying clt_table entries to deal with
namespaces [1], [2], [3]

- v1 added 'priv' to struct ctl_table, incurring 8 bytes on 64-bit and
4 bytes on 32-bit for all ~1,000 entries across thousands of dynamic
instances, even though <7% of entries need context.
Just a quick comment here: If you want to get rid of 8/4 bytes with the
ctl_table struct, you might want to look at struct ctl_table_poll, which
(to my knowledge) is only used in one ctl_table array. Finding a way to
service utsname while at the same time removing that entry is much more
of a low hanging fruit IMO.


Hi Joel,

Thanks for the detailed feedback and the namespace overlay pointers.

Our main motivation for prototyping the stride approach (and the v3 we
have been testing) was to avoid growing struct ctl_table while still
eliminating the per-entry wrapper functions. However, the upcoming
namespace table overlay work is a compelling reason to keep ctl_table
arrays homogeneous and self-contained.

Following your advice, we will set the stride series aside and split the
work into focused steps:

1, first, prepare a small, standalone series (based on the lastest -rc)
focused on migrating the non-bound context callers of extra1/extar2
to a dedicated void *priv, field in struct ctl_table, without
touching any min/max bounds yet.

2, Once the context pointer migration is settled, follow up with the
typed min/max bound conversion as a separate series.

Regarding struct ctl_table_poll in utsname: is someone already working
on removing it from struct ctl_table, or would you like us to look into
that as a separate cleanup as well?

We expect to have the context-pointer series ready in about 1 week.
Please let me know if you have any preferences or suggestions on this plan.

Thanks,
Wen