Skip to content

Commit

Permalink
kernel/delayacct: move delayacct sysctls to its own file
Browse files Browse the repository at this point in the history
kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the delayacct sysctl to its own file,
kernel/delayacct.c.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
  • Loading branch information
imtangmeng authored and mcgrof committed Apr 6, 2022
1 parent 801b501 commit 1186618
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
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
22 changes: 21 additions & 1 deletion kernel/delayacct.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void delayacct_init(void)
}

#ifdef CONFIG_PROC_SYSCTL
int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
static int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
int state = delayacct_on;
Expand All @@ -63,6 +63,26 @@ int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
set_delayacct(state);
return err;
}

static struct ctl_table kern_delayacct_table[] = {
{
.procname = "task_delayacct",
.data = NULL,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = sysctl_delayacct,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{ }
};

static __init int kernel_delayacct_sysctls_init(void)
{
register_sysctl_init("kernel", kern_delayacct_table);
return 0;
}
late_initcall(kernel_delayacct_sysctls_init);
#endif

void __delayacct_tsk_init(struct task_struct *tsk)
Expand Down
12 changes: 0 additions & 12 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#include <linux/userfaultfd_k.h>
#include <linux/latencytop.h>
#include <linux/pid.h>
#include <linux/delayacct.h>

#include "../lib/kstrtox.h"

Expand Down Expand Up @@ -1651,17 +1650,6 @@ int proc_do_static_key(struct ctl_table *table, int write,
}

static struct ctl_table kern_table[] = {
#ifdef CONFIG_TASK_DELAY_ACCT
{
.procname = "task_delayacct",
.data = NULL,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = sysctl_delayacct,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#endif /* CONFIG_TASK_DELAY_ACCT */
#ifdef CONFIG_NUMA_BALANCING
{
.procname = "numa_balancing",
Expand Down

0 comments on commit 1186618

Please sign in to comment.