All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Aaron Lu <ziqianlu@bytedance.com>,
	mingo@kernel.org, linux-kernel@vger.kernel.org,
	juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	tj@kernel.org, williams@redhat.com, jkacur@redhat.com
Subject: Re: [PATCH 0/2] sched: Remove sched_class::balance()
Date: Wed, 19 Aug 2026 11:39:20 +0200	[thread overview]
Message-ID: <20260819093920.GG1246887@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <30fcc836-d013-42ec-a683-86994d307e4c@amd.com>

On Fri, Jul 03, 2026 at 09:01:37AM +0530, K Prateek Nayak wrote:
> Hi Aaron,
> 
> On 7/2/2026 5:19 PM, Aaron Lu wrote:
> > Assume cpuX and cpuY are siblings, it appears the following happened:
> > 
> >      cpuX                                      cpuY
> > 
> >    pick_next_task()
> >    goto restart_multi
> > 
> >    rqX->core_pick = pick_task(rqX)
> > 
> >    pick_task(rqY)
> >      pick_task_fair(rqY)
> >        sched_balance_newidle(rqY)
> >          raw_spin_rq_unlock(rqY)  // drops core lock
> > 
> >                                            pick_next_task()
> >                                            goto restart_multi
> >                                            rqY->core_pick = pick_task(rqY)
> >                                            rqX->core_pick = pick_task(rqX)
> > 
> >                                            if (rqX->curr == rqX->core_pick)
> >                                              rqX->core_pick = NULL
> > 
> > 					   UNLOCK rq_lockp(rqY)
> > 
> >          raw_spin_rq_lock(rqY)
> > 
> >    rqY->core_pick = pick_task(rqY)
> > 
> >    p = rqX->core_pick        // NULL
> >    cookie_equals(p, cookie)  // NULL deref
> 
> I also feel doing a balance before the core_cookie is finalized can
> move tasks wrongly to a particular core, only to make them wait later
> because the pick converted on a different core cookie. Stealing via
> balance callback still seems like a good option.
> 
> Then there is the whole issue of core_pick_seq possibly being updated
> by another CPU on the core by the time rq_lock is dropped and grabbed
> again. Afaict, anything that drops the core-wide lock should just do
> a RETRY_TASK if a new task arrives so everything is re-done withing
> a single core-wide lock critical-section.
> 
> Up until this cleanup, only fair and ext used the RETRY_TASK
> mechanism and fair bypassed the newidle with core-sched enabled so
> it never used the RETRY_TASK mechanism with core-sched so I'm still
> skeptical on balance for core-sched being done as part of pick.
> 
> Maybe Peter will have a way to sort it out after he is back from
> vacation if he hasn't got it all figured out already ;-)

Only bad ideas so far. The whole sched_ext thing [1] makes it more
complicated than I'd like.

[1] https://lore.kernel.org/r/20260819093751.GI1247881@noisy.programming.kicks-ass.net



  reply	other threads:[~2026-08-19  9:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 12:13 [PATCH 0/2] sched: Remove sched_class::balance() Peter Zijlstra
2026-06-24 12:13 ` [PATCH 1/2] sched/core: Allow newidle for core-sched Peter Zijlstra
2026-06-24 23:56   ` K Prateek Nayak
2026-06-25 12:41     ` Peter Zijlstra
2026-06-25 12:42     ` Peter Zijlstra
2026-06-24 12:13 ` [PATCH 2/2] sched: Remove sched_class::balance() Peter Zijlstra
2026-07-02 11:49 ` [PATCH 0/2] " Aaron Lu
2026-07-03  3:31   ` K Prateek Nayak
2026-08-19  9:39     ` Peter Zijlstra [this message]
2026-08-19  7:58   ` 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=20260819093920.GG1246887@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jkacur@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=williams@redhat.com \
    --cc=ziqianlu@bytedance.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.