From: Luis Chamberlain <mcgrof@kernel.org>
To: akpm@linux-foundation.org, keescook@chromium.org,
yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com,
steve@sk2.org, gregkh@linuxfoundation.org, rafael@kernel.org,
tytso@mit.edu, viro@zeniv.linux.org.uk, pmladek@suse.com,
senozhatsky@chromium.org, rostedt@goodmis.org,
john.ogness@linutronix.de, dgilbert@interlog.com,
jejb@linux.ibm.com, martin.petersen@oracle.com,
mcgrof@bombadil.infradead.org, mcgrof@kernel.org,
linux-scsi@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 8/8] sysctl: share unsigned long const values
Date: Wed, 24 Nov 2021 15:14:35 -0800 [thread overview]
Message-ID: <20211124231435.1445213-9-mcgrof@kernel.org> (raw)
In-Reply-To: <20211124231435.1445213-1-mcgrof@kernel.org>
Provide a way to share unsigned long values.
This will allow others to not have to re-invent
these values.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
fs/proc/proc_sysctl.c | 3 +++
include/linux/sysctl.h | 6 ++++++
kernel/sysctl.c | 9 +++------
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index aa743bbb8400..2b73648a19a5 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -29,6 +29,9 @@ static const struct inode_operations proc_sys_dir_operations;
const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, INT_MAX };
EXPORT_SYMBOL(sysctl_vals);
+const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
+EXPORT_SYMBOL_GPL(sysctl_long_vals);
+
/* Support for permanently empty directories */
struct ctl_table sysctl_mount_point[] = {
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 7946b532e964..162aaee92daf 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -50,6 +50,12 @@ struct ctl_dir;
extern const int sysctl_vals[];
+#define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0])
+#define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1])
+#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2])
+
+extern const unsigned long sysctl_long_vals[];
+
typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
size_t *lenp, loff_t *ppos);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 5812d76ecee1..b8a3dcf7b925 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -99,9 +99,6 @@
/* Constants used for minimum and maximum */
-static const unsigned long zero_ul;
-static const unsigned long one_ul = 1;
-static const unsigned long long_max = LONG_MAX;
#ifdef CONFIG_PRINTK
static const int ten_thousand = 10000;
#endif
@@ -2512,7 +2509,7 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(dirty_background_bytes),
.mode = 0644,
.proc_handler = dirty_background_bytes_handler,
- .extra1 = (void *)&one_ul,
+ .extra1 = SYSCTL_LONG_ONE,
},
{
.procname = "dirty_ratio",
@@ -2930,8 +2927,8 @@ static struct ctl_table fs_table[] = {
.maxlen = sizeof(files_stat.max_files),
.mode = 0644,
.proc_handler = proc_doulongvec_minmax,
- .extra1 = (void *)&zero_ul,
- .extra2 = (void *)&long_max,
+ .extra1 = SYSCTL_LONG_ZERO,
+ .extra2 = SYSCTL_LONG_MAX,
},
{
.procname = "nr_open",
--
2.33.0
prev parent reply other threads:[~2021-11-24 23:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 23:14 [PATCH v2 0/8] sysctl: 3rd set of kernel/sysctl cleanups Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 1/8] firmware_loader: move firmware sysctl to its own files Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 2/8] random: move the random sysctl declarations to its own file Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 3/8] sysctl: add helper to register a sysctl mount point Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 4/8] fs: move binfmt_misc sysctl to its own file Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 5/8] printk: move printk sysctl to printk/sysctl.c Luis Chamberlain
2021-11-26 12:51 ` Petr Mladek
2021-11-29 20:48 ` Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 6/8] scsi/sg: move sg-big-buff sysctl to scsi/sg.c Luis Chamberlain
2021-11-24 23:14 ` [PATCH v2 7/8] stackleak: move stack_erasing sysctl to stackleak.c Luis Chamberlain
2021-11-24 23:14 ` Luis Chamberlain [this message]
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=20211124231435.1445213-9-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dgilbert@interlog.com \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=jejb@linux.ibm.com \
--cc=john.ogness@linutronix.de \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mcgrof@bombadil.infradead.org \
--cc=nixiaoming@huawei.com \
--cc=pmladek@suse.com \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=steve@sk2.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=yzaikin@google.com \
/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;
as well as URLs for NNTP newsgroup(s).