mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wenyang.linux@foxmail.com
To: "Eric W . Biederman" <ebiederm@xmission.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Joel Granados <j.granados@samsung.com>,
	Christian Brauner <brauner@kernel.org>
Cc: Wen Yang <wenyang.linux@foxmail.com>,
	David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/9] rxrpc: delete these unnecessary static variables n_65535, four, max_500, etc
Date: Sat,  9 Mar 2024 18:31:20 +0800	[thread overview]
Message-ID: <tencent_C7DFF5F3429508354390FDA4487A15F3A506@qq.com> (raw)
In-Reply-To: <cover.1709978655.git.wenyang.linux@foxmail.com>

From: Wen Yang <wenyang.linux@foxmail.com>

Delete unnecessary static variables(n_65535, four, max_500, etc.)
and encode them directly in the table entry.

Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Joel Granados <j.granados@samsung.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Marc Dionne <marc.dionne@auristor.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-kernel@vger.kernel.org
---
 net/rxrpc/sysctl.c | 169 +++++++++++++++++++--------------------------
 1 file changed, 70 insertions(+), 99 deletions(-)

diff --git a/net/rxrpc/sysctl.c b/net/rxrpc/sysctl.c
index ecaeb4ecfb58..26ec6eff8402 100644
--- a/net/rxrpc/sysctl.c
+++ b/net/rxrpc/sysctl.c
@@ -11,15 +11,6 @@
 #include "ar-internal.h"
 
 static struct ctl_table_header *rxrpc_sysctl_reg_table;
