RFC sysctl: add CTLTBL_ENTRY_XXX() macros for ctl_table initialization
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 RFC Latest2 patches 6 repliesIn review
- v4 RFC2 patches 4 repliesSuperseded
- v3 RFC2 patches 0 repliesSuperseded
Changes in v5 from the cover letter
- Extend __CTL_AUTO_HANDLER to support bool and u8
- Replace individual test functions with a single parameterized KUnit test (KUNIT_CASE_PARAM) covering all variants and types
- Use struct ctl_table as the expected-value container in the param struct, eliminating custom expected_* fields
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | sysctl: introduce CTLTBL_ENTRY_XXX() helper macrosinclude/ kernel/ | +309 | 0 replies | |
| 2/2 | sysctl: convert kernel/sysctl-test.c to use CTLTBL_ENTRY_XXX()kernel/ | +138 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [RFC PATCH v5 0/2] sysctl: add CTLTBL_ENTRY_XXX() macros for ctl_table initialization
From: Wen Yang <[email protected]>
Historically, changes to how struct ctl_table entries are initialized (e.g. removing the child field, const-qualifying ctl_table) required touching hundreds of files across all subsystems. Such series require the attention of many maintainers, sometimes need to be pulled into mainline in a special way, and create lots of unnecessary churn. With CTLTBL_ENTRY_XXX(), future structural changes to struct ctl_table need only update the macro definitions.
Conversion of existing call sites will proceed incrementally from kernel/sysctl.c outward, rather than as a treewide sweep.
This series:
1. Introduces the CTLTBL_ENTRY_XXX() macros in include/linux/sysctl.h, using _Generic() for automatic proc_handler selection, auto address-of, auto maxlen via sizeof(), and compile-time validation. Supported types: int, unsigned int, long, unsigned long, bool, u8.
2. Converts kernel/sysctl-test.c as a demonstration, adding a parameterized KUnit test covering all macro variants (V, VM, VMR, VN, VNM, VNMH) across int, u8, bool, and char[] types.
Based on discussion and suggestions from:
[1] https://sysctl-dev-rtd.readthedocs.io/en/latest/notes/ctltable_entry_macro.html
[2] https://lore.kernel.org/all/psot4oeauxi3yyj2w4ajm3tfgtcsvao4rhv5sgd5s6ymmjgojk@p3vrj3qluban/
---
Changes in v5:
- Extend __CTL_AUTO_HANDLER to support bool and u8
- Replace individual test functions with a single parameterized KUnit test (KUNIT_CASE_PARAM) covering all variants and types
- Use struct ctl_table as the expected-value container in the param struct, eliminating custom expected_* fields
Changes in v4:
- Fix Wpointer-type-mismatch warnings detected by lkp:
https://lore.kernel.org/oe-kbuild-all/[email protected]/
Changes in v3:
- Replace the unique macro with "capital letter approach"
- Reduce the name further
https://lore.kernel.org/all/rn4rsazh7kxf5byq65vw2phyqgzvwm3scczu3l5h2r4aqit2r6@znlpb24z2zuo/
Changes in v2:
- Add lvalue check, handler type check, etc.
https://lore.kernel.org/all/xptwb3uwbzposd4xf7khj52ifv4tchcjdgllhv7aabi6d7wgef@2msurl564v53/
Wen Yang (2):
sysctl: introduce CTLTBL_ENTRY_XXX() helper macros
sysctl: convert kernel/sysctl-test.c to use CTLTBL_ENTRY_XXX()
include/linux/sysctl.h | 307 +++++++++++++++++++++++++++++++++++++++++ kernel/sysctl-test.c | 237 ++++++++++++++++++------------- kernel/sysctl.c | 2 + 3 files changed, 447 insertions(+), 99 deletions(-)
Signature · 1 line
2.25.1