diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2016-02-22 16:26:50 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-02-29 03:53:06 -0500 |
commit | d6ca41d7922ce0110a840ef4f8ec4afdd5a239d3 (patch) | |
tree | 0dd1302f3f1dfb8a429f76147c66db4998488344 /kernel/sched/debug.c | |
parent | ff77e468535987b3d21b7bd4da15608ea3ce7d0b (diff) |
sched/debug: Move the /sys/kernel/debug/sched_features file setup into debug.c
As /sys/kernel/debug/sched_features is only created when SCHED_DEBUG is enabled, and the file
debug.c is only compiled when SCHED_DEBUG is enabled, it makes sense to move
sched_feature setup into that file and get rid of the #ifdef.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Clark Williams <williams@redhat.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160222212825.464193063@goodmis.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/debug.c')
-rw-r--r-- | kernel/sched/debug.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 7cfa87bd8b89..d2dedfcbf84d 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kallsyms.h> | 16 | #include <linux/kallsyms.h> |
17 | #include <linux/utsname.h> | 17 | #include <linux/utsname.h> |
18 | #include <linux/mempolicy.h> | 18 | #include <linux/mempolicy.h> |
19 | #include <linux/debugfs.h> | ||
19 | 20 | ||
20 | #include "sched.h" | 21 | #include "sched.h" |
21 | 22 | ||
@@ -58,6 +59,136 @@ static unsigned long nsec_low(unsigned long long nsec) | |||
58 | 59 | ||
59 | #define SPLIT_NS(x) nsec_high(x), nsec_low(x) | 60 | #define SPLIT_NS(x) nsec_high(x), nsec_low(x) |
60 | 61 | ||
62 | #define SCHED_FEAT(name, enabled) \ | ||
63 | #name , | ||
64 | |||
65 | static const char * const sched_feat_names[] = { | ||
66 | #include "features.h" | ||
67 | }; | ||
68 | |||
69 | #undef SCHED_FEAT | ||
70 | |||
71 | static int sched_feat_show(struct seq_file *m, void *v) | ||
72 | { | ||
73 | int i; | ||
74 | |||
75 | for (i = 0; i < __SCHED_FEAT_NR; i++) { | ||
76 | if (!(sysctl_sched_features & (1UL << i))) | ||
77 | seq_puts(m, "NO_"); | ||
78 | seq_printf(m, "%s ", sched_feat_names[i]); | ||
79 | } | ||
80 | seq_puts(m, "\n"); | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | #ifdef HAVE_JUMP_LABEL | ||
86 | |||
87 | #define jump_label_key__true STATIC_KEY_INIT_TRUE | ||
88 | #define jump_label_key__false STATIC_KEY_INIT_FALSE | ||
89 | |||
90 | #define SCHED_FEAT(name, enabled) \ | ||
91 | jump_label_key__##enabled , | ||
92 | |||
93 | struct static_key sched_feat_keys[__SCHED_FEAT_NR] = { | ||
94 | #include "features.h" | ||
95 | }; | ||
96 | |||
97 | #undef SCHED_FEAT | ||
98 | |||
99 | static void sched_feat_disable(int i) | ||
100 | { | ||
101 | static_key_disable(&sched_feat_keys[i]); | ||
102 | } | ||
103 | |||
104 | static void sched_feat_enable(int i) | ||
105 | { | ||
106 | static_key_enable(&sched_feat_keys[i]); | ||
107 | } | ||
108 | #else | ||
109 | static void sched_feat_disable(int i) { }; | ||
110 | static void sched_feat_enable(int i) { }; | ||
111 | #endif /* HAVE_JUMP_LABEL */ | ||
112 | |||
113 | static int sched_feat_set(char *cmp) | ||
114 | { | ||
115 | int i; | ||
116 | int neg = 0; | ||
117 | |||
118 | if (strncmp(cmp, "NO_", 3) == 0) { | ||
119 | neg = 1; | ||
120 | cmp += 3; | ||
121 | } | ||
122 | |||
123 | for (i = 0; i < __SCHED_FEAT_NR; i++) { | ||
124 | if (strcmp(cmp, sched_feat_names[i]) == 0) { | ||
125 | if (neg) { | ||
126 | sysctl_sched_features &= ~(1UL << i); | ||
127 | sched_feat_disable(i); | ||
128 | } else { | ||
129 | sysctl_sched_features |= (1UL << i); | ||
130 | sched_feat_enable(i); | ||
131 | } | ||
132 | break; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | return i; | ||
137 | } | ||
138 | |||
139 | static ssize_t | ||
140 | sched_feat_write(struct file *filp, const char __user *ubuf, | ||
141 | size_t cnt, loff_t *ppos) | ||
142 | { | ||
143 | char buf[64]; | ||
144 | char *cmp; | ||
145 | int i; | ||
146 | struct inode *inode; | ||
147 | |||
148 | if (cnt > 63) | ||
149 | cnt = 63; | ||
150 | |||
151 | if (copy_from_user(&buf, ubuf, cnt)) | ||
152 | return -EFAULT; | ||
153 | |||
154 | buf[cnt] = 0; | ||
155 | cmp = strstrip(buf); | ||
156 | |||
157 | /* Ensure the static_key remains in a consistent state */ | ||
158 | inode = file_inode(filp); | ||
159 | inode_lock(inode); | ||
160 | i = sched_feat_set(cmp); | ||
161 | inode_unlock(inode); | ||
162 | if (i == __SCHED_FEAT_NR) | ||
163 | return -EINVAL; | ||
164 | |||
165 | *ppos += cnt; | ||
166 | |||
167 | return cnt; | ||
168 | } | ||
169 | |||
170 | static int sched_feat_open(struct inode *inode, struct file *filp) | ||
171 | { | ||
172 | return single_open(filp, sched_feat_show, NULL); | ||
173 | } | ||
174 | |||
175 | static const struct file_operations sched_feat_fops = { | ||
176 | .open = sched_feat_open, | ||
177 | .write = sched_feat_write, | ||
178 | .read = seq_read, | ||
179 | .llseek = seq_lseek, | ||
180 | .release = single_release, | ||
181 | }; | ||
182 | |||
183 | static __init int sched_init_debug(void) | ||
184 | { | ||
185 | debugfs_create_file("sched_features", 0644, NULL, NULL, | ||
186 | &sched_feat_fops); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | late_initcall(sched_init_debug); | ||
191 | |||
61 | #ifdef CONFIG_FAIR_GROUP_SCHED | 192 | #ifdef CONFIG_FAIR_GROUP_SCHED |
62 | static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) | 193 | static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg) |
63 | { | 194 | { |