* [RESEND PATCH v2 2/9] kernel/sysctl-test: add some kunit test cases for min/max detection
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 3/9] rxrpc: delete these unnecessary static variables n_65535, four, max_500, etc wenyang.linux
` (6 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, Iurii Zaikin, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Add some kunit test cases and explicitly check the newly added min/max
initialization behavior. Including basic parsing tests, min/max overflow,
and writing data, etc
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: Iurii Zaikin <yzaikin@google.com>
Cc: linux-kernel@vger.kernel.org
---
kernel/sysctl-test.c | 300 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 300 insertions(+)
diff --git a/kernel/sysctl-test.c b/kernel/sysctl-test.c
index 6ef887c19c48..0a2b19ae2a8c 100644
--- a/kernel/sysctl-test.c
+++ b/kernel/sysctl-test.c
@@ -367,6 +367,300 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
KUNIT_EXPECT_EQ(test, 0, *((int *)table.data));
}
+/*
+ * Test that writing the int value and check if the min/max are met
+ */
+static void sysctl_test_api_dointvec_write_single_with_minmax_check(
+ struct kunit *test)
+{
+ int data = 0;
+ struct ctl_table table = CTL_TABLE_ENTRY_MINMAX("foo",
+ &data,
+ sizeof(int),
+ 0644,
+ proc_dointvec_minmax,
+ SYSCTL_NUMERIC_NEG_ONE,
+ SYSCTL_NUMERIC_ONE_HUNDRED);
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ loff_t pos = 0;
+ int i;
+
+ for (i = SYSCTL_NUMERIC_NEG_ONE; i <= SYSCTL_NUMERIC_ONE_HUNDRED; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = -10; i < SYSCTL_NUMERIC_NEG_ONE; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+
+ for (i = SYSCTL_NUMERIC_ONE_HUNDRED + 1; i < 110; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
+/*
+ * Test that writing the int value and check if the min is met
+ */
+static void sysctl_test_api_dointvec_write_single_with_min_check(
+ struct kunit *test)
+{
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ int data = 0, i;
+ loff_t pos = 0;
+ struct ctl_table table = CTL_TABLE_ENTRY_MIN("bar",
+ &data,
+ sizeof(int),
+ 0644,
+ proc_dointvec_minmax,
+ -10);
+
+ for (i = -10; i <= SYSCTL_NUMERIC_ONE_HUNDRED; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = -20; i < -10; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
+/*
+ * Test that writing the int value and check if the max is met
+ */
+static void sysctl_test_api_dointvec_write_single_with_max_check(
+ struct kunit *test)
+{
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ loff_t pos = 0;
+ int data = 0, i;
+ struct ctl_table table = CTL_TABLE_ENTRY_MAX("qux",
+ &data,
+ sizeof(int),
+ 0644,
+ proc_dointvec_minmax,
+ SYSCTL_NUMERIC_ONE_HUNDRED);
+
+ for (i = -20; i <= SYSCTL_NUMERIC_ONE_HUNDRED; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = SYSCTL_NUMERIC_ONE_HUNDRED + 1; i < SYSCTL_NUMERIC_TWO_HUNDRED; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_dointvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
+/*
+ * Test that writing the unsigned int value and check if the min/max are met
+ */
+static void sysctl_test_api_douintvec_write_single_with_minmax_check(
+ struct kunit *test)
+{
+ unsigned int data = 0;
+ struct ctl_table table1 = CTL_TABLE_ENTRY_MINMAX("foo",
+ &data,
+ sizeof(unsigned int),
+ 0644,
+ proc_douintvec_minmax,
+ SYSCTL_NUMERIC_ZERO,
+ SYSCTL_NUMERIC_ONE_THOUSAND);
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ loff_t pos = 0;
+ int i;
+
+ for (i = SYSCTL_NUMERIC_ZERO; i <= SYSCTL_NUMERIC_ONE_THOUSAND; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0, proc_douintvec_minmax(&table1, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = -10; i < 0; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL, proc_douintvec_minmax(&table1, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+
+ for (i = SYSCTL_NUMERIC_ONE_THOUSAND + 1; i < SYSCTL_NUMERIC_ONE_THOUSAND + 10; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%d", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, -EINVAL, proc_douintvec_minmax(&table1, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
+/*
+ * Test that writing the unsigned int value and check if the min is met
+ */
+static void sysctl_test_api_douintvec_write_single_with_min_check(
+ struct kunit *test)
+{
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ loff_t pos = 0;
+ unsigned int data = 0, i;
+ struct ctl_table table = CTL_TABLE_ENTRY_MIN("bar",
+ &data,
+ sizeof(unsigned int),
+ 0644,
+ proc_douintvec_minmax,
+ SYSCTL_NUMERIC_FOUR);
+
+ for (i = SYSCTL_NUMERIC_FOUR; i <= SYSCTL_NUMERIC_ONE_THOUSAND; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%u", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0,
+ proc_douintvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = SYSCTL_NUMERIC_ZERO; i < SYSCTL_NUMERIC_FOUR; i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%u", i),
+ max_len);
+ len = strlen(buffer);
+
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_douintvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
+/*
+ * Test that writing the unsigned int value and check if the max is met
+ */
+static void sysctl_test_api_douintvec_write_single_with_max_check(
+ struct kunit *test)
+{
+ size_t max_len = 32, len;
+ char *buffer = kunit_kzalloc(test, max_len, GFP_USER);
+ char __user *user_buffer = (char __user *)buffer;
+ loff_t pos = 0;
+ unsigned int data = 0, i;
+ struct ctl_table table = CTL_TABLE_ENTRY_MAX("bar",
+ &data,
+ sizeof(unsigned int),
+ 0644,
+ proc_douintvec_minmax,
+ SYSCTL_NUMERIC_TWO_THOUSAND);
+
+ for (i = SYSCTL_NUMERIC_ONE_THOUSAND; i <= SYSCTL_NUMERIC_TWO_THOUSAND;
+ i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%u", i),
+ max_len);
+ len = strlen(buffer);
+ KUNIT_EXPECT_EQ(test, 0,
+ proc_douintvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, i, data);
+ }
+
+ data = 0;
+ for (i = SYSCTL_NUMERIC_TWO_THOUSAND + 1;
+ i < SYSCTL_NUMERIC_THREE_THOUSAND;
+ i++) {
+ pos = 0;
+ KUNIT_ASSERT_LT(test,
+ (size_t)snprintf(buffer, max_len, "%u", i),
+ max_len);
+ len = strlen(buffer);
+
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ proc_douintvec_minmax(&table, KUNIT_PROC_WRITE,
+ user_buffer, &len, &pos));
+ KUNIT_EXPECT_EQ(test, 0, data);
+ }
+}
+
static struct kunit_case sysctl_test_cases[] = {
KUNIT_CASE(sysctl_test_api_dointvec_null_tbl_data),
KUNIT_CASE(sysctl_test_api_dointvec_table_maxlen_unset),
@@ -378,6 +672,12 @@ static struct kunit_case sysctl_test_cases[] = {
KUNIT_CASE(sysctl_test_dointvec_write_happy_single_negative),
KUNIT_CASE(sysctl_test_api_dointvec_write_single_less_int_min),
KUNIT_CASE(sysctl_test_api_dointvec_write_single_greater_int_max),
+ KUNIT_CASE(sysctl_test_api_dointvec_write_single_with_minmax_check),
+ KUNIT_CASE(sysctl_test_api_dointvec_write_single_with_min_check),
+ KUNIT_CASE(sysctl_test_api_dointvec_write_single_with_max_check),
+ KUNIT_CASE(sysctl_test_api_douintvec_write_single_with_minmax_check),
+ KUNIT_CASE(sysctl_test_api_douintvec_write_single_with_min_check),
+ KUNIT_CASE(sysctl_test_api_douintvec_write_single_with_max_check),
{}
};
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 3/9] rxrpc: delete these unnecessary static variables n_65535, four, max_500, etc
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
2024-03-19 15:57 ` [RESEND PATCH v2 2/9] kernel/sysctl-test: add some kunit test cases for min/max detection wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 4/9] net: ipv6: delete these unnecessary static variables two_five_five and minus_one wenyang.linux
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, David Howells, Marc Dionne,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 4/9] net: ipv6: delete these unnecessary static variables two_five_five and minus_one
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
2024-03-19 15:57 ` [RESEND PATCH v2 2/9] kernel/sysctl-test: add some kunit test cases for min/max detection wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 3/9] rxrpc: delete these unnecessary static variables n_65535, four, max_500, etc wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 5/9] svcrdma: delete these unnecessary static variables min_ord, max_ord, etc wenyang.linux
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, David S. Miller, David Ahern, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (two_five_five and minux_one)
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 S. Miller" <davem@davemloft.net>
Cc: David Ahern <dsahern@kernel.org>
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/ipv6/addrconf.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d63f5d063f07..d90f5ad3a289 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -6660,8 +6660,6 @@ static int addrconf_sysctl_disable_policy(struct ctl_table *ctl, int write,
return ret;
}
-static int minus_one = -1;
-static const int two_five_five = 255;
static u32 ioam6_if_id_max = U16_MAX;
static const struct ctl_table addrconf_sysctl[] = {
@@ -6678,8 +6676,9 @@ static const struct ctl_table addrconf_sysctl[] = {
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = (void *)SYSCTL_ONE,
- .extra2 = (void *)&two_five_five,
+ .min = SYSCTL_NUMERIC_ONE,
+ .max = SYSCTL_NUMERIC_U8_MAX,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "mtu",
@@ -6722,7 +6721,8 @@ static const struct ctl_table addrconf_sysctl[] = {
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = &minus_one,
+ .min = SYSCTL_NUMERIC_NEG_ONE,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MIN,
},
{
.procname = "router_solicitation_interval",
@@ -7061,8 +7061,9 @@ static const struct ctl_table addrconf_sysctl[] = {
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = (void *)SYSCTL_ZERO,
- .extra2 = (void *)&two_five_five,
+ .min = SYSCTL_NUMERIC_ZERO,
+ .max = SYSCTL_NUMERIC_U8_MAX,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "rpl_seg_enabled",
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 5/9] svcrdma: delete these unnecessary static variables min_ord, max_ord, etc
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
` (2 preceding siblings ...)
2024-03-19 15:57 ` [RESEND PATCH v2 4/9] net: ipv6: delete these unnecessary static variables two_five_five and minus_one wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 6/9] sysctl: delete these unnecessary static variables i_zero and i_one_hundred wenyang.linux
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, David S. Miller, David Ahern, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (min_ord, max_ord, 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 S. Miller" <davem@davemloft.net>
Cc: David Ahern <dsahern@kernel.org>
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/sunrpc/xprtrdma/svc_rdma.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
index f86970733eb0..98cde9c2bf5a 100644
--- a/net/sunrpc/xprtrdma/svc_rdma.c
+++ b/net/sunrpc/xprtrdma/svc_rdma.c
@@ -53,15 +53,9 @@
/* RPC/RDMA parameters */
unsigned int svcrdma_ord = 16; /* historical default */
-static unsigned int min_ord = 1;
-static unsigned int max_ord = 255;
unsigned int svcrdma_max_requests = RPCRDMA_MAX_REQUESTS;
unsigned int svcrdma_max_bc_requests = RPCRDMA_MAX_BC_REQUESTS;
-static unsigned int min_max_requests = 4;
-static unsigned int max_max_requests = 16384;
unsigned int svcrdma_max_req_size = RPCRDMA_DEF_INLINE_THRESH;
-static unsigned int min_max_inline = RPCRDMA_DEF_INLINE_THRESH;
-static unsigned int max_max_inline = RPCRDMA_MAX_INLINE_THRESH;
static unsigned int svcrdma_stat_unused;
static unsigned int zero;
@@ -114,8 +108,9 @@ static struct ctl_table svcrdma_parm_table[] = {
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = &min_max_requests,
- .extra2 = &max_max_requests
+ .min = SYSCTL_NUMERIC_FOUR,
+ .max = SYSCTL_NUMERIC_16K,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "max_req_size",
@@ -123,8 +118,9 @@ static struct ctl_table svcrdma_parm_table[] = {
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = &min_max_inline,
- .extra2 = &max_max_inline
+ .min = RPCRDMA_DEF_INLINE_THRESH,
+ .max = RPCRDMA_MAX_INLINE_THRESH,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "max_outbound_read_requests",
@@ -132,8 +128,9 @@ static struct ctl_table svcrdma_parm_table[] = {
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = &min_ord,
- .extra2 = &max_ord,
+ .min = SYSCTL_NUMERIC_ONE,
+ .max = SYSCTL_NUMERIC_U8_MAX,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 6/9] sysctl: delete these unnecessary static variables i_zero and i_one_hundred
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
` (3 preceding siblings ...)
2024-03-19 15:57 ` [RESEND PATCH v2 5/9] svcrdma: delete these unnecessary static variables min_ord, max_ord, etc wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 7/9] epoll: delete these unnecessary static variables long_zero and long_max wenyang.linux
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (i_zero and i_one_hundred)
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: linux-kernel@vger.kernel.org
---
lib/test_sysctl.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
index 9321d850931f..cf298f25d686 100644
--- a/lib/test_sysctl.c
+++ b/lib/test_sysctl.c
@@ -26,8 +26,6 @@
#include <linux/delay.h>
#include <linux/vmalloc.h>
-static int i_zero;
-static int i_one_hundred = 100;
static int match_int_ok = 1;
@@ -78,8 +76,9 @@ static struct ctl_table test_table[] = {
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
- .extra1 = &i_zero,
- .extra2 = &i_one_hundred,
+ .min = SYSCTL_NUMERIC_ZERO,
+ .max = SYSCTL_NUMERIC_ONE_HUNDRED,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "int_0002",
@@ -108,8 +107,9 @@ static struct ctl_table test_table[] = {
.maxlen = sizeof(test_data.boot_int),
.mode = 0644,
.proc_handler = proc_dointvec,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
+ .min = SYSCTL_NUMERIC_ZERO,
+ .max = SYSCTL_NUMERIC_ONE,
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX,
},
{
.procname = "uint_0001",
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 7/9] epoll: delete these unnecessary static variables long_zero and long_max
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
` (4 preceding siblings ...)
2024-03-19 15:57 ` [RESEND PATCH v2 6/9] sysctl: delete these unnecessary static variables i_zero and i_one_hundred wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 9/9] ucounts: delete these unnecessary static variables ue_zero and ue_int_max wenyang.linux
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, Jan Kara, Darrick J. Wong, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (long_zero and long_max)
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: Jan Kara <jack@suse.cz>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
fs/eventpoll.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 3534d36a1474..7cfc4fb0ca3c 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -309,19 +309,14 @@ static void unlist_file(struct epitems_head *head)
#include <linux/sysctl.h>
-static long long_zero;
-static long long_max = LONG_MAX;
-
static struct ctl_table epoll_table[] = {
- {
- .procname = "max_user_watches",
- .data = &max_user_watches,
- .maxlen = sizeof(max_user_watches),
- .mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
- .extra1 = &long_zero,
- .extra2 = &long_max,
- },
+ CTL_TABLE_ENTRY_MINMAX("max_user_watches",
+ &max_user_watches,
+ sizeof(max_user_watches),
+ 0644,
+ proc_doulongvec_minmax,
+ SYSCTL_NUMERIC_ZERO,
+ SYSCTL_NUMERIC_LONG_MAX),
};
static void __init epoll_sysctls_init(void)
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
` (5 preceding siblings ...)
2024-03-19 15:57 ` [RESEND PATCH v2 7/9] epoll: delete these unnecessary static variables long_zero and long_max wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
2024-03-20 10:36 ` Jan Kara
2024-03-19 15:57 ` [RESEND PATCH v2 9/9] ucounts: delete these unnecessary static variables ue_zero and ue_int_max wenyang.linux
7 siblings, 1 reply; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, Jan Kara, Darrick J. Wong, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (it_zero and it_int_max)
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: Jan Kara <jack@suse.cz>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
fs/notify/inotify/inotify_user.c | 49 +++++++++++++-------------------
1 file changed, 20 insertions(+), 29 deletions(-)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 85d8fdd55329..b346d61179ea 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -55,36 +55,27 @@ struct kmem_cache *inotify_inode_mark_cachep __ro_after_init;
#include <linux/sysctl.h>
-static long it_zero = 0;
-static long it_int_max = INT_MAX;
-
static struct ctl_table inotify_table[] = {
- {
- .procname = "max_user_instances",
- .data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES],
- .maxlen = sizeof(long),
- .mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
- .extra1 = &it_zero,
- .extra2 = &it_int_max,
- },
- {
- .procname = "max_user_watches",
- .data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES],
- .maxlen = sizeof(long),
- .mode = 0644,
- .proc_handler = proc_doulongvec_minmax,
- .extra1 = &it_zero,
- .extra2 = &it_int_max,
- },
- {
- .procname = "max_queued_events",
- .data = &inotify_max_queued_events,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO
- },
+ CTL_TABLE_ENTRY_MINMAX("max_user_instances",
+ &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES],
+ sizeof(long),
+ 0644,
+ proc_doulongvec_minmax,
+ SYSCTL_NUMERIC_ZERO,
+ SYSCTL_NUMERIC_INT_MAX),
+ CTL_TABLE_ENTRY_MINMAX("max_user_watches",
+ &init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES],
+ sizeof(long),
+ 0644,
+ proc_doulongvec_minmax,
+ SYSCTL_NUMERIC_ZERO,
+ SYSCTL_NUMERIC_INT_MAX),
+ CTL_TABLE_ENTRY_MIN("max_queued_events",
+ &inotify_max_queued_events,
+ sizeof(int),
+ 0644,
+ proc_dointvec_minmax,
+ SYSCTL_NUMERIC_ZERO),
};
static void __init inotify_sysctls_init(void)
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v2 9/9] ucounts: delete these unnecessary static variables ue_zero and ue_int_max
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
` (6 preceding siblings ...)
2024-03-19 15:57 ` [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max wenyang.linux
@ 2024-03-19 15:57 ` wenyang.linux
7 siblings, 0 replies; 14+ messages in thread
From: wenyang.linux @ 2024-03-19 15:57 UTC (permalink / raw)
To: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner
Cc: Dave Young, Wen Yang, Shuah Khan, linux-kernel
From: Wen Yang <wenyang.linux@foxmail.com>
Delete unnecessary static variables (ue_zero and ue_int_max)
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: Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
---
kernel/ucount.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/ucount.c b/kernel/ucount.c
index 4aa6166cb856..f1c7a160f361 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -58,17 +58,15 @@ static struct ctl_table_root set_root = {
.permissions = set_permissions,
};
-static long ue_zero = 0;
-static long ue_int_max = INT_MAX;
-
#define UCOUNT_ENTRY(name) \
{ \
.procname = name, \
.maxlen = sizeof(long), \
.mode = 0644, \
.proc_handler = proc_doulongvec_minmax, \
- .extra1 = &ue_zero, \
- .extra2 = &ue_int_max, \
+ .min = SYSCTL_NUMERIC_ZERO, \
+ .max = SYSCTL_NUMERIC_INT_MAX, \
+ .extra_flags = SYSCTL_TABLE_EXTRA_LONG_INIT_MINMAX \
}
static struct ctl_table user_table[] = {
UCOUNT_ENTRY("max_user_namespaces"),
--
2.25.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-19 15:57 ` [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max wenyang.linux
@ 2024-03-20 10:36 ` Jan Kara
2024-03-21 10:55 ` Joel Granados
0 siblings, 1 reply; 14+ messages in thread
From: Jan Kara @ 2024-03-20 10:36 UTC (permalink / raw)
To: wenyang.linux
Cc: Eric W . Biederman, Luis Chamberlain, Kees Cook, Joel Granados,
Christian Brauner, Dave Young, Jan Kara, Darrick J. Wong,
linux-kernel
On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
> From: Wen Yang <wenyang.linux@foxmail.com>
>
> Delete unnecessary static variables (it_zero and it_int_max)
> 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: Jan Kara <jack@suse.cz>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Cc: linux-kernel@vger.kernel.org
This looks as a sensible cleanup but I don't see the first patch in the
series (and neither it is archived at lore.kernel.org) so I cannot really
verify whether your conversion is correct...
Honza
> ---
> fs/notify/inotify/inotify_user.c | 49 +++++++++++++-------------------
> 1 file changed, 20 insertions(+), 29 deletions(-)
>
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 85d8fdd55329..b346d61179ea 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -55,36 +55,27 @@ struct kmem_cache *inotify_inode_mark_cachep __ro_after_init;
>
> #include <linux/sysctl.h>
>
> -static long it_zero = 0;
> -static long it_int_max = INT_MAX;
> -
> static struct ctl_table inotify_table[] = {
> - {
> - .procname = "max_user_instances",
> - .data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES],
> - .maxlen = sizeof(long),
> - .mode = 0644,
> - .proc_handler = proc_doulongvec_minmax,
> - .extra1 = &it_zero,
> - .extra2 = &it_int_max,
> - },
> - {
> - .procname = "max_user_watches",
> - .data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES],
> - .maxlen = sizeof(long),
> - .mode = 0644,
> - .proc_handler = proc_doulongvec_minmax,
> - .extra1 = &it_zero,
> - .extra2 = &it_int_max,
> - },
> - {
> - .procname = "max_queued_events",
> - .data = &inotify_max_queued_events,
> - .maxlen = sizeof(int),
> - .mode = 0644,
> - .proc_handler = proc_dointvec_minmax,
> - .extra1 = SYSCTL_ZERO
> - },
> + CTL_TABLE_ENTRY_MINMAX("max_user_instances",
> + &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES],
> + sizeof(long),
> + 0644,
> + proc_doulongvec_minmax,
> + SYSCTL_NUMERIC_ZERO,
> + SYSCTL_NUMERIC_INT_MAX),
> + CTL_TABLE_ENTRY_MINMAX("max_user_watches",
> + &init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES],
> + sizeof(long),
> + 0644,
> + proc_doulongvec_minmax,
> + SYSCTL_NUMERIC_ZERO,
> + SYSCTL_NUMERIC_INT_MAX),
> + CTL_TABLE_ENTRY_MIN("max_queued_events",
> + &inotify_max_queued_events,
> + sizeof(int),
> + 0644,
> + proc_dointvec_minmax,
> + SYSCTL_NUMERIC_ZERO),
> };
>
> static void __init inotify_sysctls_init(void)
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-20 10:36 ` Jan Kara
@ 2024-03-21 10:55 ` Joel Granados
2024-03-21 11:38 ` Jan Kara
0 siblings, 1 reply; 14+ messages in thread
From: Joel Granados @ 2024-03-21 10:55 UTC (permalink / raw)
To: Jan Kara
Cc: wenyang.linux, Eric W . Biederman, Luis Chamberlain, Kees Cook,
Christian Brauner, Dave Young, Darrick J. Wong, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]
On Wed, Mar 20, 2024 at 11:36:03AM +0100, Jan Kara wrote:
> On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
> > From: Wen Yang <wenyang.linux@foxmail.com>
> >
> > Delete unnecessary static variables (it_zero and it_int_max)
> > 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: Jan Kara <jack@suse.cz>
> > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > Cc: linux-kernel@vger.kernel.org
>
> This looks as a sensible cleanup but I don't see the first patch in the
> series (and neither it is archived at lore.kernel.org) so I cannot really
> verify whether your conversion is correct...
This was my original comment. If you want to see the cover letter
look for this mail ID tencent_06797E65CFC655DCD4F0414B9380E95ECC08@qq.com
Not sure why it separates the cover letter from the rest of the patches.
Best
>
> Honza
>
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-21 10:55 ` Joel Granados
@ 2024-03-21 11:38 ` Jan Kara
2024-03-21 14:41 ` Wen Yang
2024-03-21 16:37 ` Joel Granados
0 siblings, 2 replies; 14+ messages in thread
From: Jan Kara @ 2024-03-21 11:38 UTC (permalink / raw)
To: Joel Granados
Cc: Jan Kara, wenyang.linux, Eric W . Biederman, Luis Chamberlain,
Kees Cook, Christian Brauner, Dave Young, Darrick J. Wong,
linux-kernel
On Thu 21-03-24 11:55:55, Joel Granados wrote:
> On Wed, Mar 20, 2024 at 11:36:03AM +0100, Jan Kara wrote:
> > On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
> > > From: Wen Yang <wenyang.linux@foxmail.com>
> > >
> > > Delete unnecessary static variables (it_zero and it_int_max)
> > > 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: Jan Kara <jack@suse.cz>
> > > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > > Cc: linux-kernel@vger.kernel.org
> >
> > This looks as a sensible cleanup but I don't see the first patch in the
> > series (and neither it is archived at lore.kernel.org) so I cannot really
> > verify whether your conversion is correct...
> This was my original comment. If you want to see the cover letter
> look for this mail ID tencent_06797E65CFC655DCD4F0414B9380E95ECC08@qq.com
>
> Not sure why it separates the cover letter from the rest of the patches.
No, that is actually a different email :) Based on lore the message ID
should be:
26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com
but the email is not in the archive...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-21 11:38 ` Jan Kara
@ 2024-03-21 14:41 ` Wen Yang
2024-03-21 16:32 ` Joel Granados
2024-03-21 16:37 ` Joel Granados
1 sibling, 1 reply; 14+ messages in thread
From: Wen Yang @ 2024-03-21 14:41 UTC (permalink / raw)
To: Jan Kara, Joel Granados
Cc: Eric W . Biederman, Luis Chamberlain, Kees Cook,
Christian Brauner, Dave Young, Darrick J. Wong, linux-kernel
On 2024/3/21 19:38, Jan Kara wrote:
> On Thu 21-03-24 11:55:55, Joel Granados wrote:
>> On Wed, Mar 20, 2024 at 11:36:03AM +0100, Jan Kara wrote:
>>> On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
>>>> From: Wen Yang <wenyang.linux@foxmail.com>
>>>>
>>>> Delete unnecessary static variables (it_zero and it_int_max)
>>>> 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: Jan Kara <jack@suse.cz>
>>>> Cc: "Darrick J. Wong" <djwong@kernel.org>
>>>> Cc: linux-kernel@vger.kernel.org
>>>
>>> This looks as a sensible cleanup but I don't see the first patch in the
>>> series (and neither it is archived at lore.kernel.org) so I cannot really
>>> verify whether your conversion is correct...
>> This was my original comment. If you want to see the cover letter
>> look for this mail ID tencent_06797E65CFC655DCD4F0414B9380E95ECC08@qq.com
>>
>> Not sure why it separates the cover letter from the rest of the patches.
>
> No, that is actually a different email :) Based on lore the message ID
> should be:
> 26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com
>
> but the email is not in the archive...
>
> Honza
Sorry, my email box changed the message ID when sending, but it can be
found in lcore:
or
https://lore.kernel.org/all/tencent_0D6ABA209A4980742DE6003FBFE7FE2A3207@qq.com/
If it causes any inconvenience to you, I can resend it. After some
experiments, I have finally found a way to send them in a thread.
--
Best wishes,
Wen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-21 14:41 ` Wen Yang
@ 2024-03-21 16:32 ` Joel Granados
0 siblings, 0 replies; 14+ messages in thread
From: Joel Granados @ 2024-03-21 16:32 UTC (permalink / raw)
To: Wen Yang
Cc: Jan Kara, Eric W . Biederman, Luis Chamberlain, Kees Cook,
Christian Brauner, Dave Young, Darrick J. Wong, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]
On Thu, Mar 21, 2024 at 10:41:26PM +0800, Wen Yang wrote:
>
>
> On 2024/3/21 19:38, Jan Kara wrote:
> > On Thu 21-03-24 11:55:55, Joel Granados wrote:
> >> On Wed, Mar 20, 2024 at 11:36:03AM +0100, Jan Kara wrote:
> >>> On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
> >>>> From: Wen Yang <wenyang.linux@foxmail.com>
> >>>>
> >>>> Delete unnecessary static variables (it_zero and it_int_max)
> >>>> 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: Jan Kara <jack@suse.cz>
> >>>> Cc: "Darrick J. Wong" <djwong@kernel.org>
> >>>> Cc: linux-kernel@vger.kernel.org
> >>>
> >>> This looks as a sensible cleanup but I don't see the first patch in the
> >>> series (and neither it is archived at lore.kernel.org) so I cannot really
> >>> verify whether your conversion is correct...
> >> This was my original comment. If you want to see the cover letter
> >> look for this mail ID tencent_06797E65CFC655DCD4F0414B9380E95ECC08@qq.com
> >>
> >> Not sure why it separates the cover letter from the rest of the patches.
> >
> > No, that is actually a different email :) Based on lore the message ID
> > should be:
> > 26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com
> >
> > but the email is not in the archive...
> >
> > Honza
>
> Sorry, my email box changed the message ID when sending, but it can be
> found in lcore:
>
>
> or
> https://lore.kernel.org/all/tencent_0D6ABA209A4980742DE6003FBFE7FE2A3207@qq.com/
>
>
> If it causes any inconvenience to you, I can resend it. After some
> experiments, I have finally found a way to send them in a thread.
Before resending it, please read my comments to your original patchset.
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max
2024-03-21 11:38 ` Jan Kara
2024-03-21 14:41 ` Wen Yang
@ 2024-03-21 16:37 ` Joel Granados
1 sibling, 0 replies; 14+ messages in thread
From: Joel Granados @ 2024-03-21 16:37 UTC (permalink / raw)
To: Jan Kara
Cc: wenyang.linux, Eric W . Biederman, Luis Chamberlain, Kees Cook,
Christian Brauner, Dave Young, Darrick J. Wong, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]
On Thu, Mar 21, 2024 at 12:38:49PM +0100, Jan Kara wrote:
> On Thu 21-03-24 11:55:55, Joel Granados wrote:
> > On Wed, Mar 20, 2024 at 11:36:03AM +0100, Jan Kara wrote:
> > > On Tue 19-03-24 23:57:49, wenyang.linux@foxmail.com wrote:
> > > > From: Wen Yang <wenyang.linux@foxmail.com>
> > > >
> > > > Delete unnecessary static variables (it_zero and it_int_max)
> > > > 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: Jan Kara <jack@suse.cz>
> > > > Cc: "Darrick J. Wong" <djwong@kernel.org>
> > > > Cc: linux-kernel@vger.kernel.org
> > >
> > > This looks as a sensible cleanup but I don't see the first patch in the
> > > series (and neither it is archived at lore.kernel.org) so I cannot really
> > > verify whether your conversion is correct...
> > This was my original comment. If you want to see the cover letter
> > look for this mail ID tencent_06797E65CFC655DCD4F0414B9380E95ECC08@qq.com
> >
> > Not sure why it separates the cover letter from the rest of the patches.
>
> No, that is actually a different email :) Based on lore the message ID
Indeed. I have no idea where I got that ID from. I went back and found
the one I wanted: https://lore.kernel.org/all/tencent_C5E6023F97E7CC2A046AAEA09BC9ACF43907@qq.com/
that one is the original V2. This one is just a resend AFAIK.
> should be:
> 26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com
>
> but the email is not in the archive...
>
> Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-03-21 16:37 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <26c450f6467b4cbaf94cdb10f047abc6ab0c2a5d.1710863674.git.wenyang.linux@foxmail.com>
2024-03-19 15:57 ` [RESEND PATCH v2 2/9] kernel/sysctl-test: add some kunit test cases for min/max detection wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 3/9] rxrpc: delete these unnecessary static variables n_65535, four, max_500, etc wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 4/9] net: ipv6: delete these unnecessary static variables two_five_five and minus_one wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 5/9] svcrdma: delete these unnecessary static variables min_ord, max_ord, etc wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 6/9] sysctl: delete these unnecessary static variables i_zero and i_one_hundred wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 7/9] epoll: delete these unnecessary static variables long_zero and long_max wenyang.linux
2024-03-19 15:57 ` [RESEND PATCH v2 8/9] fs: inotify: delete these unnecessary static variables it_zero and it_int_max wenyang.linux
2024-03-20 10:36 ` Jan Kara
2024-03-21 10:55 ` Joel Granados
2024-03-21 11:38 ` Jan Kara
2024-03-21 14:41 ` Wen Yang
2024-03-21 16:32 ` Joel Granados
2024-03-21 16:37 ` Joel Granados
2024-03-19 15:57 ` [RESEND PATCH v2 9/9] ucounts: delete these unnecessary static variables ue_zero and ue_int_max wenyang.linux
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®