Skip to content

Commit 44d3572

Browse files
committed
Merge tag 'sysctl-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
Pull sysctl updates from Luis Chamberlain: "For two kernel releases now kernel/sysctl.c has been being cleaned up slowly, since the tables were grossly long, sprinkled with tons of #ifdefs and all this caused merge conflicts with one susbystem or another. This tree was put together to help try to avoid conflicts with these cleanups going on different trees at time. So nothing exciting on this pull request, just cleanups. Thanks a lot to the Uniontech and Huawei folks for doing some of this nasty work" * tag 'sysctl-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: (28 commits) sched: Fix build warning without CONFIG_SYSCTL reboot: Fix build warning without CONFIG_SYSCTL kernel/kexec_core: move kexec_core sysctls into its own file sysctl: minor cleanup in new_dir() ftrace: fix building with SYSCTL=y but DYNAMIC_FTRACE=n fs/proc: Introduce list_for_each_table_entry for proc sysctl mm: fix unused variable kernel warning when SYSCTL=n latencytop: move sysctl to its own file ftrace: fix building with SYSCTL=n but DYNAMIC_FTRACE=y ftrace: Fix build warning ftrace: move sysctl_ftrace_enabled to ftrace.c kernel/do_mount_initrd: move real_root_dev sysctls to its own file kernel/delayacct: move delayacct sysctls to its own file kernel/acct: move acct sysctls to its own file kernel/panic: move panic sysctls to its own file kernel/lockdep: move lockdep sysctls to its own file mm: move page-writeback sysctls to their own file mm: move oom_kill sysctls to their own file kernel/reboot: move reboot sysctls to its own file sched: Move energy_aware sysctls to topology.c ...
2 parents cdeffe8 + 494dcdf commit 44d3572

31 files changed

+742
-611
lines changed

fs/proc/proc_sysctl.c

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <linux/kmemleak.h>
2020
#include "internal.h"
2121

22+
#define list_for_each_table_entry(entry, table) \
23+
for ((entry) = (table); (entry)->procname; (entry)++)
24+
2225
static const struct dentry_operations proc_sys_dentry_operations;
2326
static const struct file_operations proc_sys_file_operations;
2427
static const struct inode_operations proc_sys_inode_operations;
@@ -215,15 +218,19 @@ static void init_header(struct ctl_table_header *head,
215218
INIT_HLIST_HEAD(&head->inodes);
216219
if (node) {
217220
struct ctl_table *entry;
218-
for (entry = table; entry->procname; entry++, node++)
221+
222+
list_for_each_table_entry(entry, table) {
219223
node->header = head;
224+
node++;
225+
}
220226
}
221227
}
222228

223229
static void erase_header(struct ctl_table_header *head)
224230
{
225231
struct ctl_table *entry;
226-
for (entry = head->ctl_table; entry->procname; entry++)
232+
233+
list_for_each_table_entry(entry, head->ctl_table)
227234
erase_entry(head, entry);
228235
}
229236

