Skip to content

Commit

Permalink
Merge tag 'sysctl-5.19-rc1' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/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
  ...
  • Loading branch information
torvalds committed May 26, 2022
2 parents cdeffe8 + 494dcdf commit 44d3572
Show file tree
Hide file tree
Showing 31 changed files with 742 additions and 611 deletions.
89 changes: 50 additions & 39 deletions fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <linux/kmemleak.h>
#include "internal.h"

#define list_for_each_table_entry(entry, table) \
for ((entry) = (table); (entry)->procname; (entry)++)

static const struct dentry_operations proc_sys_dentry_operations;
static const struct file_operations proc_sys_file_operations;
static const struct inode_operations proc_sys_inode_operations;
Expand Down Expand Up @@ -215,15 +218,19 @@ static void init_header(struct ctl_table_header *head,
INIT_HLIST_HEAD(&head->inodes);
if (node) {
struct ctl_table *entry;
for (entry = table; entry->procname; entry++, node++)

list_for_each_table_entry(entry, table) {
node->header = head;
node++;
}
}
}

static void erase_header(struct ctl_table_header *head)
{
struct ctl_table *entry;
for (entry = head->ctl_table; entry->procname; entry++)

list_for_each_table_entry(entry, head->ctl_table)
erase_entry(head, entry);
}