-static const unsigned int four = 4;
-static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
-static const unsigned int n_65535 = 65535;
-static const unsigned int n_max_acks = 255;
-static const unsigned long one_jiffy = 1;
-static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
-#ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
-static const unsigned long max_500 = 500;
-#endif
 
 /*
  * RxRPC operating parameters.
@@ -29,102 +20,82 @@ static const unsigned long max_500 = 500;
  */
 static struct ctl_table rxrpc_sysctl_table[] = {
 	/* Values measured in milliseconds but used in jiffies */
-	{
-		.procname	= "soft_ack_delay",
-		.data		= &rxrpc_soft_ack_delay,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
-		.extra1		= (void *)&one_jiffy,
-		.extra2		= (void *)&max_jiffies,
-	},
-	{
-		.procname	= "idle_ack_delay",
-		.data		= &rxrpc_idle_ack_delay,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
-		.extra1		= (void *)&one_jiffy,
-		.extra2		= (void *)&max_jiffies,
-	},
-	{
-		.procname	= "idle_conn_expiry",
-		.data		= &rxrpc_conn_idle_client_expiry,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
-		.extra1		= (void *)&one_jiffy,
-		.extra2		= (void *)&max_jiffies,
-	},
-	{
-		.procname	= "idle_conn_fast_expiry",
-		.data		= &rxrpc_conn_idle_client_fast_expiry,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_ms_jiffies_minmax,
-		.extra1		= (void *)&one_jiffy,
-		.extra2		= (void *)&max_jiffies,
-	},
+	CTL_TABLE_ENTRY_MINMAX("soft_ack_delay",
+			       &rxrpc_soft_ack_delay,
+			       sizeof(unsigned long),
+			       0644,
+			       proc_doulongvec_ms_jiffies_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       MAX_JIFFY_OFFSET),
+	CTL_TABLE_ENTRY_MINMAX("idle_ack_delay",
+			       &rxrpc_idle_ack_delay,
+			       sizeof(unsigned long),
+			       0644,
+			       proc_doulongvec_ms_jiffies_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       MAX_JIFFY_OFFSET),
+	CTL_TABLE_ENTRY_MINMAX("idle_conn_expiry",
+			       &rxrpc_conn_idle_client_expiry,
+			       sizeof(unsigned long),
+			       0644,
+			       proc_doulongvec_ms_jiffies_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       MAX_JIFFY_OFFSET),
+	CTL_TABLE_ENTRY_MINMAX("idle_conn_fast_expiry",
+			       &rxrpc_conn_idle_client_fast_expiry,
+			       sizeof(unsigned long),
+			       0644,
+			       proc_doulongvec_ms_jiffies_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       MAX_JIFFY_OFFSET),
 
 	/* Values used in milliseconds */
 #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
-	{
-		.procname	= "inject_rx_delay",
-		.data		= &rxrpc_inject_rx_delay,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-		.extra1		= (void *)SYSCTL_LONG_ZERO,
-		.extra2		= (void *)&max_500,
-	},
+	CTL_TABLE_ENTRY_MINMAX("inject_rx_delay",
+			       &rxrpc_inject_rx_delay,
+			       sizeof(unsigned long),
+			       0644,
+			       proc_doulongvec_minmax,
+			       SYSCTL_NUMERIC_ZERO,
+			       SYSCTL_NUMERIC_FIVE_HUNDRED),
 #endif
 
 	/* Non-time values */
-	{
-		.procname	= "reap_client_conns",
-		.data		= &rxrpc_reap_client_connections,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= (void *)SYSCTL_ONE,
-		.extra2		= (void *)&n_65535,
-	},
-	{
-		.procname	= "max_backlog",
-		.data		= &rxrpc_max_backlog,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= (void *)&four,
-		.extra2		= (void *)&max_backlog,
-	},
-	{
-		.procname	= "rx_window_size",
-		.data		= &rxrpc_rx_window_size,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= (void *)SYSCTL_ONE,
-		.extra2		= (void *)&n_max_acks,
-	},
-	{
-		.procname	= "rx_mtu",
-		.data		= &rxrpc_rx_mtu,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= (void *)SYSCTL_ONE,
-		.extra2		= (void *)&n_65535,
-	},
-	{
-		.procname	= "rx_jumbo_max",
-		.data		= &rxrpc_rx_jumbo_max,
-		.maxlen		= sizeof(unsigned int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= (void *)SYSCTL_ONE,
-		.extra2		= (void *)&four,
-	},
+	CTL_TABLE_ENTRY_MINMAX("reap_client_conns",
+			       &rxrpc_reap_client_connections,
+			       sizeof(unsigned int),
+			       0644,
+			       proc_dointvec_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       SYSCTL_NUMERIC_U16_MAX),
+	CTL_TABLE_ENTRY_MINMAX("max_backlog",
+			       &rxrpc_max_backlog,
+			       sizeof(unsigned int),
+			       0644,
+			       proc_dointvec_minmax,
+			       SYSCTL_NUMERIC_FOUR,
+			       RXRPC_BACKLOG_MAX - 1),
+	CTL_TABLE_ENTRY_MINMAX("rx_window_size",
+			       &rxrpc_rx_window_size,
+			       sizeof(unsigned int),
+			       0644,
+			       proc_dointvec_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       SYSCTL_NUMERIC_U8_MAX),
+	CTL_TABLE_ENTRY_MINMAX("rx_mtu",
+			       &rxrpc_rx_mtu,
+			       sizeof(unsigned int),
+			       0644,
+			       proc_dointvec_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       SYSCTL_NUMERIC_U16_MAX),
+	CTL_TABLE_ENTRY_MINMAX("rx_jumbo_max",
+			       &rxrpc_rx_jumbo_max,
+			       sizeof(unsigned int),
+			       0644,
+			       proc_dointvec_minmax,
+			       SYSCTL_NUMERIC_ONE,
+			       SYSCTL_NUMERIC_FOUR),
 	{ }
 };
 
-- 
2.25.1


  parent reply	other threads:[~2024-03-09 10:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1709978655.git.wenyang.linux@foxmail.com>
2024-03-09 10:31 ` [PATCH v2 1/9] sysctl: support encoding values directly in the table entry wenyang.linux
2024-03-21 16:27   ` Joel Granados
2024-03-22 15:43     ` Wen Yang
2024-03-25  9:55       ` Joel Granados
2024-03-09 10:31 ` [PATCH v2 2/9] kernel/sysctl-test: add some kunit test cases for min/max detection wenyang.linux
2024-03-09 10:31 ` wenyang.linux [this message]
2024-03-09 10:31 ` [PATCH v2 4/9] net: ipv6: delete these unnecessary static variables two_five_five and minus_one wenyang.linux
2024-03-09 10:31 ` [PATCH v2 5/9] svcrdma: delete these unnecessary static variables min_ord, max_ord, etc wenyang.linux
2024-03-09 10:31 ` [PATCH v2 6/9] sysctl: delete these unnecessary static variables i_zero and i_one_hundred wenyang.linux
2024-03-09 10:31 ` [PATCH v2 7/9] epoll: delete these unnecessary static variables long_zero and long_max wenyang.linux
2024-03-09 10:31 ` [PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max wenyang.linux
2024-03-09 10:31 ` [PATCH v2 9/9] ucounts: delete these unnecessary static variables ue_zero and ue_int_max wenyang.linux

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=tencent_C7DFF5F3429508354390FDA4487A15F3A506@qq.com \
    --to=wenyang.linux@foxmail.com \
    --cc=brauner@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=edumazet@google.com \
    --cc=j.granados@samsung.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=mcgrof@kernel.org \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®