@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)
extern void set_task_cpu(struct task_struct *p, unsigned int cpu);
+static inline int task_running(const struct task_struct *p)
+{
+ return READ_ONCE(p->on_cpu);
+}
+
#else
static inline unsigned int task_cpu(const struct task_struct *p)
@@ -1854,6 +1859,11 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
{
}
+static inline int task_running(const struct task_struct *p)
+{
+ return p == current;
+}
+
#endif /* CONFIG_SMP */
/*
The task_running() should be renamed to task_running_on_rq() like the naming of task_running_on_cpu(), this is what it originally mean. Add task_running() no rq required. Signed-off-by: Wang Qing <wangqing@vivo.com> --- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)