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 64F0D21B1BF for ; Thu, 19 Mar 2026 11:12:59 +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=1773918781; cv=none; b=F9mkdRCPSpaRs7eES228ocauzSVsy5D/y8DjG5zkrYy/y6v+rI9023tlBGeXIcukts93/qXu35a88TgDGUbTtwRngDJH219uziddDt1sov0Z03ZKodQEbO22lmXUlCfsvYB5Ubbrc6DyBUPWFfAajmcnERUbeR8lnUVhQkUeQLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773918781; c=relaxed/simple; bh=380nvrs7aZBLbefJDxk4FP1ufyLbRITJU/9hrKMiZoA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d8Jbm6qErvO/7388HZQg7sAc8dzpR7+0qfmMH82vnrbJ/DB4maN3/dmjZd8BcIzKJ+FEnj/eTUYdZQEyniD0Aa2fBgCN4CN/QKMHlKgRR6UdsXWByEVBzct3JMSIsUwUbwHyrnXAD1JX+XRLK3EfK20IT1YpDKysuRzRYsi2cW8= 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=FHV+zMSL; 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="FHV+zMSL" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=sjnIom670Xcouis/V+3CE7NGDyrclX2tyq7vp958Jqw=; b=FHV+zMSL99Pr1IFn2UTYkiaWyU rr9FlrVNI/+Hpjym2wqPG5uhPaIZUYWCpOve2AJsBsoHlG2x6Y52BCOEYMKxZGMnGveJIamq8lyxk PTuMcH7rF4ljx+eq6oQv5rSzHrjig7Aoqjrb5FE0Rasad++8Z342TaPWDs82R/2m6KKcT4pWx5gTQ Tfrw08wfgcRQnxtWjPSI9f6JM7BaHm3Movj33mssA/9+UDy3GLPhO6mJjX7lsZZZEr+5j1niE36cB hEiCGSs67+MsYrvqsFLSKLM7xliFlx+uxRa5U2xNhW7BN29+qSdI0xLOdbtfiG+OvBDl5jkMqbjeM otJf1AWw==; 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 1w3BIx-0000000DKZQ-0rlz; Thu, 19 Mar 2026 11:12:43 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 02C9A300578; Thu, 19 Mar 2026 12:12:42 +0100 (CET) Date: Thu, 19 Mar 2026 12:12:41 +0100 From: Peter Zijlstra To: Uros Bizjak Cc: Tejun Heo , 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, Marco Elver Subject: Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util() Message-ID: <20260319111241.GG3738786@noisy.programming.kicks-ass.net> References: <20260318121755.16354-1-xuewen.yan@unisoc.com> <20260318124718.GC3738786@noisy.programming.kicks-ass.net> <20260319090240.GS3738010@noisy.programming.kicks-ass.net> <20260319102655.GF3738786@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Mar 19, 2026 at 12:02:29PM +0100, Uros Bizjak wrote: > On Thu, Mar 19, 2026 at 11:27 AM Peter Zijlstra wrote: > > > > On Thu, Mar 19, 2026 at 11:01:03AM +0100, Uros Bizjak wrote: > > > On Thu, Mar 19, 2026 at 10:02 AM Peter Zijlstra wrote: > > > > > > > That fastpath is definitely better; the slowpath is worse, but that is > > > > in part because the compilers are stupid and cannot eliminate > > > > static_branch(). > > > > > > asm gotos are implicitly volatile because they are control flow > > > primitives. The compiler will *not* remove them. > > > > Yes, but I want ponies ;-) > > > > if (static_branch_unlikely(&foo)) { > > if (static_branch_unlikely(&foo)) { > > /* A */ > > } else { > > /* B */ > > } > > /* C */ > > } > > > > Is a very common occurence. And we all know this really should be: > > > > if (static_branch_unlikely(&foo)) { > > /* A */ > > /* C */ > > } > > > > So how can we make this happen? IMO marking those functions __const > > should tell the compiler that yes, it can elimintate them. > > Huh, __const promises that the function does not access global memory > and that the function does not have side effects other than returning > a value. asm volatile inside the __const function creates a side > effect, so removing function calls would be considered a > misoptimization. Probably this could lead to undefined behavior in > terms of what the compiler expects from a __const function. So since the whole function reduces to a single branch or nop, it does not in fact access memory or have side effects, right? (and there is still __pure, for if we somehow consider the key governing the text patching to be an 'access' in this case) > > You should not try and protect the user. If they use __const > > incorrectly, they get to keep the pieces and all that. > > I'm afraid that here the user wants the "__const with only partial > properties of __const" function, where the compiler does not know what > the user really wants. Well, clearly I'm not a compiler person :-) I just want to be able to tell the compiler that it can collapse these branches. Do you have another option that would be less offensive to compiler folks such as yourself?