Skip to content

Commit 8a99b68

Browse files
author
Peter Zijlstra
committed
sched: Move SCHED_DEBUG sysctl to debugfs
Stop polluting sysctl with undocumented knobs that really are debug only, move them all to /debug/sched/ along with the existing /debug/sched_* files that already exist. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Tested-by: Valentin Schneider <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d86ba83 commit 8a99b68

File tree

6 files changed

+80
-113
lines changed

6 files changed

+80
-113
lines changed

include/linux/sched/sysctl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
2626
enum { sysctl_hung_task_timeout_secs = 0 };
2727
#endif
2828

29+
extern unsigned int sysctl_sched_child_runs_first;
30+
2931
extern unsigned int sysctl_sched_latency;
3032
extern unsigned int sysctl_sched_min_granularity;
3133
extern unsigned int sysctl_sched_wakeup_granularity;
32-
extern unsigned int sysctl_sched_child_runs_first;
3334

3435
enum sched_tunable_scaling {
3536
SCHED_TUNABLESCALING_NONE,
3637
SCHED_TUNABLESCALING_LOG,
3738
SCHED_TUNABLESCALING_LINEAR,
3839
SCHED_TUNABLESCALING_END,
3940
};
40-
extern enum sched_tunable_scaling sysctl_sched_tunable_scaling;
41+
extern unsigned int sysctl_sched_tunable_scaling;
4142

4243
extern unsigned int sysctl_numa_balancing_scan_delay;
4344
extern unsigned int sysctl_numa_balancing_scan_period_min;
@@ -47,9 +48,6 @@ extern unsigned int sysctl_numa_balancing_scan_size;
4748
#ifdef CONFIG_SCHED_DEBUG
4849
extern __read_mostly unsigned int sysctl_sched_migration_cost;
4950
extern __read_mostly unsigned int sysctl_sched_nr_migrate;
50-
51-
int sched_proc_update_handler(struct ctl_table *table, int write,
52-
void *buffer, size_t *length, loff_t *ppos);
5351
#endif
5452

5553
/*

kernel/sched/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5504,9 +5504,11 @@ static const struct file_operations sched_dynamic_fops = {
55045504
.release = single_release,
55055505
};
55065506

5507+
extern struct dentry *debugfs_sched;
5508+
55075509
static __init int sched_init_debug_dynamic(void)
55085510
{
5509-
debugfs_create_file("sched_preempt", 0644, NULL, NULL, &sched_dynamic_fops);
5511+
debugfs_create_file("sched_preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
55105512
return 0;
55115513
}
55125514
late_initcall(sched_init_debug_dynamic);

kernel/sched/debug.c

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,81 @@ static const struct file_operations sched_feat_fops = {
169169
.release = single_release,
170170
};
171171

172+
#ifdef CONFIG_SMP
173+
174+
static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
175+
size_t cnt, loff_t *ppos)
176+
{
177+
char buf[16];
178+
179+
if (cnt > 15)
180+
cnt = 15;
181+
182+
if (copy_from_user(&buf, ubuf, cnt))
183+
return -EFAULT;
184+
185+
if (kstrtouint(buf, 10, &sysctl_sched_tunable_scaling))
186+
return -EINVAL;
187+
188+
if (sched_update_scaling())
189+
return -EINVAL;
190+
191+
*ppos += cnt;
192+
return cnt;
193+
}
194+
195+
static int sched_scaling_show(struct seq_file *m, void *v)
196+
{
197+
seq_printf(m, "%d\n", sysctl_sched_tunable_scaling);
198+
return 0;
199+
}
200+
201+
static int sched_scaling_open(struct inode *inode, struct file *filp)
202+
{
203+
return single_open(filp, sched_scaling_show, NULL);
204+
}
205+
206+
static const struct file_operations sched_scaling_fops = {
207+
.open = sched_scaling_open,
208+
.write = sched_scaling_write,
209+
.read = seq_read,
210+
.llseek = seq_lseek,
211+
.release = single_release,
212+
};
213+
214+
#endif /* SMP */
215+
172216
__read_mostly bool sched_debug_enabled;
173217

