Re: [RFC] sched: Distinguish between idle_cpu calls based on desired effect

From: Randy Dunlap
Date: Mon May 07 2018 - 20:15:26 EST


On 05/07/2018 04:41 PM, Rohit Jain wrote:
> In commit 247f2f6f3c706b40b5f3886646f3eb53671258bf we distinguish
> between idle_cpu when the vcpu is not running for scheduling threads.
> However, idle_cpu function is used at other places for actually checking
> whether the state of the CPU is idle or not. Hence splitting the use of
> that function based on the desired return value.
>
> Signed-off-by: Rohit Jain <rohit.k.jain@xxxxxxxxxx>
> ---
> include/linux/sched.h | 1 +
> kernel/sched/core.c | 14 ++++++++++++++
> kernel/sched/fair.c | 20 ++++++++++----------
> 3 files changed, 25 insertions(+), 10 deletions(-)
>

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 71bdb86..171e160 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4028,6 +4028,20 @@ int idle_cpu(int cpu)
> return 0;
> #endif
>
> + return 1;
> +}
> +
> +/**
> + * idle_cpu - is a given CPU idle for enqueuing work.

* available_idle_cpu -

> + * @cpu: the processor in question.
> + *
> + * Return: 1 if the CPU is currently idle. 0 otherwise.
> + */
> +int available_idle_cpu(int cpu)
> +{
> + if (!idle_cpu(cpu))
> + return 0;
> +
> if (vcpu_is_preempted(cpu))
> return 0;
>


--
~Randy