lkml.org 
[lkml]   [2020]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
On Mon, 13 Apr 2020 at 14:04, Wang Qing <wangqing@vivo.com> wrote:
>
> We have no interface whether the task is running,
> so we need to add an interface and distinguish CONFIG_SMP.
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
> include/linux/sched.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 4418f5c..13cc8f5 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -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_oncpu(const struct task_struct *p)

This function name is too close from task_running_on_cpu() and can be
misleading as the difference is only "_"
Also, how task_running_oncpu() is different from task_running() ?

> +{
> + return 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_oncpu(const struct task_struct *p)
> +{
> + return p == current;
> +}
> +
> #endif /* CONFIG_SMP */
>
> /*
> --
> 2.7.4
>

\
 
 \ /
  Last update: 2020-04-14 09:22    [W:0.095 / U:1.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site