19
19
#include <linux/sched.h>
20
20
#include <linux/cpumask.h>
21
21
#include <linux/cpuset.h>
22
+ #include <linux/debugfs.h>
22
23
#include <linux/mutex.h>
23
24
#include <linux/sysctl.h>
24
25
#include <linux/nodemask.h>
@@ -34,50 +35,38 @@ static bool __read_mostly sched_itmt_capable;
34
35
* of higher turbo frequency for cpus supporting Intel Turbo Boost Max
35
36
* Technology 3.0.
36
37
*
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
38
39
*/
39
- unsigned int __read_mostly sysctl_sched_itmt_enabled ;
40
+ bool __read_mostly sysctl_sched_itmt_enabled ;
40
41
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 )
43
45
{
44
- unsigned int old_sysctl ;
45
- int ret ;
46
+ ssize_t result ;
47
+ bool orig ;
46
48
47
- mutex_lock (& itmt_update_mutex );
49
+ guard ( mutex ) (& itmt_update_mutex );
48
50
49
- if (!sched_itmt_capable ) {
50
- mutex_unlock (& itmt_update_mutex );
51
- return - EINVAL ;
52
- }
53
-
54
- old_sysctl = sysctl_sched_itmt_enabled ;
55
- 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 );
56
53
57
- if (! ret && write && old_sysctl != sysctl_sched_itmt_enabled ) {
54
+ if (sysctl_sched_itmt_enabled != orig ) {
58
55
x86_topology_update = true;
59
56
rebuild_sched_domains ();
60
57
}
61
58
62
- mutex_unlock (& itmt_update_mutex );
63
-
64
- return ret ;
59
+ return result ;
65
60
}
66
61
67
- static struct ctl_table itmt_kern_table [] = {
68
- {
69
- .procname = "sched_itmt_enabled" ,
70
- .data = & sysctl_sched_itmt_enabled ,
71
- .maxlen = sizeof (unsigned int ),
72
- .mode = 0644 ,
73
- .proc_handler = sched_itmt_update_handler ,
74
- .extra1 = SYSCTL_ZERO ,
75
- .extra2 = SYSCTL_ONE ,
76
- },
77
- {}
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 ,
78
67
};
79
68
80
- static struct ctl_table_header * itmt_sysctl_header ;
69
+ static struct dentry * dfs_sched_itmt ;
81
70
82
71
/**
83
72
* sched_set_itmt_support() - Indicate platform supports ITMT
@@ -98,16 +87,18 @@ static struct ctl_table_header *itmt_sysctl_header;
98
87
*/
99
88
int sched_set_itmt_support (void )
100
89
{
101
- mutex_lock (& itmt_update_mutex );
90
+ guard ( mutex ) (& itmt_update_mutex );
102
91
103
- if (sched_itmt_capable ) {
104
- mutex_unlock (& itmt_update_mutex );
92
+ if (sched_itmt_capable )
105
93
return 0 ;
106
- }
107
94
108
- itmt_sysctl_header = register_sysctl ("kernel" , itmt_kern_table );
109
- if (!itmt_sysctl_header ) {
110
- mutex_unlock (& itmt_update_mutex );
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 ;
111
102
return - ENOMEM ;
112
103
}
113
104
@@ -118,8 +109,6 @@ int sched_set_itmt_support(void)
118
109
x86_topology_update = true;
119
110
rebuild_sched_domains ();
120
111
121
- mutex_unlock (& itmt_update_mutex );
122
-
123
112
return 0 ;
124
113
}
125
114
@@ -135,27 +124,22 @@ int sched_set_itmt_support(void)
135
124
*/
136
125
void sched_clear_itmt_support (void )
137
126
{
138
- mutex_lock (& itmt_update_mutex );
127
+ guard ( mutex ) (& itmt_update_mutex );
139
128
140
- if (!sched_itmt_capable ) {
141
- mutex_unlock (& itmt_update_mutex );
129
+ if (!sched_itmt_capable )
142
130
return ;
143
- }
131
+
144
132
sched_itmt_capable = false;
145
133
146
- if (itmt_sysctl_header ) {
147
- unregister_sysctl_table (itmt_sysctl_header );
148
- itmt_sysctl_header = NULL ;
149
- }
134
+ debugfs_remove (dfs_sched_itmt );
135
+ dfs_sched_itmt = NULL ;
150
136
151
137
if (sysctl_sched_itmt_enabled ) {
152
138
/* disable sched_itmt if we are no longer ITMT capable */
153
139
sysctl_sched_itmt_enabled = 0 ;
154
140
x86_topology_update = true;
155
141
rebuild_sched_domains ();
156
142
}
157
-
158
- mutex_unlock (& itmt_update_mutex );
159
143
}
160
144
161
145
int arch_asym_cpu_priority (int cpu )
0 commit comments