aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paul.mckenney@linaro.org>2011-11-10 15:41:56 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2011-12-11 13:31:47 -0500
commitc4f3060843506ba6d473ab9a0afe5bd5dc93a00d (patch)
tree3fa6ed6ea9288daa19426a5402d5bcb08f6edcbe
parentbb3bf7052de520f2d21a1275e95fac7a84d89e4c (diff)
sched: Add is_idle_task() to handle invalidated uses of idle_cpu()
Commit 908a3283 (Fix idle_cpu()) invalidated some uses of idle_cpu(), which used to say whether or not the CPU was running the idle task, but now instead says whether or not the CPU is running the idle task in the absence of pending wakeups. Although this new implementation gives a better answer to the question "is this CPU idle?", it also invalidates other uses that were made of idle_cpu(). This commit therefore introduces a new is_idle_task() API member that determines whether or not the specified task is one of the idle tasks, allowing open-coded "->pid == 0" sequences to be replaced by something more meaningful. Suggested-by: Josh Triplett <josh@joshtriplett.org> Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rw-r--r--include/linux/sched.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1c4f3e9b9bc..4a7e4d333a2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2070,6 +2070,14 @@ extern int sched_setscheduler(struct task_struct *, int,
2070extern int sched_setscheduler_nocheck(struct task_struct *, int, 2070extern int sched_setscheduler_nocheck(struct task_struct *, int,
2071 const struct sched_param *); 2071 const struct sched_param *);
2072extern struct task_struct *idle_task(int cpu); 2072extern struct task_struct *idle_task(int cpu);
2073/**
2074 * is_idle_task - is the specified task an idle task?
2075 * @tsk: the task in question.
2076 */
2077static inline bool is_idle_task(struct task_struct *p)
2078{
2079 return p->pid == 0;
2080}
2073extern struct task_struct *curr_task(int cpu); 2081extern struct task_struct *curr_task(int cpu);
2074extern void set_curr_task(int cpu, struct task_struct *p); 2082extern void set_curr_task(int cpu, struct task_struct *p);
2075 2083