linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Valentin Schneider <valentin.schneider@arm.com>,
	linux-kernel@vger.kernel.org
Cc: John Keeping <john@metanate.com>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Subject: Re: [PATCH] sched/rt: Plug rt_mutex_setprio() vs push_rt_task() race
Date: Mon, 24 Jan 2022 10:37:43 +0100	[thread overview]
Message-ID: <aa5bf2d0-bef7-485a-9a51-0da7df67d8c5@arm.com> (raw)
In-Reply-To: <20220120194037.650433-1-valentin.schneider@arm.com>

On 20/01/2022 20:40, Valentin Schneider wrote:

[...]

> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 7b4f4fbbb404..48fc8c04b038 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2026,6 +2026,16 @@ static int push_rt_task(struct rq *rq, bool pull)
>  		return 0;
>  
>  retry:
> +	/*
> +	 * It's possible that the next_task slipped in of
> +	 * higher priority than current. If that's the case
> +	 * just reschedule current.
> +	 */
> +	if (unlikely(next_task->prio < rq->curr->prio)) {
> +		resched_curr(rq);
> +		return 0;
> +	}

If we do this before `is_migration_disabled(next_task), shouldn't then
the related condition in push_dl_task() also be moved up?

  if (dl_task(rq->curr) &&
    dl_time_before(next_task->dl.deadline, rq->curr->dl.deadline) &&
    rq->curr->nr_cpus_allowed > 1)

To enforce resched_curr(rq) in the `is_migration_disabled(next_task)`
case there as well?

> +
>  	if (is_migration_disabled(next_task)) {
>  		struct task_struct *push_task = NULL;
>  		int cpu;
> @@ -2033,6 +2043,17 @@ static int push_rt_task(struct rq *rq, bool pull)
>  		if (!pull || rq->push_busy)
>  			return 0;
>  
> +		/*
> +		 * Per the above priority check, curr is at least RT. If it's
> +		 * of a higher class than RT, invoking find_lowest_rq() on it
> +		 * doesn't make sense.
> +		 *
> +		 * Note that the stoppers are masqueraded as SCHED_FIFO
> +		 * (cf. sched_set_stop_task()), so we can't rely on rt_task().
> +		 */
> +		if (rq->curr->sched_class != &rt_sched_class)

s/ != / > / ... since the `unlikely(next_task->prio < rq->curr->prio)`
already filters tasks from lower sched classes (CFS)?

> +			return 0;
> +

[...]


  parent reply	other threads:[~2022-01-24  9:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 19:40 [PATCH] sched/rt: Plug rt_mutex_setprio() vs push_rt_task() race Valentin Schneider
2022-01-20 19:47 ` Valentin Schneider
2022-01-21 19:47   ` John Keeping
2022-01-24 12:39     ` Valentin Schneider
2022-01-24  9:37 ` Dietmar Eggemann [this message]
2022-01-24 13:29   ` Valentin Schneider
2022-01-24 15:47     ` Dietmar Eggemann
2022-01-24 16:51       ` Valentin Schneider

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=aa5bf2d0-bef7-485a-9a51-0da7df67d8c5@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=john@metanate.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=valentin.schneider@arm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).