From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 016EB12CDBE for ; Thu, 19 Mar 2026 01:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773882525; cv=none; b=oFQ4LGDt8pE21R0UmEmxO8IlnfMnjarlCbWWgpT5Q6qsYLOy4Es6aZXK2NdiU1nHQ9ErJB7oKQgXEJe68h++2Ov73fOzFvKJ3bxE1doujBbYPZ4HRMyAF3e7ClhlV7odVwKPYWvU4FIGUfbPPbR18GiC33dDEIDJh60jeb1I0Ts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773882525; c=relaxed/simple; bh=8jw9WNjcAr3Mpdy7Xg8K9ph5CKl3dVD1si4s0BrWt+M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L39cu6MMZT2oleufsFSVo+ARPS2Houp82/XC412ryU5NTaKxgI0o9bLV6Q/a/3WzHDq1hvPQXzhH1ZVWaBy2KnOy7J8YLEhSRRSZawlcvBEUVdBJD2XIueMfIsXDToa+mjUVXNm93Hp9z1AVXMb/bKNwZjlrKLFRcEMGYEQHxUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZIBz/Oy/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZIBz/Oy/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67993C19421; Thu, 19 Mar 2026 01:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773882524; bh=8jw9WNjcAr3Mpdy7Xg8K9ph5CKl3dVD1si4s0BrWt+M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZIBz/Oy/9EAIToyeTTBh/IqwFv1pE+mFhXOEZG+5Dbp6OEagyBc2Z1KR4qW2/6KeU 39E2OBVjEG1qiLXvRp9Sc6lzxgCuEFcx6hYSHQzM5D4Vmjbfic3QU7BiU4l4b6N0q6 Ww5nBw04aE9e5yFXzdPQgkANJ64WOPKosNstLOgN3trdlebtcv44IxsjRgipHYe/Jl Ki9Cvg8vM3Xrvj7XstT4wJoFVurNRxS0qq7zmCEUOgYEcPqJ2XR11j+6NFVQKPjuO2 1M9n66HeqVzeVZSGq0SIqLOaEBAI/Sc2hIXIkIXKwY7CTxMkjKi6+eIwUmJK/FzPnd lmj6FV7fsdJ2A== Date: Wed, 18 Mar 2026 15:08:43 -1000 From: Tejun Heo To: Peter Zijlstra Cc: Xuewen Yan , mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.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: References: <20260318121755.16354-1-xuewen.yan@unisoc.com> <20260318124718.GC3738786@noisy.programming.kicks-ass.net> 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: <20260318124718.GC3738786@noisy.programming.kicks-ass.net> On Wed, Mar 18, 2026 at 01:47:18PM +0100, Peter Zijlstra wrote: > 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); > } scx_switched_all() is an unlikely static branch just like scx_enabled() and scx_cpuperf_target() has scx_enabled() in it too, so the difference for the fair path between the two versions is two noop run-throughs vs. one. Either way is fine but it is more code for likely no discernible gain. Thanks. -- tejun