218+
struct dentry *debugfs_sched;
219+
174220
static __init int sched_init_debug(void)
175221
{
176-
debugfs_create_file("sched_features", 0644, NULL, NULL,
177-
&sched_feat_fops);
222+
struct dentry __maybe_unused *numa;
178223

179-
debugfs_create_bool("sched_debug", 0644, NULL,
180-
&sched_debug_enabled);
224+
debugfs_sched = debugfs_create_dir("sched", NULL);
225+
226+
debugfs_create_file("features", 0644, debugfs_sched, NULL, &sched_feat_fops);
227+
debugfs_create_bool("debug_enabled", 0644, debugfs_sched, &sched_debug_enabled);
228+
229+
debugfs_create_u32("latency_ns", 0644, debugfs_sched, &sysctl_sched_latency);
230+
debugfs_create_u32("min_granularity_ns", 0644, debugfs_sched, &sysctl_sched_min_granularity);
231+
debugfs_create_u32("wakeup_granularity_ns", 0644, debugfs_sched, &sysctl_sched_wakeup_granularity);
232+
233+
#ifdef CONFIG_SMP
234+
debugfs_create_file("tunable_scaling", 0644, debugfs_sched, NULL, &sched_scaling_fops);
235+
debugfs_create_u32("migration_cost_ns", 0644, debugfs_sched, &sysctl_sched_migration_cost);
236+
debugfs_create_u32("nr_migrate", 0644, debugfs_sched, &sysctl_sched_nr_migrate);
237+
#endif
238+
239+
#ifdef CONFIG_NUMA_BALANCING
240+
numa = debugfs_create_dir("numa_balancing", debugfs_sched);
241+
242+
debugfs_create_u32("scan_delay_ms", 0644, numa, &sysctl_numa_balancing_scan_delay);
243+
debugfs_create_u32("scan_period_min_ms", 0644, numa, &sysctl_numa_balancing_scan_period_min);
244+
debugfs_create_u32("scan_period_max_ms", 0644, numa, &sysctl_numa_balancing_scan_period_max);
245+
debugfs_create_u32("scan_size_mb", 0644, numa, &sysctl_numa_balancing_scan_size);
246+
#endif
181247

182248
return 0;
183249
}

