Skip to content

Commit 7e14825

Browse files
committed
x86/itmt: Move the "sched_itmt_enabled" sysctl to debugfs
JIRA: https://issues.redhat.com/browse/RHEL-53784 Conflicts: RHEL is missing upstream 78eb4ea and 83e291d commit d04013a Author: K Prateek Nayak <[email protected]> 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 <[email protected]> Signed-off-by: K Prateek Nayak <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Tim Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: David Arcari <[email protected]>
1 parent b52c620 commit 7e14825

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

arch/x86/kernel/itmt.c

Lines changed: 27 additions & 30 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,46 +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(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-
},
73-
{}
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,
7467
};
7568

76-
static struct ctl_table_header *itmt_sysctl_header;
69+
static struct dentry *dfs_sched_itmt;
7770

7871
/**
7972
* sched_set_itmt_support() - Indicate platform supports ITMT
@@ -99,9 +92,15 @@ int sched_set_itmt_support(void)
9992
if (sched_itmt_capable)
10093
return 0;
10194

102-
itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table);
103-
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;
104102
return -ENOMEM;
103+
}
105104

106105
sched_itmt_capable = true;
107106

@@ -132,10 +131,8 @@ void sched_clear_itmt_support(void)
132131

133132
sched_itmt_capable = false;
134133

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

140137
if (sysctl_sched_itmt_enabled) {
141138
/* disable sched_itmt if we are no longer ITMT capable */

0 commit comments

Comments
 (0)