From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6F2F63D3CF3 for ; Wed, 18 Mar 2026 12:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773838055; cv=none; b=JZoUiFtdHe3FwgF2kNjjKtI/wxfXmDHgVOPBGCCgJxfUgm+lxRC6GxEaQTad/K7KQAlpwox3Aavrl9wjH+IsY8XhLBHOcINH9Gvd3iU8OgZBB/sEL6BYwguJunHA6xa5R6wb4V+JsubQma0ZJy/qWSsMEm88t8rizfP35nYvRt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773838055; c=relaxed/simple; bh=rmF/hGcZk9PZMeNhkxZlYz4cfZPNe57aCUwxf5TmoNU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cbd+ZTWn1XjLfBEYh/InYOiF/ZE8jWMsv644AAR/Vs+FK3YQtqI7kFKYzY9XikKqhtcHrC5r1hM1OEEL1vT88Hg9xbSAcY06SGReLKp21DGjof2KBS+C5yk5WhIhy2ROwfjf62Mcy+0h/M7bYhTvcvOVHPkfVlconF/beqJfze4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=lOkjOCaV; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none 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="lOkjOCaV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=/Kw4sGZJTIJhzCq7lQudRHchD1Meovz+F2jsknAiBS8=; b=lOkjOCaV4FLJUqHC04p/TXm61I n7G0/kUPHmwrcYA/2MJL+UHwUUpDGGWiFBgjYBmKqQe7o7N7BRve/8QWNw4jpxcFXhMCqITHRWn3u x5dNWn4+RPt3CeLyEvm9ER/j0PdcadHR7pEeDMV9rNPJksAphmJNWXsQEI0WeQLATPJ+y4odWGler oz+UZkO1fpsaroLOd9+fM87bqUWbA07UUr8smEMeCJIZl2zz7l+qrfUS+pE5drKTRzNw5UAEmRKSC EmoMZMa0YZMalRGeyc4TL7HxXNt/MCB7o8L8lipLUALAicSDQH3Ien5I3zwgXvf2tN+XYkQLJA+uW AvNrIyiA==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1w2qIx-0000000BDAE-2fy9; Wed, 18 Mar 2026 12:47:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 155CA3007C4; Wed, 18 Mar 2026 13:47:18 +0100 (CET) Date: Wed, 18 Mar 2026 13:47:18 +0100 From: Peter Zijlstra To: Xuewen Yan Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, tj@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, rui.zhang@intel.com, di.shen@unisoc.com, ke.wang@unisoc.com, xuewen.yan94@gmail.com Subject: Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util() Message-ID: <20260318124718.GC3738786@noisy.programming.kicks-ass.net> References: <20260318121755.16354-1-xuewen.yan@unisoc.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: <20260318121755.16354-1-xuewen.yan@unisoc.com> On Wed, Mar 18, 2026 at 08:17:55PM +0800, Xuewen Yan wrote: > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index bf948db905ed..20adb6fede2a 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8198,7 +8198,12 @@ unsigned long effective_cpu_util(int cpu, unsigned long util_cfs, > > unsigned long sched_cpu_util(int cpu) > { > - return effective_cpu_util(cpu, cpu_util_cfs(cpu), NULL, NULL); > + unsigned long util = scx_cpuperf_target(cpu); > + > + if (!scx_switched_all()) > + util += cpu_util_cfs(cpu); > + > + return effective_cpu_util(cpu, util, NULL, NULL); > } This puts the common case of no ext muck into the slow path of that static_branch. This wants to be something like: unsigned long sched_cpu_util(int cpu) { unsigned long util = cpu_util_cfs(cpu); if (scx_enabled()) { unsigned long scx_util = scx_cpuperf_target(cpu); if (!scx_switched_all()) scx_util += util; util = scx_util; } return effective_cpu_util(cpu, util, NULL, NULL); }