kernel/sched/fair.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static unsigned int normalized_sysctl_sched_latency = 6000000ULL;
4949
*
5050
* (default SCHED_TUNABLESCALING_LOG = *(1+ilog(ncpus))
5151
*/
52-
enum sched_tunable_scaling sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG;
52+
unsigned int sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG;
5353

5454
/*
5555
* Minimal preemption granularity for CPU-bound tasks:
@@ -634,15 +634,10 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
634634
* Scheduling class statistics methods:
635635
*/
636636

637-
int sched_proc_update_handler(struct ctl_table *table, int write,
638-
void *buffer, size_t *lenp, loff_t *ppos)
637+
int sched_update_scaling(void)
639638
{
640-
int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
641639
unsigned int factor = get_update_sysctl_factor();
642640

643-
if (ret || !write)
644-
return ret;
645-
646641
sched_nr_latency = DIV_ROUND_UP(sysctl_sched_latency,
647642
sysctl_sched_min_granularity);
648643

kernel/sched/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,8 @@ static inline void unregister_sched_domain_sysctl(void)
15681568
}
15691569
#endif
15701570

1571+
extern int sched_update_scaling(void);
1572+
15711573
extern void flush_smp_call_function_from_idle(void);
15721574

15731575
#else /* !CONFIG_SMP: */

kernel/sysctl.c

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,6 @@ static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
184184
int sysctl_legacy_va_layout;
185185
#endif
186186

187-
#ifdef CONFIG_SCHED_DEBUG
188-
static int min_sched_granularity_ns = 100000; /* 100 usecs */
189-
static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
190-
static int min_wakeup_granularity_ns; /* 0 usecs */
191-
static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
192-
#ifdef CONFIG_SMP
193-
static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
194-
static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
195-
#endif /* CONFIG_SMP */
196-
#endif /* CONFIG_SCHED_DEBUG */
197-
198187
#ifdef CONFIG_COMPACTION
199188
static int min_extfrag_threshold;
200189
static int max_extfrag_threshold = 1000;
@@ -1659,91 +1648,6 @@ static struct ctl_table kern_table[] = {
16591648
.mode = 0644,
16601649
.proc_handler = proc_dointvec,
16611650
},
1662-
#ifdef CONFIG_SCHED_DEBUG
1663-
{
1664-
.procname = "sched_min_granularity_ns",
1665-
.data = &sysctl_sched_min_granularity,
1666-
.maxlen = sizeof(unsigned int),
1667-
.mode = 0644,
1668-
.proc_handler = sched_proc_update_handler,
1669-
.extra1 = &min_sched_granularity_ns,
1670-
.extra2 = &max_sched_granularity_ns,
1671-
},
1672-
{
1673-
.procname = "sched_latency_ns",
1674-
.data = &sysctl_sched_latency,
1675-
.maxlen = sizeof(unsigned int),
1676-
.mode = 0644,
1677-
.proc_handler = sched_proc_update_handler,
1678-
.extra1 = &min_sched_granularity_ns,
1679-
.extra2 = &max_sched_granularity_ns,
1680-
},
1681-
{
1682-
.procname = "sched_wakeup_granularity_ns",
1683-
.data = &sysctl_sched_wakeup_granularity,
1684-
.maxlen = sizeof(unsigned int),
1685-
.mode = 0644,
1686-
.proc_handler = sched_proc_update_handler,
1687-
.extra1 = &min_wakeup_granularity_ns,
1688-
.extra2 = &max_wakeup_granularity_ns,
1689-
},
1690-
#ifdef CONFIG_SMP
1691-
{
1692-
.procname = "sched_tunable_scaling",
1693-
.data = &sysctl_sched_tunable_scaling,
1694-
.maxlen = sizeof(enum sched_tunable_scaling),
1695-
.mode = 0644,
1696-
.proc_handler = sched_proc_update_handler,
1697-
.extra1 = &min_sched_tunable_scaling,
1698-
.extra2 = &max_sched_tunable_scaling,
1699-
},
1700-
{
1701-
.procname = "sched_migration_cost_ns",
1702-
.data = &sysctl_sched_migration_cost,
1703-
.maxlen = sizeof(unsigned int),
1704-
.mode = 0644,
1705-
.proc_handler = proc_dointvec,
1706-
},
1707-
{
1708-
.procname = "sched_nr_migrate",
1709-
.data = &sysctl_sched_nr_migrate,
1710-
.maxlen = sizeof(unsigned int),
1711-
.mode = 0644,
1712-
.proc_handler = proc_dointvec,
1713-
},
1714-
#endif /* CONFIG_SMP */
1715-
#ifdef CONFIG_NUMA_BALANCING
1716-
{
1717-
.procname = "numa_balancing_scan_delay_ms",
1718-
.data = &sysctl_numa_balancing_scan_delay,
1719-
.maxlen = sizeof(unsigned int),
1720-
.mode = 0644,
1721-
.proc_handler = proc_dointvec,
1722-
},
1723-
{
1724-
.procname = "numa_balancing_scan_period_min_ms",
1725-
.data = &sysctl_numa_balancing_scan_period_min,
1726-
.maxlen = sizeof(unsigned int),
1727-
.mode = 0644,
1728-
.proc_handler = proc_dointvec,
1729-
},
1730-
{
1731-
.procname = "numa_balancing_scan_period_max_ms",
1732-
.data = &sysctl_numa_balancing_scan_period_max,
1733-
.maxlen = sizeof(unsigned int),
1734-
.mode = 0644,
1735-
.proc_handler = proc_dointvec,
1736-
},
1737-
{
1738-
.procname = "numa_balancing_scan_size_mb",
1739-
.data = &sysctl_numa_balancing_scan_size,
1740-
.maxlen = sizeof(unsigned int),
1741-
.mode = 0644,
1742-
.proc_handler = proc_dointvec_minmax,
1743-
.extra1 = SYSCTL_ONE,
1744-
},
1745-
#endif /* CONFIG_NUMA_BALANCING */
1746-
#endif /* CONFIG_SCHED_DEBUG */
17471651
#ifdef CONFIG_SCHEDSTATS
17481652
{
17491653
.procname = "sched_schedstats",

0 commit comments

Comments
 (0)