mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] fs: move and constify sysctl_nr_open_min, sysctl_nr_open_max
Date: Wed, 11 Oct 2023 21:24:21 +0300	[thread overview]
Message-ID: <02591c1e-936b-46bf-ad2b-402b33338eee@p183> (raw)

sysctl_nr_open_min, sysctl_nr_open_max variables are really hard limits
on fs.nr_open sysctl, they aren't interesting to the rest of the code
and are constants (sysctl_nr_open is not constant obviously).

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/file.c            |    5 -----
 fs/file_table.c      |   10 ++++++++--
 include/linux/file.h |    2 --
 3 files changed, 8 insertions(+), 9 deletions(-)

--- a/fs/file.c
+++ b/fs/file.c
@@ -25,11 +25,6 @@
 #include "internal.h"
 
 unsigned int sysctl_nr_open __read_mostly = 1024*1024;
-unsigned int sysctl_nr_open_min = BITS_PER_LONG;
-/* our min() is unusable in constant expressions ;-/ */
-#define __const_min(x, y) ((x) < (y) ? (x) : (y))
-unsigned int sysctl_nr_open_max =
-	__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
 
 static void __free_fdtable(struct fdtable *fdt)
 {
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -111,6 +111,12 @@ static int proc_nr_files(struct ctl_table *table, int write, void *buffer,
 	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
 }
 
+static const unsigned int sysctl_nr_open_min = BITS_PER_LONG;
+/* our min() is unusable in constant expressions ;-/ */
+#define __const_min(x, y) ((x) < (y) ? (x) : (y))
+static const unsigned int sysctl_nr_open_max =
+	__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
+
 static struct ctl_table fs_stat_sysctls[] = {
 	{
 		.procname	= "file-nr",
@@ -134,8 +140,8 @@ static struct ctl_table fs_stat_sysctls[] = {
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= &sysctl_nr_open_min,
-		.extra2		= &sysctl_nr_open_max,
+		.extra1		= (void *)&sysctl_nr_open_min,
+		.extra2		= (void *)&sysctl_nr_open_max,
 	},
 	{ }
 };
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -113,6 +113,4 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
 extern void flush_delayed_fput(void);
 extern void __fput_sync(struct file *);
 
-extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
-
 #endif /* __LINUX_FILE_H */

             reply	other threads:[~2023-10-11 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 18:24 Alexey Dobriyan [this message]
2023-10-12 13:54 ` David Laight
2023-10-14  9:22   ` Alexey Dobriyan
2023-10-15  9:16     ` David Laight
2023-10-15  9:30     ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02591c1e-936b-46bf-ad2b-402b33338eee@p183 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®