All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juri Lelli <juri.lelli@redhat.com>
To: Lucas Stach <l.stach@pengutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	patchwork-lst@pengutronix.de
Subject: Re: [PATCH] sched/deadline: Fix stale throttling on de-/boosted tasks
Date: Wed, 2 Sep 2020 08:00:24 +0200	[thread overview]
Message-ID: <20200902060024.GK16601@localhost.localdomain> (raw)
In-Reply-To: <20200831110719.2126930-1-l.stach@pengutronix.de>

Hi,

On 31/08/20 13:07, Lucas Stach wrote:
> When a boosted task gets throttled, what normally happens is that it's
> immediately enqueued again with ENQUEUE_REPLENISH, which replenishes the
> runtime and clears the dl_throttled flag. There is a special case however:
> if the throttling happened on sched-out and the task has been deboosted in
> the meantime, the replenish is skipped as the task will return to its
> normal scheduling class. This leaves the task with the dl_throttled flag
> set.
> 
> Now if the task gets boosted up to the deadline scheduling class again
> while it is sleeping, it's still in the throttled state. The normal wakeup
> however will enqueue the task with ENQUEUE_REPLENISH not set, so we don't
> actually place it on the rq. Thus we end up with a task that is runnable,
> but not actually on the rq and neither a immediate replenishment happens,
> nor is the replenishment timer set up, so the task is stuck in
> forever-throttled limbo.
> 
> Clear the dl_throttled flag before dropping back to the normal scheduling
> class to fix this issue.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> This is the root cause and fix of the issue described at [1]. After working
> on other stuff for the last few months, I finally was able to circle back
> to this issue and gather the required data to pinpoint the failure mode.
> 
> [1] https://lkml.org/lkml/2020/3/20/765
> ---
>  kernel/sched/deadline.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 3862a28cd05d..c19c1883d695 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1527,12 +1527,15 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
>  		pi_se = &pi_task->dl;
>  	} else if (!dl_prio(p->normal_prio)) {
>  		/*
> -		 * Special case in which we have a !SCHED_DEADLINE task
> -		 * that is going to be deboosted, but exceeds its
> -		 * runtime while doing so. No point in replenishing
> -		 * it, as it's going to return back to its original
> -		 * scheduling class after this.
> +		 * Special case in which we have a !SCHED_DEADLINE task that is going
> +		 * to be deboosted, but exceeds its runtime while doing so. No point in
> +		 * replenishing it, as it's going to return back to its original
> +		 * scheduling class after this. If it has been throttled, we need to
> +		 * clear the flag, otherwise the task may wake up as throttled after
> +		 * being boosted again with no means to replenish the runtime and clear
> +		 * the throttle.
>  		 */
> +		p->dl.dl_throttled = 0;
>  		BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH);
>  		return;
>  	}

Ah, right, thanks for looking into this issue!

Wonder if we should be calling __dl_clear_params() instead of just
clearing dl_throttled, but what you propose makes sense to me.

Acked-by: Juri Lelli <juri.lelli@redhat.com>

Best,

Juri


  reply	other threads:[~2020-09-02  6:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 11:07 [PATCH] sched/deadline: Fix stale throttling on de-/boosted tasks Lucas Stach
2020-09-02  6:00 ` Juri Lelli [this message]
2020-09-02  9:43   ` peterz
2020-09-09 12:59     ` Lucas Stach
2020-09-16  7:40     ` Daniel Bristot de Oliveira
2020-09-29  7:56 ` [tip: sched/core] " tip-bot2 for Lucas Stach

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=20200902060024.GK16601@localhost.localdomain \
    --to=juri.lelli@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=kernel@pengutronix.de \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=patchwork-lst@pengutronix.de \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.