From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D947443A86 for ; Wed, 19 Aug 2026 09:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787132376; cv=none; b=siAORKGaUJXqocH47kJmhiWSrls9ZJnSCOaeMAQ+EtM1uq3ojZonQ05MuMV+bfx2WIysvZEbJGTCPqa6XztVUZcXJcAfLQUF0TlUg4klVQODopX4Q6/P0hMwidbDwI/xFLcDhgd6ZMI/985w2v0yJDrEQ2YflDV1OTNFXL0ZQfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787132376; c=relaxed/simple; bh=Yfbgy7+5tEkzOXsSqUcLxn7lV1spCpTD8h94arnmrnI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b3xJOLSZg/LQcu0tJgqTY+QwaJuRTN9+WB5Ei0Q+K7Rx9G+PfEKCq6ghkCv4ZBUasjiHpt3QhJrC+CE0vh4wm87TT37zdckVAHclzzQrSdYaSUPA4aLFMudRT5a8oSPmosknXnFxKYd40XEoQEomrW+jfiUOYtZIj7+GAa0CwLs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=F9PixPXU; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="F9PixPXU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9e1v2k4BkRD5Y0hELsfbFWbCnPmmUEHaP6b7j+SyU8A=; b=F9PixPXUTV5MnlyFgLxLmY0col tl1BEZYZMXupLePXYVmSz3NpDEzTpFG72/nVrcIoxcUPcnBonB00YZ8zT3Vwbaehwt2pxB72PBPp+ fLKJ8Trz1+nsrHhn89OAatT53/PlSjjAoz/cpGpAGYLFIW3JpposwRSXImAPCAmc3EzY4TGEaoTCB SH5Mp7CnUTx79BU+AM7RyyyFk1GgLPmFmcJ618yfRnzQxDzQeBJgi8NkPtpguBo7hMBQifiP1vN1J lG/mfyZgI7ypj2yDLOof34bmZ8R6RT5kk3ka7Ngt4MMM1ROYpVIrsAETPh5+wYcC2cXDEpn34M4ti kR/GPxzQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wwclU-0000000DRLQ-3FTU; Wed, 19 Aug 2026 09:39:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 439BB30030F; Wed, 19 Aug 2026 11:39:20 +0200 (CEST) Date: Wed, 19 Aug 2026 11:39:20 +0200 From: Peter Zijlstra To: K Prateek Nayak Cc: Aaron Lu , 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() Message-ID: <20260819093920.GG1246887@noisy.programming.kicks-ass.net> References: <20260624121327.190063948@infradead.org> <20260702114919.GA186418@bytedance.com> <30fcc836-d013-42ec-a683-86994d307e4c@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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