From: Peter Zijlstra <peterz@infradead.org>
To: Ibrahim Elshahed <lshahed@amazon.de>
Cc: Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
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>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Josh Don <joshdon@google.com>,
linux-kernel@vger.kernel.org, nh-open-source@amazon.com,
Fernand Sieber <sieberf@amazon.com>,
Roman Kagan <rkagan@amazon.de>
Subject: Re: [PATCH 2/2] sched/core: Don't skip a pending core-wide pick on idle re-entry
Date: Wed, 18 Nov 2026 15:40:27 +0100 [thread overview]
Message-ID: <20261118144027.GZ1779021@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261117142704.6878-3-lshahed@amazon.de>
On Tue, Nov 17, 2026 at 02:27:03PM +0000, Ibrahim Elshahed wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index b1718ba5a4..58b429bbe3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -347,6 +347,17 @@ void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags)
> resched_curr(rq);
> }
>
> +/*
> + * An idle CPU with an empty runqueue must still call pick_next_task() while
> + * it has a pending core-wide pick or the core is forced idle. Only that pick
> + * consumes rq->core_pick and ends the forced idle.
> + */
> +static inline bool sched_core_idle_needs_pick(struct rq *rq)
> +{
> + return sched_core_enabled(rq) &&
> + (rq->core_pick || rq->core->core_forceidle_count);
> +}
I'm not sure I understand the rq->core_pick condition here. We already
have !rq->nr_running, and if we have rq->core_pick, then nr_running must
be non-zero, right?
> static int sched_task_is_throttled(struct task_struct *p, int cpu)
> {
> if (p->sched_class->task_is_throttled)
> @@ -550,6 +561,7 @@ void sched_core_put(void)
> static inline void sched_core_enqueue(struct rq *rq, struct task_struct *p) { }
> static inline void
> sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }
> +static inline bool sched_core_idle_needs_pick(struct rq *rq) { return false; }
>
> #endif /* !CONFIG_SCHED_CORE */
>
> @@ -7285,8 +7297,13 @@ static void __sched notrace __schedule(int sched_mode)
> */
> prev_state = READ_ONCE(prev->__state);
> if (sched_mode == SM_IDLE) {
> - /* SCX must consult the BPF scheduler to tell if rq is empty */
> - if (!rq->nr_running && !scx_enabled()) {
> + /*
> + * SCX must consult the BPF scheduler to tell if rq is empty,
> + * and core scheduling may need pick_next_task() to consume
> + * rq->core_pick or to end forced idle.
> + */
> + if (!rq->nr_running && !scx_enabled() &&
> + !sched_core_idle_needs_pick(rq)) {
> next = prev;
> rq->next_class = &idle_sched_class;
> goto picked;
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-11-18 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:27 [PATCH 0/2] sched/core: Fix stale core_pick and forced idle after SM_IDLE fast path Ibrahim Elshahed
2026-11-17 14:27 ` [PATCH 1/2] sched/core: Clear a stale rq->core_pick after dequeue Ibrahim Elshahed
2026-11-17 14:27 ` [PATCH 2/2] sched/core: Don't skip a pending core-wide pick on idle re-entry Ibrahim Elshahed
2026-11-18 14:40 ` Peter Zijlstra [this message]
2026-11-17 14:27 ` [PATCH 0/2] sched/core: Fix stale core_pick and forced idle after SM_IDLE fast path Ibrahim Elshahed
2026-11-18 14:41 ` Peter Zijlstra
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=20261118144027.GZ1779021@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=joshdon@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lshahed@amazon.de \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=rkagan@amazon.de \
--cc=rostedt@goodmis.org \
--cc=sieberf@amazon.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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®