The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c
@ 2026-08-07 15:47 Oleg Nesterov
  2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Oleg Nesterov @ 2026-08-07 15:47 UTC (permalink / raw)
  To: Joel Granados
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

After the removal of CONFIG_PROC_SYSCTL, several #ifdef CONFIG_SYSCTL
blocks ended up nested inside the outer (now the same) CONFIG_SYSCTL
guards.

Collapse them and remove a now-stale "/proc/sys support" comment which
referred to CONFIG_PROC_SYSCTL.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/sysctl.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f7b75985d542..d0a612c65b08 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -29,14 +29,12 @@ EXPORT_SYMBOL(sysctl_vals);
 const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
 EXPORT_SYMBOL_GPL(sysctl_long_vals);
 
-#if defined(CONFIG_SYSCTL)
+#ifdef CONFIG_SYSCTL
 
 /* Constants used for minimum and maximum */
 static const int ngroups_max = NGROUPS_MAX;
 static const int cap_last_cap = CAP_LAST_CAP;
 
-#ifdef CONFIG_SYSCTL
-
 /**
  * enum sysctl_writes_mode - supported sysctl write modes
  *
@@ -64,14 +62,6 @@ enum sysctl_writes_mode {
 };
 
 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
-#endif /* CONFIG_SYSCTL */
-#endif /* CONFIG_SYSCTL */
-
-/*
- * /proc/sys support
- */
-
-#ifdef CONFIG_SYSCTL
 
 static int _proc_do_string(char *data, int maxlen, int dir,
 		char *buffer, size_t *lenp, loff_t *ppos)
@@ -1366,7 +1356,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
 
 #endif /* CONFIG_SYSCTL */
 
