Re: single aio thread is migrated crazily by scheduler

From: Dave Chinner
Date: Mon Dec 09 2019 - 18:17:54 EST


On Mon, Dec 09, 2019 at 10:21:22PM +0530, Srikar Dronamraju wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 44123b4d14e8..efd740aafa17 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2664,7 +2664,12 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> */
> int wake_up_process(struct task_struct *p)
> {
> - return try_to_wake_up(p, TASK_NORMAL, 0);
> + int wake_flags = 0;
> +
> + if (is_per_cpu_kthread(p))
> + wake_flags = WF_KTHREAD;
> +
> + return try_to_wake_up(p, TASK_NORMAL, WF_KTHREAD);

This is buggy. It always sets WF_KTHREAD, even for non-kernel
processes. I think you meant:

return try_to_wake_up(p, TASK_NORMAL, wake_flags);

I suspect this bug invalidates the test results presented, too...

-Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx