All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuba Piecuch <jpiecuch@google.com>
To: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	David Vernet <void@manifault.com>,
	 Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/2] sched_ext: Reenqueue IMMED tasks when a higher class wins the pick
Date: Mon, 30 Nov 2026 16:26:10 +0000	[thread overview]
Message-ID: <20261130162540.3997064-1-jpiecuch@google.com> (raw)
In-Reply-To: <2c4bde68cd5b1ad1bbb7a3cc7d3e3139@kernel.org>

Hi Tejun,

On Mon, 30 Nov 2026 15:11, Tejun Heo wrote:
> This is just from reading the code and I could be wrong, but AFAICS there
> are three cases where wakeup_preempt_scx() finds an IMMED task on the
> local DSQ which doesn't already have a reenqueue scheduled:
>
> 1. The CPU is idle and hasn't picked the task which was just inserted.
>
> 2. The CPU is in dispatch.
>
> 3. The task was inserted with SCX_ENQ_PREEMPT or SCX_ENQ_PREEMPT_LAZY and
>    curr hasn't scheduled out yet.
>
> In the first two, the CPU looks to be already on its way to the pick, so
> I don't think there's much difference. In the last one, triggering from
> wakeup_preempt_scx() may be a bit sooner, but that doesn't seem that
> significant to me, especially given that the task was already waiting for
> curr to schedule out, which is the latency the preempt path already
> accepts. Am I missing something?

I think you're right. Put as an invariant: an IMMED task on a local DSQ
either has a reenqueue scheduled, or its CPU is in the pick or has a
resched pending. rq_is_open() only keeps a lone IMMED task in your three
cases, and rq_owned_post_enq() provides the resched for them: through
wakeup_preempt() when next_class is below ext, and through the slice
reset and resched_curr() for PREEMPT. So when a higher class task wakes
up, the CPU is going through __schedule() anyway, and scx_settle_pick()
catches the IMMED tasks there if the pick lands above ext. If the pick
lands on ext (the ext dl_server still has budget, or the woken task got
pushed away), the IMMED task can run right after the pick.

There are two exceptions I know of:

- A forced idle pick consumes the resched and leaves the IMMED task
  queued with next_class at idle. That's intended (AFAIK), and a higher
  class wakeup goes through wakeup_preempt_idle() there anyway, so we
  don't lose anything by removing the reenqueue from
  wakeup_preempt_scx().

- Under core scheduling, the core-wide pick can dispatch on a sibling
  that has an RT task current. It gets to do_pick_task_scx() on the
  sibling through the ext dl_server, which lowers the sibling's
  next_class to ext and runs dispatch with SCX_RQ_IN_DISPATCH set, so
  rq_owned_post_enq() skips the resched. If the core pick then hands the
  sibling its current task, nothing reschedules it, and the IMMED task
  stays behind the RT task with next_class stuck at ext. That's the case
  Sashiko reported, and I'll fix it in v2.

  Dropping the reenqueue from wakeup_preempt_scx() doesn't make this case
  worse. That reenqueue only runs when a task of a class above ext wakes
  up on the sibling: because of the stale next_class, wakeup_preempt()
  calls wakeup_preempt_scx(), and then resched_curr(). The sibling then
  goes through __schedule(), which resets next_class from its pick, and
  scx_settle_pick() reenqueues the IMMED task if that pick lands above
  ext. All that's lost is the time until the sibling reschedules.

So I'll drop the reenqueue from wakeup_preempt_scx() in v2, so that
scx_settle_pick() is the only place.

Thanks,
Kuba

  reply	other threads:[~2026-11-30 16:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 11:50 [RFC PATCHSET sched_ext/for-7.4-fixes] sched_ext: Reenqueue IMMED tasks when a higher class wins the pick Kuba Piecuch
2026-11-25 11:50 ` [RFC PATCH 1/2] " Kuba Piecuch
2026-11-25 12:16   ` sashiko-bot
2026-11-30 11:19     ` Kuba Piecuch
2026-11-27 15:10   ` Tejun Heo
2026-11-30 11:19     ` Kuba Piecuch
2026-11-30 15:11       ` Tejun Heo
2026-11-30 16:26         ` Kuba Piecuch [this message]
2026-11-25 11:50 ` [RFC PATCH 2/2] selftests/sched_ext: Add immed_strand test Kuba Piecuch

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=20261130162540.3997064-1-jpiecuch@google.com \
    --to=jpiecuch@google.com \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.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 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.