-#if defined(CONFIG_SYSCTL)
+#ifdef CONFIG_SYSCTL
 int proc_do_static_key(const struct ctl_table *table, int dir,
 		       void *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -1398,7 +1388,6 @@ int proc_do_static_key(const struct ctl_table *table, int dir,
 }
 
 static const struct ctl_table sysctl_subsys_table[] = {
-#ifdef CONFIG_SYSCTL
 	{
 		.procname	= "sysctl_writes_strict",
 		.data		= &sysctl_writes_strict,
@@ -1408,7 +1397,6 @@ static const struct ctl_table sysctl_subsys_table[] = {
 		.extra1		= SYSCTL_NEG_ONE,
 		.extra2		= SYSCTL_ONE,
 	},
-#endif
 	{
 		.procname	= "ngroups_max",
 		.data		= (void *)&ngroups_max,

base-commit: 8d75c338f0bcecaa6c9af67f86c176b67b6acf3e
-- 
2.52.0



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

* [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks
  2026-08-07 15:47 [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Oleg Nesterov
@ 2026-08-07 15:48 ` Oleg Nesterov
  2026-08-07 18:01   ` Bradley Morgan
  2026-08-10 10:58   ` Joel Granados
  2026-08-07 17:16 ` [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Bradley Morgan
  2026-08-10 11:08 ` Joel Granados
  2 siblings, 2 replies; 8+ messages in thread
From: Oleg Nesterov @ 2026-08-07 15:48 UTC (permalink / raw)
  To: Joel Granados
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

Now that CONFIG_PROC_SYSCTL is gone, CONFIG_SYSCTL depends on
CONFIG_PROC_FS directly in fs/proc/Kconfig, so the double guard
defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS) is redundant.
Simplify to "#ifdef CONFIG_SYSCTL".

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 drivers/parport/procfs.c | 8 ++++----
 fs/dcache.c              | 2 +-
 fs/file_table.c          | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 3880460e67f2..68a24e17a68f 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -26,9 +26,9 @@
 
 #include <linux/uaccess.h>
 
-#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
+#ifdef CONFIG_SYSCTL
 
-#define PARPORT_MIN_TIMESLICE_VALUE 1ul 
+#define PARPORT_MIN_TIMESLICE_VALUE 1ul
 #define PARPORT_MAX_TIMESLICE_VALUE ((unsigned long) HZ)
 #define PARPORT_MIN_SPINTIME_VALUE 1
 #define PARPORT_MAX_SPINTIME_VALUE 1000
@@ -560,7 +560,7 @@ static void __exit parport_default_proc_unregister(void)
 	parport_bus_exit();
 }
 
-#else /* no sysctl or no procfs*/
+#else /* CONFIG_SYSCTL */
 
 int parport_proc_register(struct parport *pp)
 {
@@ -591,7 +591,7 @@ static void __exit parport_default_proc_unregister (void)
 {
 	parport_bus_exit();
 }
-#endif
+#endif /* CONFIG_SYSCTL */
 
 subsys_initcall(parport_default_proc_register)
 module_exit(parport_default_proc_unregister)
diff --git a/fs/dcache.c b/fs/dcache.c
index 3e9af9de7074..cb8a6b04a17a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -144,7 +144,7 @@ static DEFINE_PER_CPU(long, nr_dentry_unused);
 static DEFINE_PER_CPU(long, nr_dentry_negative);
 static int dentry_negative_policy;
 
-#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
+#ifdef CONFIG_SYSCTL
 /* Statistics gathering. */
 static struct dentry_stat_t dentry_stat = {
 	.age_limit = 45,
diff --git a/fs/file_table.c b/fs/file_table.c
index c68b8c0a4097..08ca3631b726 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -122,7 +122,7 @@ unsigned long get_max_files(void)
 }
 EXPORT_SYMBOL_GPL(get_max_files);
 
-#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
+#ifdef CONFIG_SYSCTL
 
 /*
  * Handle nr_files sysctl
-- 
2.52.0



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

* Re: [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c
  2026-08-07 15:47 [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Oleg Nesterov
  2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
@ 2026-08-07 17:16 ` Bradley Morgan
  2026-08-10 11:08 ` Joel Granados
  2 siblings, 0 replies; 8+ messages in thread
From: Bradley Morgan @ 2026-08-07 17:16 UTC (permalink / raw)
  To: oleg
  Cc: brauner, broonie, jack, joel.granados, kees, linux-kernel, mcgrof,
	sudipm.mukherjee, viro

Hi Oleg, thanks for the patch.

Reviewed-by: Bradley Morgan <include@grrlz.net>

Thanks!

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

* Re: [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks
  2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
@ 2026-08-07 18:01   ` Bradley Morgan
  2026-08-10 10:58   ` Joel Granados
  1 sibling, 0 replies; 8+ messages in thread
From: Bradley Morgan @ 2026-08-07 18:01 UTC (permalink / raw)
  To: oleg
  Cc: brauner, broonie, jack, joel.granados, kees, linux-kernel, mcgrof,
	sudipm.mukherjee, viro

Hi, this is correct to me! :)

Reviewed-by: Bradley Morgan <include@grrlz.net>

Thanks!

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

* Re: [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks
  2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
  2026-08-07 18:01   ` Bradley Morgan
@ 2026-08-10 10:58   ` Joel Granados
  2026-08-10 12:07     ` Oleg Nesterov
  1 sibling, 1 reply; 8+ messages in thread
From: Joel Granados @ 2026-08-10 10:58 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2548 bytes --]

On Fri, Aug 07, 2026 at 05:48:11PM +0200, Oleg Nesterov wrote:
> Now that CONFIG_PROC_SYSCTL is gone, CONFIG_SYSCTL depends on
> CONFIG_PROC_FS directly in fs/proc/Kconfig, so the double guard
> defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS) is redundant.
> Simplify to "#ifdef CONFIG_SYSCTL".
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
>  drivers/parport/procfs.c | 8 ++++----
>  fs/dcache.c              | 2 +-
>  fs/file_table.c          | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
> index 3880460e67f2..68a24e17a68f 100644
> --- a/drivers/parport/procfs.c
> +++ b/drivers/parport/procfs.c
> @@ -26,9 +26,9 @@
>  
>  #include <linux/uaccess.h>
>  
> -#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
> +#ifdef CONFIG_SYSCTL
>  
> -#define PARPORT_MIN_TIMESLICE_VALUE 1ul 
> +#define PARPORT_MIN_TIMESLICE_VALUE 1ul
Nit: Please remove the formatting changes from the series.

>  #define PARPORT_MAX_TIMESLICE_VALUE ((unsigned long) HZ)
>  #define PARPORT_MIN_SPINTIME_VALUE 1
>  #define PARPORT_MAX_SPINTIME_VALUE 1000
> @@ -560,7 +560,7 @@ static void __exit parport_default_proc_unregister(void)
>  	parport_bus_exit();
>  }
>  
> -#else /* no sysctl or no procfs*/
> +#else /* CONFIG_SYSCTL */
>  
>  int parport_proc_register(struct parport *pp)
>  {
> @@ -591,7 +591,7 @@ static void __exit parport_default_proc_unregister (void)
>  {
>  	parport_bus_exit();
>  }
> -#endif
> +#endif /* CONFIG_SYSCTL */
>  
>  subsys_initcall(parport_default_proc_register)
>  module_exit(parport_default_proc_unregister)
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 3e9af9de7074..cb8a6b04a17a 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -144,7 +144,7 @@ static DEFINE_PER_CPU(long, nr_dentry_unused);
>  static DEFINE_PER_CPU(long, nr_dentry_negative);
>  static int dentry_negative_policy;
>  
> -#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
> +#ifdef CONFIG_SYSCTL
>  /* Statistics gathering. */
>  static struct dentry_stat_t dentry_stat = {
>  	.age_limit = 45,
> diff --git a/fs/file_table.c b/fs/file_table.c
> index c68b8c0a4097..08ca3631b726 100644
> --- a/fs/file_table.c
> +++ b/fs/file_table.c
> @@ -122,7 +122,7 @@ unsigned long get_max_files(void)
>  }
>  EXPORT_SYMBOL_GPL(get_max_files);
>  
> -#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
> +#ifdef CONFIG_SYSCTL
>  
>  /*
>   * Handle nr_files sysctl
> -- 
> 2.52.0
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c
  2026-08-07 15:47 [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Oleg Nesterov
  2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
  2026-08-07 17:16 ` [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Bradley Morgan
@ 2026-08-10 11:08 ` Joel Granados
  2026-08-10 12:24   ` Oleg Nesterov
  2 siblings, 1 reply; 8+ messages in thread
From: Joel Granados @ 2026-08-10 11:08 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3111 bytes --]

On Fri, Aug 07, 2026 at 05:47:44PM +0200, Oleg Nesterov wrote:
> After the removal of CONFIG_PROC_SYSCTL, several #ifdef CONFIG_SYSCTL
> blocks ended up nested inside the outer (now the same) CONFIG_SYSCTL
> guards.
> 
> Collapse them and remove a now-stale "/proc/sys support" comment which
> referred to CONFIG_PROC_SYSCTL.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
>  kernel/sysctl.c | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index f7b75985d542..d0a612c65b08 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -29,14 +29,12 @@ EXPORT_SYMBOL(sysctl_vals);
>  const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
>  EXPORT_SYMBOL_GPL(sysctl_long_vals);
>  
> -#if defined(CONFIG_SYSCTL)
> +#ifdef CONFIG_SYSCTL
>  
>  /* Constants used for minimum and maximum */
>  static const int ngroups_max = NGROUPS_MAX;
>  static const int cap_last_cap = CAP_LAST_CAP;
>  
> -#ifdef CONFIG_SYSCTL
> -
>  /**
>   * enum sysctl_writes_mode - supported sysctl write modes
>   *
> @@ -64,14 +62,6 @@ enum sysctl_writes_mode {
>  };
>  
>  static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
> -#endif /* CONFIG_SYSCTL */
> -#endif /* CONFIG_SYSCTL */
> -
> -/*
> - * /proc/sys support
> - */
> -
> -#ifdef CONFIG_SYSCTL
>  
>  static int _proc_do_string(char *data, int maxlen, int dir,
>  		char *buffer, size_t *lenp, loff_t *ppos)
> @@ -1366,7 +1356,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
>  
>  #endif /* CONFIG_SYSCTL */
>  
> -#if defined(CONFIG_SYSCTL)
> +#ifdef CONFIG_SYSCTL
>  int proc_do_static_key(const struct ctl_table *table, int dir,
>  		       void *buffer, size_t *lenp, loff_t *ppos)
>  {
> @@ -1398,7 +1388,6 @@ int proc_do_static_key(const struct ctl_table *table, int dir,
>  }
>  
>  static const struct ctl_table sysctl_subsys_table[] = {
> -#ifdef CONFIG_SYSCTL
>  	{
>  		.procname	= "sysctl_writes_strict",
>  		.data		= &sysctl_writes_strict,
> @@ -1408,7 +1397,6 @@ static const struct ctl_table sysctl_subsys_table[] = {
>  		.extra1		= SYSCTL_NEG_ONE,
>  		.extra2		= SYSCTL_ONE,
>  	},
> -#endif
>  	{
>  		.procname	= "ngroups_max",
>  		.data		= (void *)&ngroups_max,
> 
> base-commit: 8d75c338f0bcecaa6c9af67f86c176b67b6acf3e
> -- 
> 2.52.0
> 
> 

This looks very nice, but now that you are there, I would propose an
additional change:

1. I would move the proc_do_static_key function and the definition of
   the sysctl_subsys_table into the first CONFIG_SYSCTL definition
   section; right after proc_do_large_bitmap

2. Doing one means that there is only one #ifdef CONFIG_SYSCTL

3. Add a proc_do_static_key stub to the #else section; something like
   this:

  int proc_do_static_key(const struct ctl_table *table, int dir,
                         void *buffer, size_t *lenp, loff_t *ppos)
  {
    return -ENOSYS;
  }


I'll wont add these for this release; will queue them for the next one.

Best

Joel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks
  2026-08-10 10:58   ` Joel Granados
@ 2026-08-10 12:07     ` Oleg Nesterov
  0 siblings, 0 replies; 8+ messages in thread
From: Oleg Nesterov @ 2026-08-10 12:07 UTC (permalink / raw)
  To: Joel Granados
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

Hi Joel,

On 08/10, Joel Granados wrote:
>
> On Fri, Aug 07, 2026 at 05:48:11PM +0200, Oleg Nesterov wrote:
> > --- a/drivers/parport/procfs.c
> > +++ b/drivers/parport/procfs.c
> > @@ -26,9 +26,9 @@
> >
> >  #include <linux/uaccess.h>
> >
> > -#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
> > +#ifdef CONFIG_SYSCTL
> >
> > -#define PARPORT_MIN_TIMESLICE_VALUE 1ul
> > +#define PARPORT_MIN_TIMESLICE_VALUE 1ul
>
> Nit: Please remove the formatting changes from the series.

Hmm. I replaced "#if defined(CONFIG_SYSCTL)" with "#ifdef CONFIG_SYSCTL"
because the latter matches the rest of this file which uses "#ifdef", not
"#if defined(...)" elsewhere...

Plus I removed the extra whitespace after eol in the next line.

What exactly you want me to revert in this cleanup?

In any case, I'd be happy to send V2. But I am travelling without
my work laptop, I can only do this when I return on Aug 19.

Thanks!

Oleg.


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

* Re: [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c
  2026-08-10 11:08 ` Joel Granados
@ 2026-08-10 12:24   ` Oleg Nesterov
  0 siblings, 0 replies; 8+ messages in thread
From: Oleg Nesterov @ 2026-08-10 12:24 UTC (permalink / raw)
  To: Joel Granados
  Cc: Mark Brown, Luis Chamberlain, Sudip Mukherjee, Alexander Viro,
	Christian Brauner, Jan Kara, Kees Cook, linux-kernel

On 08/10, Joel Granados wrote:
>
> This looks very nice, but now that you are there, I would propose an
> additional change:
>
> 1. I would move the proc_do_static_key function and the definition of
>    the sysctl_subsys_table into the first CONFIG_SYSCTL definition
>    section; right after proc_do_large_bitmap
>
> 2. Doing one means that there is only one #ifdef CONFIG_SYSCTL
>
> 3. Add a proc_do_static_key stub to the #else section; something like
>    this:
>
>   int proc_do_static_key(const struct ctl_table *table, int dir,
>                          void *buffer, size_t *lenp, loff_t *ppos)
>   {
>     return -ENOSYS;
>   }

Yeees, and I thought about this too ;) Just I decided to send the
minimal and trivial cleanup. Except right now I am not 100% sure
about 3. because I can't read the source code now...

Again, I'd be happy to send V2, but only after I return from PTO on
Aug 19.

But let me ask... Do you want me to incorporate this additional change
into 1/2 or send it as a separate change? I'd prefer the latter, but
I am fine either way.

Oleg.


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

end of thread, other threads:[~2026-08-10 12:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 15:47 [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Oleg Nesterov
2026-08-07 15:48 ` [PATCH sysctl-next 2/2] sysctl: remove redundant CONFIG_PROC_FS checks Oleg Nesterov
2026-08-07 18:01   ` Bradley Morgan
2026-08-10 10:58   ` Joel Granados
2026-08-10 12:07     ` Oleg Nesterov
2026-08-07 17:16 ` [PATCH sysctl-next 1/2] sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c Bradley Morgan
2026-08-10 11:08 ` Joel Granados
2026-08-10 12:24   ` Oleg Nesterov

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