Skip to content

Commit 988f11e

Browse files
liaohuamcgrof
authored andcommitted
latencytop: move sysctl to its own file
This moves latencytop sysctl to kernel/latencytop.c Signed-off-by: liaohua <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent f8b7d2b commit 988f11e

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

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

kernel/latencytop.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <linux/sched/stat.h>
5656
#include <linux/list.h>
5757
#include <linux/stacktrace.h>
58+
#include <linux/sysctl.h>
5859

5960
static DEFINE_RAW_SPINLOCK(latency_lock);
6061

@@ -63,6 +64,31 @@ static struct latency_record latency_record[MAXLR];
6364

6465
int latencytop_enabled;
6566

67+
#ifdef CONFIG_SYSCTL
68+
static int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
69+
size_t *lenp, loff_t *ppos)
70+
{
71+
int err;
72+
73+
err = proc_dointvec(table, write, buffer, lenp, ppos);
74+
if (latencytop_enabled)
75+
force_schedstat_enabled();
76+
77+
return err;
78+
}
79+
80+
static struct ctl_table latencytop_sysctl[] = {
81+
{
82+
.procname = "latencytop",
83+
.data = &latencytop_enabled,
84+
.maxlen = sizeof(int),
85+
.mode = 0644,
86+
.proc_handler = sysctl_latencytop,
87+
},
88+
{}
89+
};
90+
#endif
91+
6692
void clear_tsk_latency_tracing(struct task_struct *p)
6793
{
6894
unsigned long flags;
@@ -266,18 +292,9 @@ static const struct proc_ops lstats_proc_ops = {
266292
static int __init init_lstats_procfs(void)
267293
{
268294
proc_create("latency_stats", 0644, NULL, &lstats_proc_ops);
295+
#ifdef CONFIG_SYSCTL
296+
register_sysctl_init("kernel", latencytop_sysctl);
297+
#endif
269298
return 0;
270299
}
271-
272-
int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
273-
size_t *lenp, loff_t *ppos)
274-
{
275-
int err;
276-
277-
err = proc_dointvec(table, write, buffer, lenp, ppos);
278-
if (latencytop_enabled)
279-
force_schedstat_enabled();
280-
281-
return err;
282-
}
283300
device_initcall(init_lstats_procfs);

kernel/sysctl.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#include <linux/kexec.h>
6565
#include <linux/mount.h>
6666
#include <linux/userfaultfd_k.h>
67-
#include <linux/latencytop.h>
6867
#include <linux/pid.h>
6968

7069
#include "../lib/kstrtox.h"
@@ -1623,15 +1622,6 @@ static struct ctl_table kern_table[] = {
16231622
.extra1 = SYSCTL_NEG_ONE,
16241623
.extra2 = SYSCTL_ONE,
16251624
},
1626-
#endif
1627-
#ifdef CONFIG_LATENCYTOP
1628-
{
1629-
.procname = "latencytop",
1630-
.data = &latencytop_enabled,
1631-
.maxlen = sizeof(int),
1632-
.mode = 0644,
1633-
.proc_handler = sysctl_latencytop,
1634-
},
16351625
#endif
16361626
{
16371627
.procname = "print-fatal-signals",

0 commit comments

Comments
 (0)