From: Tejun Heo <tj@kernel.org>
To: David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: linux-kernel@vger.kernel.org, sched-ext@meta.com
Subject: Re: [PATCH sched_ext/for-6.14-fixes] sched_ext: Fix pick_task_scx() picking non-queued tasks when it's called without balance()
Date: Tue, 25 Feb 2025 08:30:36 -1000 [thread overview]
Message-ID: <Z74MTER2Mycqt8xg@slm.duckdns.org> (raw)
In-Reply-To: <Z73pjysZYNEIbkiy@slm.duckdns.org>
On Tue, Feb 25, 2025 at 06:02:23AM -1000, Tejun Heo wrote:
> a6250aa251ea ("sched_ext: Handle cases where pick_task_scx() is called
> without preceding balance_scx()") added a workaround to handle the cases
> where pick_task_scx() is called without prececing balance_scx() which is due
> to a fair class bug where pick_taks_fair() may return NULL after a true
> return from balance_fair().
>
> The workaround detects when pick_task_scx() is called without preceding
> balance_scx() and emulates SCX_RQ_BAL_KEEP and triggers kicking to avoid
> stalling. Unfortunately, the workaround code was testing whether @prev was
> on SCX to decide whether to keep the task running. This is incorrect as the
> task may be on SCX but no longer runnable.
>
> This could lead to a non-runnable task to be returned from pick_task_scx()
> which cause interesting confusions and failures. e.g. A common failure mode
> is the task ending up with (!on_rq && on_cpu) state which can cause
> potential wakers to busy loop, which can easily lead to deadlocks.
>
> Fix it by testing whether @prev has SCX_TASK_QUEUED set. This makes
> $prev_on_scx only used in one place. Open code the usage and improve the
> comment while at it.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Pat Cody <patcody@meta.com>
> Fixes: a6250aa251ea ("sched_ext: Handle cases where pick_task_scx() is called without preceding balance_scx()")
> Cc: stable@vger.kernel.org # v6.12+
Applied to sched_ext/for-6.14-fixes.
Thanks.
--
tejun
prev parent reply other threads:[~2025-02-25 18:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 16:02 [PATCH sched_ext/for-6.14-fixes] sched_ext: Fix pick_task_scx() picking non-queued tasks when it's called without balance() Tejun Heo
2025-02-25 17:14 ` Andrea Righi
2025-02-25 17:45 ` Tejun Heo
2025-02-25 18:30 ` Tejun Heo [this message]
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=Z74MTER2Mycqt8xg@slm.duckdns.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@meta.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox