Skip to content

Commit

Permalink
sched: partly revert "sched debug: remove NULL checking in print_cfs_…
Browse files Browse the repository at this point in the history
…rt_rq()"

Impact: avoid accessing NULL tg.css->cgroup

In commit 0a0db8f, 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>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Jan 11, 2009
1 parent 62ea9ce commit 805194c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions kernel/sched_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
read_unlock_irqrestore(&tasklist_lock, flags);
}

#if defined(CONFIG_CGROUP_SCHED) && \
(defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED))
static void task_group_path(struct task_group *tg, char *buf, int buflen)
{
/* may be NULL if the underlying cgroup isn't fully-created yet */
if (!tg->css.cgroup) {
buf[0] = '\0';
return;
}
cgroup_path(tg->css.cgroup, buf, buflen);
}
#endif

void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
Expand All @@ -154,10 +167,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
unsigned long flags;

#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)
char path[128] = "";
char path[128];
struct task_group *tg = cfs_rq->tg;

cgroup_path(tg->css.cgroup, path, sizeof(path));
task_group_path(tg, path, sizeof(path));

SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, path);
#elif defined(CONFIG_USER_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)
Expand Down Expand Up @@ -208,10 +221,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
{
#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_RT_GROUP_SCHED)
char path[128] = "";
char path[128];
struct task_group *tg = rt_rq->tg;

cgroup_path(tg->css.cgroup, path, sizeof(path));
task_group_path(tg, path, sizeof(path));

SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, path);
#else
Expand Down

0 comments on commit 805194c

Please sign in to comment.