@@ -248,7 +255,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
248255
err = insert_links(header);
249256
if (err)
250257
goto fail_links;
251-
for (entry = header->ctl_table; entry->procname; entry++) {
258+
list_for_each_table_entry(entry, header->ctl_table) {
252259
err = insert_entry(header, entry);
253260
if (err)
254261
goto fail;
@@ -978,7 +985,6 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
978985
table = (struct ctl_table *)(node + 1);
979986
new_name = (char *)(table + 2);
980987
memcpy(new_name, name, namelen);
981-
new_name[namelen] = '\0';
982988
table[0].procname = new_name;
983989
table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
984990
init_header(&new->header, set->dir.header.root, set, node, table);
@@ -1130,35 +1136,36 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
11301136

11311137
static int sysctl_check_table(const char *path, struct ctl_table *table)
11321138
{
1139+
struct ctl_table *entry;
11331140
int err = 0;
1134-
for (; table->procname; table++) {
1135-
if (table->child)
1136-
err |= sysctl_err(path, table, "Not a file");
1137-
1138-
if ((table->proc_handler == proc_dostring) ||
1139-
(table->proc_handler == proc_dointvec) ||
1140-
(table->proc_handler == proc_douintvec) ||
1141-
(table->proc_handler == proc_douintvec_minmax) ||
1142-
(table->proc_handler == proc_dointvec_minmax) ||
1143-
(table->proc_handler == proc_dou8vec_minmax) ||
1144-
(table->proc_handler == proc_dointvec_jiffies) ||
1145-
(table->proc_handler == proc_dointvec_userhz_jiffies) ||
1146-
(table->proc_handler == proc_dointvec_ms_jiffies) ||
1147-
(table->proc_handler == proc_doulongvec_minmax) ||
1148-
(table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
1149-
if (!table->data)
1150-
err |= sysctl_err(path, table, "No data");
1151-
if (!table->maxlen)
1152-
err |= sysctl_err(path, table, "No maxlen");
1141+
list_for_each_table_entry(entry, table) {
1142+
if (entry->child)
1143+
err |= sysctl_err(path, entry, "Not a file");
1144+
1145+
if ((entry->proc_handler == proc_dostring) ||
1146+
(entry->proc_handler == proc_dointvec) ||
1147+
(entry->proc_handler == proc_douintvec) ||
1148+
(entry->proc_handler == proc_douintvec_minmax) ||
1149+
(entry->proc_handler == proc_dointvec_minmax) ||
1150+
(entry->proc_handler == proc_dou8vec_minmax) ||
1151+
(entry->proc_handler == proc_dointvec_jiffies) ||
1152+
(entry->proc_handler == proc_dointvec_userhz_jiffies) ||
1153+
(entry->proc_handler == proc_dointvec_ms_jiffies) ||
1154+
(entry->proc_handler == proc_doulongvec_minmax) ||
1155+
(entry->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
1156+
if (!entry->data)
1157+
err |= sysctl_err(path, entry, "No data");
1158+
if (!entry->maxlen)
1159+
err |= sysctl_err(path, entry, "No maxlen");
11531160
else
1154-
err |= sysctl_check_table_array(path, table);
1161+
err |= sysctl_check_table_array(path, entry);
11551162
}
1156-
if (!table->proc_handler)
1157-
err |= sysctl_err(path, table, "No proc_handler");
1163+
if (!entry->proc_handler)
1164+
err |= sysctl_err(path, entry, "No proc_handler");
11581165

1159-
if ((table->mode & (S_IRUGO|S_IWUGO)) != table->mode)
1160-
err |= sysctl_err(path, table, "bogus .mode 0%o",
1161-
table->mode);
1166+
if ((entry->mode & (S_IRUGO|S_IWUGO)) != entry->mode)
1167+
err |= sysctl_err(path, entry, "bogus .mode 0%o",
1168+
entry->mode);
11621169
}
11631170
return err;
11641171
}
@@ -1174,7 +1181,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
11741181

11751182
name_bytes = 0;
11761183
nr_entries = 0;
1177-
for (entry = table; entry->procname; entry++) {
1184+
list_for_each_table_entry(entry, table) {
11781185
nr_entries++;
11791186
name_bytes += strlen(entry->procname) + 1;
11801187
}
@@ -1191,14 +1198,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
11911198
node = (struct ctl_node *)(links + 1);
11921199
link_table = (struct ctl_table *)(node + nr_entries);
11931200
link_name = (char *)&link_table[nr_entries + 1];
1201+
link = link_table;
11941202

1195-
for (link = link_table, entry = table; entry->procname; link++, entry++) {
1203+
list_for_each_table_entry(entry, table) {
11961204
int len = strlen(entry->procname) + 1;
11971205
memcpy(link_name, entry->procname, len);
11981206
link->procname = link_name;
11991207
link->mode = S_IFLNK|S_IRWXUGO;
12001208
link->data = link_root;
12011209
link_name += len;
1210+
link++;
12021211
}
12031212
init_header(links, dir->header.root, dir->header.set, node, link_table);
12041213
links->nreg = nr_entries;
@@ -1213,7 +1222,7 @@ static bool get_links(struct ctl_dir *dir,
12131222
struct ctl_table *entry, *link;
12141223

12151224
/* Are there links available for every entry in table? */
1216-
for (entry = table; entry->procname; entry++) {
1225+
list_for_each_table_entry(entry, table) {
12171226
const char *procname = entry->procname;
12181227
link = find_entry(&head, dir, procname, strlen(procname));
12191228
if (!link)
@@ -1226,7 +1235,7 @@ static bool get_links(struct ctl_dir *dir,
12261235
}
12271236

12281237
/* The checks passed. Increase the registration count on the links */
1229-
for (entry = table; entry->procname; entry++) {
1238+
list_for_each_table_entry(entry, table) {
12301239
const char *procname = entry->procname;
12311240
link = find_entry(&head, dir, procname, strlen(procname));
12321241
head->nreg++;
@@ -1329,7 +1338,7 @@ struct ctl_table_header *__register_sysctl_table(
13291338
struct ctl_node *node;
13301339
int nr_entries = 0;
13311340

1332-
for (entry = table; entry->procname; entry++)
1341+
list_for_each_table_entry(entry, table)
13331342
nr_entries++;
13341343

13351344
header = kzalloc(sizeof(struct ctl_table_header) +
@@ -1456,7 +1465,7 @@ static int count_subheaders(struct ctl_table *table)
14561465
if (!table || !table->procname)
14571466
return 1;
14581467

1459-
for (entry = table; entry->procname; entry++) {
1468+
list_for_each_table_entry(entry, table) {
14601469
if (entry->child)
14611470
nr_subheaders += count_subheaders(entry->child);
14621471
else
@@ -1475,7 +1484,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
14751484
int nr_dirs = 0;
14761485
int err = -ENOMEM;
14771486

1478-
for (entry = table; entry->procname; entry++) {
1487+
list_for_each_table_entry(entry, table) {
14791488
if (entry->child)
14801489
nr_dirs++;
14811490
else
@@ -1492,7 +1501,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
14921501
goto out;
14931502

14941503
ctl_table_arg = files;
1495-
for (new = files, entry = table; entry->procname; entry++) {
1504+
new = files;
1505+
1506+
list_for_each_table_entry(entry, table) {
14961507
if (entry->child)
14971508
continue;
14981509
*new = *entry;
@@ -1516,7 +1527,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
15161527
}
15171528

15181529
/* Recurse into the subdirectories. */
1519-
for (entry = table; entry->procname; entry++) {
1530+
list_for_each_table_entry(entry, table) {
15201531
char *child_pos;
15211532

15221533
if (!entry->child)
@@ -1670,7 +1681,7 @@ static void put_links(struct ctl_table_header *header)
16701681
if (IS_ERR(core_parent))
16711682
return;
16721683

1673-
for (entry = header->ctl_table; entry->procname; entry++) {
1684+
list_for_each_table_entry(entry, header->ctl_table) {
16741685
struct ctl_table_header *link_head;
16751686
struct ctl_table *link;
16761687
const char *name = entry->procname;

include/linux/acct.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#ifdef CONFIG_BSD_PROCESS_ACCT
2323
struct pid_namespace;
24-
extern int acct_parm[]; /* for sysctl */
2524
extern void acct_collect(long exitcode, int group_dead);
2625
extern void acct_process(void);
2726
extern void acct_exit_ns(struct pid_namespace *);

include/linux/delayacct.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ extern int delayacct_on; /* Delay accounting turned on/off */
6161
extern struct kmem_cache *delayacct_cache;
6262
extern void delayacct_init(void);
6363

64-
extern int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
65-
size_t *lenp, loff_t *ppos);
66-
6764
extern void __delayacct_tsk_init(struct task_struct *);
6865
extern void __delayacct_tsk_exit(struct task_struct *);
6966
extern void __delayacct_blkio_start(void);

include/linux/ftrace.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *val
101101
#ifdef CONFIG_FUNCTION_TRACER
102102

103103
extern int ftrace_enabled;
104-
extern int
105-
ftrace_enable_sysctl(struct ctl_table *table, int write,
106-
void *buffer, size_t *lenp, loff_t *ppos);
107104

108105
#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
109106

include/linux/initrd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ static inline void wait_for_initramfs(void) {}
2929
extern phys_addr_t phys_initrd_start;
3030
extern unsigned long phys_initrd_size;
3131

32-
extern unsigned int real_root_dev;
33-
3432
extern char __initramfs_start[];
3533
extern unsigned long __initramfs_size;
3634

include/linux/latencytop.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ account_scheduler_latency(struct task_struct *task, int usecs, int inter)
3838

3939
void clear_tsk_latency_tracing(struct task_struct *p);
4040

41-
int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
42-
size_t *lenp, loff_t *ppos);
43-
4441
#else
4542

4643
static inline void

include/linux/lockdep.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
struct task_struct;
1818

19-
/* for sysctl */
20-
extern int prove_locking;
21-
extern int lock_stat;
22-
2319
#ifdef CONFIG_LOCKDEP
2420

2521
#include <linux/linkage.h>

include/linux/oom.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,4 @@ extern void oom_killer_enable(void);
123123

124124
extern struct task_struct *find_lock_task_mm(struct task_struct *p);
125125

126-
/* sysctls */
127-
extern int sysctl_oom_dump_tasks;
128-
extern int sysctl_oom_kill_allocating_task;
129-
extern int sysctl_panic_on_oom;
130126
#endif /* _INCLUDE_LINUX_OOM_H */

include/linux/panic.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ extern void oops_enter(void);
1515
extern void oops_exit(void);
1616
extern bool oops_may_print(void);
1717

18-
#ifdef CONFIG_SMP
19-
extern unsigned int sysctl_oops_all_cpu_backtrace;
20-
#else
21-
#define sysctl_oops_all_cpu_backtrace 0
22-
#endif /* CONFIG_SMP */
23-
2418
extern int panic_timeout;
2519
extern unsigned long panic_print;
2620
extern int panic_on_oops;

include/linux/reboot.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ extern void kernel_restart(char *cmd);
7171
extern void kernel_halt(void);
7272
extern void kernel_power_off(void);
7373

74-
extern int C_A_D; /* for sysctl */
7574
void ctrl_alt_del(void);
7675

77-
#define POWEROFF_CMD_PATH_LEN 256
78-
extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
79-
8076
extern void orderly_poweroff(bool force);
8177
extern void orderly_reboot(void);
8278
void hw_protection_shutdown(const char *reason, int ms_until_forced);

0 commit comments

Comments
 (0)