diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-01-10 02:43:15 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-10 20:40:32 -0500 |
commit | 805194c35b91999b139e4d6b6145f4f84fd4c814 (patch) | |
tree | 7530c66ec53045858bba70ad8f1c626c450d12cc | |
parent | 62ea9ceb17a74bc7544211bfeecf4170c554ac4f (diff) |
sched: partly revert "sched debug: remove NULL checking in print_cfs_rt_rq()"
Impact: avoid accessing NULL tg.css->cgroup
In commit 0a0db8f5c9d4bbb9bbfcc2b6cb6bce2d0ef4d73d, I removed checking
NULL tg.css->cgroup, but I realized I was wrong when I found reading
/proc/sched_debug can race with cgroup_create().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/sched_debug.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 4293cfa9681d..16eeba4e4169 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -145,6 +145,19 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) | |||
145 | read_unlock_irqrestore(&tasklist_lock, flags); | 145 | read_unlock_irqrestore(&tasklist_lock, flags); |
146 | } | 146 | } |
147 | 147 | ||
148 | #if defined(CONFIG_CGROUP_SCHED) && \ | ||
149 | (defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED)) | ||
150 | static void task_group_path(struct task_group *tg, char *buf, int buflen) | ||
151 | { | ||
152 | /* may be NULL if the underlying cgroup isn't fully-created yet */ | ||
153 | if (!tg->css.cgroup) { | ||
154 | buf[0] = '\0'; | ||
155 | return; | ||
156 | } | ||
157 | cgroup_path(tg->css.cgroup, buf, buflen); | ||
158 | } | ||
159 | #endif | ||
160 | |||
148 | void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) | 161 | void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) |
149 | { | 162 | { |
150 | s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1, | 163 | s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1, |
@@ -154,10 +167,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) | |||
154 | unsigned long flags; | 167 | unsigned long flags; |
155 | 168 | ||
156 | #if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED) | 169 | #if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED) |
157 | char path[128] = ""; | 170 | char path[128]; |
158 | struct task_group *tg = cfs_rq->tg; | 171 | struct task_group *tg = cfs_rq->tg; |
159 | 172 | ||
160 | cgroup_path(tg->css.cgroup, path, sizeof(path)); | 173 | task_group_path(tg, path, sizeof(path)); |
161 | 174 | ||
162 | SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, path); | 175 | SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, path); |
163 | #elif defined(CONFIG_USER_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED) | 176 | #elif defined(CONFIG_USER_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED) |
@@ -208,10 +221,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) | |||
208 | void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq) | 221 | void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq) |
209 | { | 222 | { |
210 | #if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_RT_GROUP_SCHED) | 223 | #if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_RT_GROUP_SCHED) |
211 | char path[128] = ""; | 224 | char path[128]; |
212 | struct task_group *tg = rt_rq->tg; | 225 | struct task_group *tg = rt_rq->tg; |
213 | 226 | ||
214 | cgroup_path(tg->css.cgroup, path, sizeof(path)); | 227 | task_group_path(tg, path, sizeof(path)); |
215 | 228 | ||
216 | SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, path); | 229 | SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, path); |
217 | #else | 230 | #else |