sysctl: add typed field descriptors - #2653
Open
vfsci-bot[bot] wants to merge 6 commits into
Open
vfsci-bot[bot] wants to merge 6 commits into
vfsci-bot[bot] wants to merge 6 commits into
Conversation
proc_sysctl keeps pointers to ctl_table entries in several lookup and inode paths. That makes it hard to support alternative descriptor formats because the tree logic assumes that every registered entry already is a ctl_table object. Store the entry index in proc inodes and pass header/index pairs through the lookup, iteration and permission paths instead. The existing ctl_table entries are still used for all handler, permission and poll operations, but the core no longer needs to carry a direct ctl_table pointer through every internal path. Signed-off-by: Alexey Gladkov <legion@kernel.org>
Some sysctl handlers use unsigned int storage for their limit arguments. In particular, proc_dou8vec_minmax() expects extra1 and extra2 to point to unsigned int values even though the controlled data is an u8. Provide shared unsigned int constants so typed sysctl descriptors can pass correctly typed min and max pointers without casting the existing int constants. Signed-off-by: Alexey Gladkov <legion@kernel.org>
Several sysctl users duplicate ctl_table arrays at registration time so data and limit pointers can be redirected to namespace or device state. The copies consume memory for every instance and their index-based fixups silently depend on the source table order. Add sysctl_field as an alternative static descriptor. A field records the value kind and a checked offset into an object selected by a registration context. Type-specific offset helpers verify the backing member type at build time, while the core derives the legacy proc handler, size and limit pointers from the field kind. Keep ctl_table as the interface used by proc handlers, permissions and BPF by materializing one entry on the stack when those paths need it. Existing ctl_table registrations are unchanged, and converted users can share one read-only descriptor array without allocating a table copy. Signed-off-by: Alexey Gladkov <legion@kernel.org>
IPC sysctl registration clones the table and rewrites data and limit pointers for each namespace. This allocates a full ctl_table array per namespace and ties the fixup loop to the table layout. Describe the table with sysctl_field offsets into ipc_namespace instead. Keep the auto_msgmni entry data-less because its handler selects the effective value itself. This removes the per-namespace table allocation while preserving the existing handlers and limits. Signed-off-by: Alexey Gladkov <legion@kernel.org>
Convert mq_sysctls. The table can now share one static array across ipc namespaces instead of allocating and rewriting a ctl_table copy for each registration. Signed-off-by: Alexey Gladkov <legion@kernel.org>
User namespace sysctl registration clones the entire ctl_table and assigns ucount_max entries by table index. This allocates a table for every user namespace and makes the data mapping depend on the descriptor order. Use typed field offsets to associate each entry explicitly with its ucount_max element. The static descriptor array can then be shared by all user namespaces without allocating or rewriting a ctl_table copy. Signed-off-by: Alexey Gladkov <legion@kernel.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Series: https://patchwork.kernel.org/project/linux-fsdevel/list/?series=1170284
Submitter: Alexey Gladkov
Version: 2
Patches: 6/6
Message-ID:
<cover.1789987960.git.legion@kernel.org>Base: vfs.base.ci
Lore: https://lore.kernel.org/linux-fsdevel/cover.1789987960.git.legion@kernel.org
Automated by ml2pr