Skip to content

Commit dc55342

Browse files
committed
Merge tag 'sysctl-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
Pull sysctl updates from Luis Chamberlain: "Just some boring cleanups on the sysctl front for this release" * tag 'sysctl-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: kernel/sysctl-test: use SYSCTL_{ZERO/ONE_HUNDRED} instead of i_{zero/one_hundred} kernel/sysctl.c: move sysctl_vals and sysctl_long_vals to sysctl.c sysctl: remove max_extfrag_threshold kernel/sysctl.c: remove unnecessary (void*) conversions proc: remove initialization assignment
2 parents 47cc75a + c06a17f commit dc55342

File tree

3 files changed

+33
-41
lines changed

3 files changed

+33
-41
lines changed

fs/proc/proc_sysctl.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ static const struct inode_operations proc_sys_inode_operations;
2828
static const struct file_operations proc_sys_dir_file_operations;
2929
static const struct inode_operations proc_sys_dir_operations;
3030

31-
/* shared constants to be used in various sysctls */
32-
const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
33-
EXPORT_SYMBOL(sysctl_vals);
34-
35-
const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
36-
EXPORT_SYMBOL_GPL(sysctl_long_vals);
37-
3831
/* Support for permanently empty directories */
3932

4033
struct ctl_table sysctl_mount_point[] = {
@@ -1246,7 +1239,7 @@ static bool get_links(struct ctl_dir *dir,
12461239
static int insert_links(struct ctl_table_header *head)
12471240
{
12481241
struct ctl_table_set *root_set = &sysctl_table_root.default_set;
1249-
struct ctl_dir *core_parent = NULL;
1242+
struct ctl_dir *core_parent;
12501243
struct ctl_table_header *links;
12511244
int err;
12521245

kernel/sysctl-test.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#define KUNIT_PROC_READ 0
1010
#define KUNIT_PROC_WRITE 1
1111

12-
static int i_zero;
13-
static int i_one_hundred = 100;
14-
1512
/*
1613
* Test that proc_dointvec will not try to use a NULL .data field even when the
1714
* length is non-zero.
@@ -29,8 +26,8 @@ static void sysctl_test_api_dointvec_null_tbl_data(struct kunit *test)
2926
.maxlen = sizeof(int),
3027
.mode = 0644,
3128
.proc_handler = proc_dointvec,
32-
.extra1 = &i_zero,
33-
.extra2 = &i_one_hundred,
29+
.extra1 = SYSCTL_ZERO,
30+
.extra2 = SYSCTL_ONE_HUNDRED,
3431
};
3532
/*
3633
* proc_dointvec expects a buffer in user space, so we allocate one. We
@@ -79,8 +76,8 @@ static void sysctl_test_api_dointvec_table_maxlen_unset(struct kunit *test)
7976
.maxlen = 0,
8077
.mode = 0644,
8178
.proc_handler = proc_dointvec,
82-
.extra1 = &i_zero,
83-
.extra2 = &i_one_hundred,
79+
.extra1 = SYSCTL_ZERO,
80+
.extra2 = SYSCTL_ONE_HUNDRED,
8481
};
8582
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
8683
GFP_USER);
@@ -122,8 +119,8 @@ static void sysctl_test_api_dointvec_table_len_is_zero(struct kunit *test)
122119
.maxlen = sizeof(int),
123120
.mode = 0644,
124121
.proc_handler = proc_dointvec,
125-
.extra1 = &i_zero,
126-
.extra2 = &i_one_hundred,
122+
.extra1 = SYSCTL_ZERO,
123+
.extra2 = SYSCTL_ONE_HUNDRED,
127124
};
128125
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
129126
GFP_USER);
@@ -156,8 +153,8 @@ static void sysctl_test_api_dointvec_table_read_but_position_set(
156153
.maxlen = sizeof(int),
157154
.mode = 0644,
158155
.proc_handler = proc_dointvec,
159-
.extra1 = &i_zero,
160-
.extra2 = &i_one_hundred,
156+
.extra1 = SYSCTL_ZERO,
157+
.extra2 = SYSCTL_ONE_HUNDRED,
161158
};
162159
void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int),
163160
GFP_USER);
@@ -191,8 +188,8 @@ static void sysctl_test_dointvec_read_happy_single_positive(struct kunit *test)
191188
.maxlen = sizeof(int),
192189
.mode = 0644,
193190
.proc_handler = proc_dointvec,
194-
.extra1 = &i_zero,
195-
.extra2 = &i_one_hundred,
191+
.extra1 = SYSCTL_ZERO,
192+
.extra2 = SYSCTL_ONE_HUNDRED,
196193
};
197194
size_t len = 4;
198195
loff_t pos = 0;
@@ -222,8 +219,8 @@ static void sysctl_test_dointvec_read_happy_single_negative(struct kunit *test)
222219
.maxlen = sizeof(int),
223220
.mode = 0644,
224221
.proc_handler = proc_dointvec,
225-
.extra1 = &i_zero,
226-
.extra2 = &i_one_hundred,
222+
.extra1 = SYSCTL_ZERO,
223+
.extra2 = SYSCTL_ONE_HUNDRED,
227224
};
228225
size_t len = 5;
229226
loff_t pos = 0;
@@ -251,8 +248,8 @@ static void sysctl_test_dointvec_write_happy_single_positive(struct kunit *test)
251248
.maxlen = sizeof(int),
252249
.mode = 0644,
253250
.proc_handler = proc_dointvec,
254-
.extra1 = &i_zero,
255-
.extra2 = &i_one_hundred,
251+
.extra1 = SYSCTL_ZERO,
252+
.extra2 = SYSCTL_ONE_HUNDRED,
256253
};
257254
char input[] = "9";
258255
size_t len = sizeof(input) - 1;
@@ -281,8 +278,8 @@ static void sysctl_test_dointvec_write_happy_single_negative(struct kunit *test)
281278
.maxlen = sizeof(int),
282279
.mode = 0644,
283280
.proc_handler = proc_dointvec,
284-
.extra1 = &i_zero,
285-
.extra2 = &i_one_hundred,
281+
.extra1 = SYSCTL_ZERO,
282+
.extra2 = SYSCTL_ONE_HUNDRED,
286283
};
287284
char input[] = "-9";
288285
size_t len = sizeof(input) - 1;
@@ -313,8 +310,8 @@ static void sysctl_test_api_dointvec_write_single_less_int_min(
313310
.maxlen = sizeof(int),
314311
.mode = 0644,
315312
.proc_handler = proc_dointvec,
316-
.extra1 = &i_zero,
317-
.extra2 = &i_one_hundred,
313+
.extra1 = SYSCTL_ZERO,
314+
.extra2 = SYSCTL_ONE_HUNDRED,
318315
};
319316
size_t max_len = 32, len = max_len;
320317
loff_t pos = 0;
@@ -351,8 +348,8 @@ static void sysctl_test_api_dointvec_write_single_greater_int_max(
351348
.maxlen = sizeof(int),
352349
.mode = 0644,
353350
.proc_handler = proc_dointvec,
354-
.extra1 = &i_zero,
355-
.extra2 = &i_one_hundred,
351+
.extra1 = SYSCTL_ZERO,
352+
.extra2 = SYSCTL_ONE_HUNDRED,
356353
};
357354
size_t max_len = 32, len = max_len;
358355
loff_t pos = 0;

kernel/sysctl.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,16 @@
8282
#include <linux/rtmutex.h>
8383
#endif
8484

85+
/* shared constants to be used in various sysctls */
86+
const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
87+
EXPORT_SYMBOL(sysctl_vals);
88+
89+
const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
90+
EXPORT_SYMBOL_GPL(sysctl_long_vals);
91+
8592
#if defined(CONFIG_SYSCTL)
8693

87-
/* Constants used for minimum and maximum */
94+
/* Constants used for minimum and maximum */
8895

8996
#ifdef CONFIG_PERF_EVENTS
9097
static const int six_hundred_forty_kb = 640 * 1024;
@@ -129,11 +136,6 @@ static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
129136
int sysctl_legacy_va_layout;
130137
#endif
131138

132-
#ifdef CONFIG_COMPACTION
133-
/* min_extfrag_threshold is SYSCTL_ZERO */;
134-
static const int max_extfrag_threshold = 1000;
135-
#endif
136-
137139
#endif /* CONFIG_SYSCTL */
138140

139141
/*
@@ -1052,9 +1054,9 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
10521054
return 0;
10531055
}
10541056

1055-
i = (unsigned long *) data;
1056-
min = (unsigned long *) table->extra1;
1057-
max = (unsigned long *) table->extra2;
1057+
i = data;
1058+
min = table->extra1;
1059+
max = table->extra2;
10581060
vleft = table->maxlen / sizeof(unsigned long);
10591061
left = *lenp;
10601062

@@ -2216,7 +2218,7 @@ static struct ctl_table vm_table[] = {
22162218
.mode = 0644,
22172219
.proc_handler = proc_dointvec_minmax,
22182220
.extra1 = SYSCTL_ZERO,
2219-
.extra2 = (void *)&max_extfrag_threshold,
2221+
.extra2 = SYSCTL_ONE_THOUSAND,
22202222
},
22212223
{
22222224
.procname = "compact_unevictable_allowed",

0 commit comments

Comments
 (0)