Expand All @@ -248,7 +255,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
err = insert_links(header);
if (err)
goto fail_links;
for (entry = header->ctl_table; entry->procname; entry++) {
list_for_each_table_entry(entry, header->ctl_table) {
err = insert_entry(header, entry);
if (err)
goto fail;
Expand Down Expand Up @@ -978,7 +985,6 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
table = (struct ctl_table *)(node + 1);
new_name = (char *)(table + 2);
memcpy(new_name, name, namelen);
new_name[namelen] = '\0';
table[0].procname = new_name;
table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
init_header(&new->header, set->dir.header.root, set, node, table);
Expand Down Expand Up @@ -1130,35 +1136,36 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)

static int sysctl_check_table(const char *path, struct ctl_table *table)
{
struct ctl_table *entry;
int err = 0;
for (; table->procname; table++) {
if (table->child)
err |= sysctl_err(path, table, "Not a file");

if ((table->proc_handler == proc_dostring) ||
(table->proc_handler == proc_dointvec) ||
(table->proc_handler == proc_douintvec) ||
(table->proc_handler == proc_douintvec_minmax) ||
(table->proc_handler == proc_dointvec_minmax) ||
(table->proc_handler == proc_dou8vec_minmax) ||
(table->proc_handler == proc_dointvec_jiffies) ||
(table->proc_handler == proc_dointvec_userhz_jiffies) ||
(table->proc_handler == proc_dointvec_ms_jiffies) ||
(table->proc_handler == proc_doulongvec_minmax) ||
(table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
if (!table->data)
err |= sysctl_err(path, table, "No data");
if (!table->maxlen)
err |= sysctl_err(path, table, "No maxlen");
list_for_each_table_entry(entry, table) {
if (entry->child)
err |= sysctl_err(path, entry, "Not a file");

if ((entry->proc_handler == proc_dostring) ||
(entry->proc_handler == proc_dointvec) ||
(entry->proc_handler == proc_douintvec) ||
(entry->proc_handler == proc_douintvec_minmax) ||
(entry->proc_handler == proc_dointvec_minmax) ||
(entry->proc_handler == proc_dou8vec_minmax) ||
(entry->proc_handler == proc_dointvec_jiffies) ||
(entry->proc_handler == proc_dointvec_userhz_jiffies) ||
(entry->proc_handler == proc_dointvec_ms_jiffies) ||
(entry->proc_handler == proc_doulongvec_minmax) ||
(entry->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
if (!entry->data)
err |= sysctl_err(path, entry, "No data");
if (!entry->maxlen)
err |= sysctl_err(path, entry, "No maxlen");
else
err |= sysctl_check_table_array(path, table);
err |= sysctl_check_table_array(path, entry);
}
if (!table->proc_handler)
err |= sysctl_err(path, table, "No proc_handler");
if (!entry->proc_handler)
err |= sysctl_err(path, entry, "No proc_handler");

if ((table->mode & (S_IRUGO|S_IWUGO)) != table->mode)
err |= sysctl_err(path, table, "bogus .mode 0%o",
table->mode);
if ((entry->mode & (S_IRUGO|S_IWUGO)) != entry->mode)
err |= sysctl_err(path, entry, "bogus .mode 0%o",
entry->mode);
}
return err;
}
Expand All @@ -1174,7 +1181,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table

name_bytes = 0;
nr_entries = 0;
for (entry = table; entry->procname; entry++) {
list_for_each_table_entry(entry, table) {
nr_entries++;
name_bytes += strlen(entry->procname) + 1;
}
Expand All @@ -1191,14 +1198,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
node = (struct ctl_node *)(links + 1);
link_table = (struct ctl_table *)(node + nr_entries);
link_name = (char *)&link_table[nr_entries + 1];
link = link_table;

for (link = link_table, entry = table; entry->procname; link++, entry++) {
list_for_each_table_entry(entry, table) {
int len = strlen(entry->procname) + 1;
memcpy(link_name, entry->procname, len);
link->procname = link_name;
link->mode = S_IFLNK|S_IRWXUGO;
link->data = link_root;
link_name += len;
link++;
}
init_header(links, dir->header.root, dir->header.set, node, link_table);
links->nreg = nr_entries;
Expand All @@ -1213,7 +1222,7 @@ static bool get_links(struct ctl_dir *dir,
struct ctl_table *entry, *link;

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

/* The checks passed. Increase the registration count on the links */
for (entry = table; entry->procname; entry++) {
list_for_each_table_entry(entry, table) {
const char *procname = entry->procname;
link = find_entry(&head, dir, procname, strlen(procname));
head->nreg++;
Expand Down Expand Up @@ -1329,7 +1338,7 @@ struct ctl_table_header *__register_sysctl_table(
struct ctl_node *node;
int nr_entries = 0;

for (entry = table; entry->procname; entry++)
list_for_each_table_entry(entry, table)
nr_entries++;

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

for (entry = table; entry->procname; entry++) {
list_for_each_table_entry(entry, table) {
if (entry->child)
nr_subheaders += count_subheaders(entry->child);
else
Expand All @@ -1475,7 +1484,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
int nr_dirs = 0;
int err = -ENOMEM;

for (entry = table; entry->procname; entry++) {
list_for_each_table_entry(entry, table) {
if (entry->child)
nr_dirs++;
else
Expand All @@ -1492,7 +1501,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
goto out;

ctl_table_arg = files;
for (new = files, entry = table; entry->procname; entry++) {
new = files;

list_for_each_table_entry(entry, table) {
if (entry->child)
continue;
*new = *entry;
Expand All @@ -1516,7 +1527,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
}

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

if (!entry->child)
Expand Down Expand Up @@ -1670,7 +1681,7 @@ static void put_links(struct ctl_table_header *header)
if (IS_ERR(core_parent))
return;

for (entry = header->ctl_table; entry->procname; entry++) {
list_for_each_table_entry(entry, header->ctl_table) {
struct ctl_table_header *link_head;
struct ctl_table *link;
const char *name = entry->procname;
Expand Down
1 change: 0 additions & 1 deletion include/linux/acct.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#ifdef CONFIG_BSD_PROCESS_ACCT
struct pid_namespace;
extern int acct_parm[]; /* for sysctl */
extern void acct_collect(long exitcode, int group_dead);
extern void acct_process(void);
extern void acct_exit_ns(struct pid_namespace *);
Expand Down
3 changes: 0 additions & 3 deletions include/linux/delayacct.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ extern int delayacct_on; /* Delay accounting turned on/off */
extern struct kmem_cache *delayacct_cache;
extern void delayacct_init(void);

extern int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);

extern void __delayacct_tsk_init(struct task_struct *);
extern void __delayacct_tsk_exit(struct task_struct *);
extern void __delayacct_blkio_start(void);
Expand Down
3 changes: 0 additions & 3 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *val
#ifdef CONFIG_FUNCTION_TRACER

extern int ftrace_enabled;
extern int
ftrace_enable_sysctl(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);

#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS

Expand Down
2 changes: 0 additions & 2 deletions include/linux/initrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ static inline void wait_for_initramfs(void) {}
extern phys_addr_t phys_initrd_start;
extern unsigned long phys_initrd_size;

extern unsigned int real_root_dev;

extern char __initramfs_start[];
extern unsigned long __initramfs_size;

Expand Down
3 changes: 0 additions & 3 deletions include/linux/latencytop.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ account_scheduler_latency(struct task_struct *task, int usecs, int inter)

void clear_tsk_latency_tracing(struct task_struct *p);

int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);

#else

static inline void
Expand Down
4 changes: 0 additions & 4 deletions include/linux/lockdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

struct task_struct;

/* for sysctl */
extern int prove_locking;
extern int lock_stat;

#ifdef CONFIG_LOCKDEP

#include <linux/linkage.h>
Expand Down
4 changes: 0 additions & 4 deletions include/linux/oom.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,4 @@ extern void oom_killer_enable(void);

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

/* sysctls */
extern int sysctl_oom_dump_tasks;
extern int sysctl_oom_kill_allocating_task;
extern int sysctl_panic_on_oom;
#endif /* _INCLUDE_LINUX_OOM_H */
6 changes: 0 additions & 6 deletions include/linux/panic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ extern void oops_enter(void);
extern void oops_exit(void);
extern bool oops_may_print(void);

#ifdef CONFIG_SMP
extern unsigned int sysctl_oops_all_cpu_backtrace;
#else
#define sysctl_oops_all_cpu_backtrace 0
#endif /* CONFIG_SMP */

extern int panic_timeout;
extern unsigned long panic_print;
extern int panic_on_oops;
Expand Down
4 changes: 0 additions & 4 deletions include/linux/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@ extern void kernel_restart(char *cmd);
extern void kernel_halt(void);
extern void kernel_power_off(void);

extern int C_A_D; /* for sysctl */
void ctrl_alt_del(void);

#define POWEROFF_CMD_PATH_LEN 256
extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];

extern void orderly_poweroff(bool force);
extern void orderly_reboot(void);
void hw_protection_shutdown(const char *reason, int ms_until_forced);
Expand Down
41 changes: 0 additions & 41 deletions include/linux/sched/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ extern unsigned long sysctl_hung_task_timeout_secs;
enum { sysctl_hung_task_timeout_secs = 0 };
#endif

extern unsigned int sysctl_sched_child_runs_first;

enum sched_tunable_scaling {
SCHED_TUNABLESCALING_NONE,
SCHED_TUNABLESCALING_LOG,
Expand All @@ -33,46 +31,7 @@ extern int sysctl_numa_balancing_mode;
#define sysctl_numa_balancing_mode 0
#endif

/*
* control realtime throttling:
*
* /proc/sys/kernel/sched_rt_period_us
* /proc/sys/kernel/sched_rt_runtime_us
*/
extern unsigned int sysctl_sched_rt_period;
extern int sysctl_sched_rt_runtime;

extern unsigned int sysctl_sched_dl_period_max;
extern unsigned int sysctl_sched_dl_period_min;

#ifdef CONFIG_UCLAMP_TASK
extern unsigned int sysctl_sched_uclamp_util_min;
extern unsigned int sysctl_sched_uclamp_util_max;
extern unsigned int sysctl_sched_uclamp_util_min_rt_default;
#endif

#ifdef CONFIG_CFS_BANDWIDTH
extern unsigned int sysctl_sched_cfs_bandwidth_slice;
#endif

extern int sysctl_sched_rr_timeslice;
extern int sched_rr_timeslice;

int sched_rr_handler(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int sysctl_numa_balancing(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);
int sysctl_schedstats(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos);

#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
extern unsigned int sysctl_sched_energy_aware;
int sched_energy_aware_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
#endif

#endif /* _LINUX_SCHED_SYSCTL_H */
15 changes: 0 additions & 15 deletions include/linux/writeback.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,28 +352,13 @@ void wb_domain_exit(struct wb_domain *dom);
extern struct wb_domain global_wb_domain;

/* These are exported to sysctl. */
extern int dirty_background_ratio;
extern unsigned long dirty_background_bytes;
extern int vm_dirty_ratio;
extern unsigned long vm_dirty_bytes;
extern unsigned int dirty_writeback_interval;
extern unsigned int dirty_expire_interval;
extern unsigned int dirtytime_expire_interval;
extern int vm_highmem_is_dirtyable;
extern int laptop_mode;

int dirty_background_ratio_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int dirty_background_bytes_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int dirty_ratio_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int dirty_bytes_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int dirtytime_interval_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);

void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh);
Expand Down
Loading

0 comments on commit 44d3572

Please sign in to comment.