mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/9] sysctl: Consolidate do_proc_* functions into one macro
@ 2025-12-19 12:15 Joel Granados
  2025-12-19 12:15 ` [PATCH 1/9] sysctl: Move default converter assignment out of do_proc_dointvec Joel Granados
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Joel Granados @ 2025-12-19 12:15 UTC (permalink / raw)
  To: Kees Cook, Alexander Viro, Christian Brauner, Jan Kara
  Cc: linux-kernel, linux-fsdevel, Joel Granados

What
====
Generate do_proc_{int,uint,ulong} with the new do_proc_typevec macro.
Removed small differences between each implementation and put it all
under one roof. This macro is meant for internal (to sysctl.c) static
functions; it should not be used from the outside.

Groups and document the proc handler and converter functions in
include/linux/sysctl.h. Document how to create custom converters
with examples for every converter type.

This series sits on top of [1], you can see the working branch here [2].

Why
===
Working with one instead of three slightly different implementations of
the same thing makes more sense to me for three reasons: 1. I don't have
to think about the different types separately (less context switches) and
2. One place to begin debugging proc_handler issues and 3. A fix for
one type, fixes all types.

A word on macros
================
I have mixed feelings about the use of macros here, especially because
it is such a long function. But I see it as the first step. Having this
in mainline will validate that the three types **indeed** have the same
logic (I have tested extensively, but linux-next & mainline are the
ultimate tests). Once this is established in mainline, implementing an
alternative way of parametrizing becomes easier.

A word on checkpatch
====================
* It does not like that ENOSYS is returned for the no-op functions. I'm
  just following the pattern that was initially there. Does -EINVAL
  makes more sense?
* It has a false positive on a spacing around a pointer.

Testing
=======
Ran sysctl selftest/kunit on x86_64 and 0-day.

Comments are greatly appreciated

[1] https://lore.kernel.org/20251217-jag-no-macro-conv-v1-0-6e4252687915@kernel.org
[2] https://git.kernel.org/pub/scm/linux/kernel/git/joel.granados/linux.git/log/?h=jag/dovec_consolidate

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
Joel Granados (9):
      sysctl: Move default converter assignment out of do_proc_dointvec
      sysctl: Replace do_proc_dointvec with a type-generic macro
      sysctl: Generate do_proc_doulongvec_minmax with do_proc_dotypevec macro
      sysctl: Add negp parameter to douintvec converter functions
      sysctl: Generate do_proc_douintvec with a type-generic macro
      sysctl: Rename do_proc_dotypevec macro to do_proc_typevec
      sysctl: Group proc_handler declarations and document
      sysctl: Rename proc_doulongvec_minmax_conv to proc_doulongvec_conv
      sysctl: Update API function documentation

 fs/pipe.c              |   2 +-
 include/linux/sysctl.h | 123 +++++++----
 kernel/sysctl.c        | 539 +++++++++++++++++++++++--------------------------
 kernel/time/jiffies.c  |  28 ++-
 4 files changed, 371 insertions(+), 321 deletions(-)
---
base-commit: 0616c77e5d877006efe3bea27ca195d396de08dc
change-id: 20251218-jag-dovec_consolidate-5a704f2a3f9b

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-01-01 12:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-19 12:15 [PATCH 0/9] sysctl: Consolidate do_proc_* functions into one macro Joel Granados
2025-12-19 12:15 ` [PATCH 1/9] sysctl: Move default converter assignment out of do_proc_dointvec Joel Granados
2025-12-19 12:15 ` [PATCH 2/9] sysctl: Replace do_proc_dointvec with a type-generic macro Joel Granados
2025-12-19 12:15 ` [PATCH 3/9] sysctl: Generate do_proc_doulongvec_minmax with do_proc_dotypevec macro Joel Granados
2025-12-29  7:17   ` kernel test robot
2026-01-01 12:56     ` Joel Granados
2025-12-19 12:15 ` [PATCH 4/9] sysctl: Add negp parameter to douintvec converter functions Joel Granados
2025-12-19 12:15 ` [PATCH 5/9] sysctl: Generate do_proc_douintvec with a type-generic macro Joel Granados
2025-12-19 12:15 ` [PATCH 6/9] sysctl: Rename do_proc_dotypevec macro to do_proc_typevec Joel Granados
2025-12-19 12:15 ` [PATCH 7/9] sysctl: Group proc_handler declarations and document Joel Granados
2025-12-19 12:15 ` [PATCH 8/9] sysctl: Rename proc_doulongvec_minmax_conv to proc_doulongvec_conv Joel Granados
2025-12-19 12:16 ` [PATCH 9/9] sysctl: Update API function documentation Joel Granados

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome