mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Steve Muckle <smuckle@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@android.com,
	Todd Kjos <tkjos@google.com>, Paul Turner <pjt@google.com>,
	Quentin Perret <quentin.perret@arm.com>,
	Patrick Bellasi <Patrick.Bellasi@arm.com>,
	Chris Redpath <Chris.Redpath@arm.com>,
	Morten Rasmussen <Morten.Rasmussen@arm.com>,
	Miguel de Dios <migueldedios@google.com>,
	John Dias <joaodias@google.com>
Subject: Re: [PATCH] sched/fair: fix vruntime_normalized for remote non-migration wakeup
Date: Sun, 2 Sep 2018 21:27:16 -0700	[thread overview]
Message-ID: <bb8f4581-20e1-772b-7c98-98ba22443a45@arm.com> (raw)
In-Reply-To: <20180831224217.169476-1-smuckle@google.com>

On 08/31/2018 03:42 PM, Steve Muckle wrote:
> When a task which previously ran on a given CPU is remotely queued to
> wake up on that same CPU, there is a period where the task's state is
> TASK_WAKING and its vruntime is not normalized. This is not accounted
> for in vruntime_normalized() which will cause an
> error in the task's vruntime if it is switched from the fair class
> during this time, for example if it is boosted to RT priority via
> rt_mutex_setprio. The rq's min_vruntime will not be subtracted from the
> task's vruntime but it will be added again when the task returns to the
> fair class. The task's vruntime will have been erroneously doubled and
> the effective priority of the task will be reduced.
> 
> Note this will also lead to inflation of all vruntimes since the doubled
> vruntime value will become the rq's min_vruntime when other tasks leave
> the rq. This leads to repeated doubling of the vruntime and priority
> penalty.
> 
> Fix this by recognizing a WAKING task's vruntime as normalized only if
> sched_remote_wakeup is true. This indicates a migration, in which case
> the vruntime would have been normalized in migrate_task_rq_fair().
> 
> Based on a similar patch from joaodias@google.com.
> 
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Steve Muckle <smuckle@google.com>
> ---
>   kernel/sched/fair.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index b39fb596f6c1..b3b62cf37fb6 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9638,7 +9638,8 @@ static inline bool vruntime_normalized(struct task_struct *p)
>   	 * - A task which has been woken up by try_to_wake_up() and
>   	 *   waiting for actually being woken up by sched_ttwu_pending().
>   	 */
> -	if (!se->sum_exec_runtime || p->state == TASK_WAKING)
> +	if (!se->sum_exec_runtime ||
> +	    (p->state == TASK_WAKING && p->sched_remote_wakeup))
>   		return true;
>   
>   	return false;
> 

Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>

  reply	other threads:[~2018-09-03  4:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 22:42 Steve Muckle
2018-09-03  4:27 ` Dietmar Eggemann [this message]
2018-09-10 10:07 ` [tip:sched/core] sched/fair: Fix vruntime_normalized() " tip-bot for Steve Muckle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb8f4581-20e1-772b-7c98-98ba22443a45@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=Chris.Redpath@arm.com \
    --cc=Morten.Rasmussen@arm.com \
    --cc=Patrick.Bellasi@arm.com \
    --cc=joaodias@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=migueldedios@google.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=quentin.perret@arm.com \
    --cc=smuckle@google.com \
    --cc=tkjos@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®