Skip to content

Commit 15dc497

Browse files
committed
x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs
JIRA: https://issues.redhat.com/browse/RHEL-53783 commit d04013a Author: K Prateek Nayak <kprateek.nayak@amd.com> Date: Mon Dec 23 04:34:02 2024 +0000 x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs "sched_itmt_enabled" was only introduced as a debug toggle for any funky ITMT behavior. Move the sysctl controlled from "/proc/sys/kernel/sched_itmt_enabled" to debugfs at "/sys/kernel/debug/x86/sched_itmt_enabled" with a notable change that a cat on the file will return "Y" or "N" instead of "1" or "0" to indicate that feature is enabled or disabled respectively. Either "0" or "N" (or any string that kstrtobool() interprets as false) can be written to the file will disable the feature, and writing either "1" or "Y" (or any string that kstrtobool() interprets as true) will enable it back when the platform supports ITMT ranking. Since ITMT is x86 specific (and PowerPC uses SD_ASYM_PACKING too), the toggle was moved to "/sys/kernel/debug/x86/" as opposed to "/sys/kernel/debug/sched/" Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com> Link: https://lore.kernel.org/r/20241223043407.1611-4-kprateek.nayak@amd.com Signed-off-by: Steve Best <sbest@redhat.com>
1 parent 63fcbf0 commit 15dc497

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

arch/x86/kernel/itmt.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/sched.h>
2020
#include <linux/cpumask.h>
2121
#include <linux/cpuset.h>
22+
#include <linux/debugfs.h>
2223
#include <linux/mutex.h>
2324
#include <linux/sysctl.h>
2425
#include <linux/nodemask.h>
@@ -34,45 +35,38 @@ static bool __read_mostly sched_itmt_capable;
3435
* of higher turbo frequency for cpus supporting Intel Turbo Boost Max
3536
* Technology 3.0.
3637
*
37-
* It can be set via /proc/sys/kernel/sched_itmt_enabled
38+
* It can be set via /sys/kernel/debug/x86/sched_itmt_enabled
3839
*/
3940
bool __read_mostly sysctl_sched_itmt_enabled;
4041

41-
static int sched_itmt_update_handler(const struct ctl_table *table, int write,
42-
void *buffer, size_t *lenp, loff_t *ppos)
42+
static ssize_t sched_itmt_enabled_write(struct file *filp,
43+
const char __user *ubuf,
44+
size_t cnt, loff_t *ppos)
4345
{
44-
unsigned int old_sysctl;
45-
int ret;
46+
ssize_t result;
47+
bool orig;
4648

4749
guard(mutex)(&itmt_update_mutex);
4850

49-
if (!sched_itmt_capable)
50-
return -EINVAL;
51-
52-
old_sysctl = sysctl_sched_itmt_enabled;
53-
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
51+
orig = sysctl_sched_itmt_enabled;
52+
result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
5453

55-
if (!ret && write && old_sysctl != sysctl_sched_itmt_enabled) {
54+
if (sysctl_sched_itmt_enabled != orig) {
5655
x86_topology_update = true;
5756
rebuild_sched_domains();
5857
}
5958

60-
return ret;
59+
return result;
6160
}
6261

63-
static struct ctl_table itmt_kern_table[] = {
64-
{
65-
.procname = "sched_itmt_enabled",
66-
.data = &sysctl_sched_itmt_enabled,
67-
.maxlen = sizeof(unsigned int),
68-
.mode = 0644,
69-
.proc_handler = sched_itmt_update_handler,
70-
.extra1 = SYSCTL_ZERO,
71-
.extra2 = SYSCTL_ONE,
72-
},
62+
static const struct file_operations dfs_sched_itmt_fops = {
63+
.read = debugfs_read_file_bool,
64+
.write = sched_itmt_enabled_write,
65+
.open = simple_open,
66+
.llseek = default_llseek,
7367
};
7468

75-
static struct ctl_table_header *itmt_sysctl_header;
69+
static struct dentry *dfs_sched_itmt;
7670

7771
/**
7872
* sched_set_itmt_support() - Indicate platform supports ITMT
@@ -98,9 +92,15 @@ int sched_set_itmt_support(void)
9892
if (sched_itmt_capable)
9993
return 0;
10094

101-
itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table);
102-
if (!itmt_sysctl_header)
95+
dfs_sched_itmt = debugfs_create_file_unsafe("sched_itmt_enabled",
96+
0644,
97+
arch_debugfs_dir,
98+
&sysctl_sched_itmt_enabled,
99+
&dfs_sched_itmt_fops);
100+
if (IS_ERR_OR_NULL(dfs_sched_itmt)) {
101+
dfs_sched_itmt = NULL;
103102
return -ENOMEM;
103+
}
104104

105105
sched_itmt_capable = true;
106106

@@ -131,10 +131,8 @@ void sched_clear_itmt_support(void)
131131

132132
sched_itmt_capable = false;
133133

134-
if (itmt_sysctl_header) {
135-
unregister_sysctl_table(itmt_sysctl_header);
136-
itmt_sysctl_header = NULL;
137-
}
134+
debugfs_remove(dfs_sched_itmt);
135+
dfs_sched_itmt = NULL;
138136

139137
if (sysctl_sched_itmt_enabled) {
140138
/* disable sched_itmt if we are no longer ITMT capable */

0 commit comments

Comments
 (0)