From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F28E3803C1 for ; Thu, 19 Mar 2026 11:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.167.42 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773919206; cv=pass; b=lTjlbtdugye7fWQMNNJV20pCTIge7/EBDHTDJ3CMiQ36UcmIUXKMXFqzSGIsR5zHBHH0eTWO6IVYdzEyiGJa3kpyXrtZClvg//lKSYkxOeN1XfFhDnHNSB5TnkXsnkP6OKiBK/xaXSXp1zhPoxMUSW1QN4wL1ESJc1M5Br0ktDU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773919206; c=relaxed/simple; bh=AD1vViFSJU3BxMV4aYyR3B8iYG3VAj55M422w8JwxCc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Uk8QfPIZqF7N/EzLlMF4NAHvti8dHZF/L4PqE1A/Q2J/WEz+h59eSrVqYGzlAUw4BMr64XmQ0HKcFMWmzJifGCq7IAf1FxAy+2AFL6G5NN95ahLofb+VAuknYU3bl19pFHOyXV9u1j29NMUHW5GyjmipzY5Hwrk+ypy+jkCqino= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bFAlJPF2; arc=pass smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bFAlJPF2" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5a278e0f7f6so1075369e87.0 for ; Thu, 19 Mar 2026 04:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773919203; cv=none; d=google.com; s=arc-20240605; b=fwdkXG09h3C2G4fqnq2HX0TN+Dqo9XVtVTxZnxJItROZeoV0YvP8Tl1K0R0Jf1h3RO ft55wEaDJlfDSa/k+4l4GCyFqGVqO+QtCZfdihOD7GyCuX9aEJaEvbvGWcjvYi9WZAjK g8WqQGoNHCRHpUI+JOx3BQvv/nRgMn5OBZAHe8O2DIvi/V9NYu9/NfeDqsoxvkM4uOuQ Sx6VugKEUJIG2hqb7Fdoe5MFa9Ml2H6nTu6s6vtBkJ/ojOQGbDRaNnoBdGOGH6bXgrPI KZc9/gnOtToW0u5KpIwvCwKsCQX0LoFKGJbSzUac1gga1PZsEQ5u0VbF+6lhG3xW0taC RnBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=etLvvEcLFwo8e2RPE/0Ib2H5EMAL0o/cEnHCWkidN48=; fh=L47WRMpOZaWiaRx/0MYLC4mQ/C95EygrIZoLc+JQ9Ag=; b=HVn1UFb5upV4Rcgwd9IyfB+j/BHJViopjflni0OGrlg9bodAeDG2N5Aj+U+ZQXNt3f GX4vOTv1ViWa/QB7r7gHadLl9WwGdOm9jSWd8RM3T1t9EHwUdrHyyshrluIKk5YDRJ8y V/scHgDZm+h9lTF/MR3Adnc44/unLrmccxqZQeXpe/sRWH1NGeKKSXpCqqerq8REdxmq s4+uQ+704pMkkFBWzDBnLJtqndFUBxbkgBaO3AETNepcHXkHOB6lYqpLFrxWaw5PvEMQ lMZ4JKqmUysV1TI6JQZw0uNMv+wXFQjowkI6S4JzIttnSem7X9S9Xd4I8eAyLZW0oXEr 7EoA==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773919203; x=1774524003; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=etLvvEcLFwo8e2RPE/0Ib2H5EMAL0o/cEnHCWkidN48=; b=bFAlJPF2IF3M9W3Cg9Lg31oFdKKmeIhwkVf9MiX4ptR6VQWILEZUUMuLuifTli8OoT yf/0PVcIaPZsvf4nZSxZwjmfszQRAeklRjmTxjlcDY0sgpvQNwglTCzb0E7Kt3BUgBjA LDp/eGVQfSyGb+B34kAVoD3SZYZcC1vMYhP368TX/Ym7lrFbVrHMSAJAoc81RrecPqsE 3Z6xNM1lFH7HnoTFAvTAxfg21YhEnChdgfiHfI9Ywdn84cQA5nvzbjIwE5oKVL+gm9bi iN9pz5unWddjO/D/R8SqkaEJhjL2+vfNqVs5/jHCMfYituOVAfj18wPhRMWKQ7ZkHB/D nBbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773919203; x=1774524003; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=etLvvEcLFwo8e2RPE/0Ib2H5EMAL0o/cEnHCWkidN48=; b=Cai93c8S+jGydAd76gsZIxi2S0+gK6bVnb+MxOfn63tC2pZdgWrfE5PAxQN91nKmJ1 mm6dBf70MIvVthrervZbIr36yHScIQ947BdB8AbnS7bP+LKC6T7jNzbfrwBpc4JsaJf9 6J+2G0qrL12DuRNCPablYa6ymUefhMDMpZeVuleUq+AngB6Y3DmNfEeZtRnwtOB/toyW OcfS5hDjGhkIRcYlRUN5Dz5fa4dcmXwGVcNNEYQrRD/yAWs75hGUlObm45sDC8oRhO0Z Mb4sP5aOlGU6cSV5t2Tm1AF3gOF6gTVOopZx9S3Ku8WYoO8An8ciww449byj9PrPzZEi cBvA== X-Forwarded-Encrypted: i=1; AJvYcCXDl8zbOiRp5fD4Qi1avDXq23f/ZzpZqbc3ynGDtJzPNKdcZN2JKnmhk0n6pjqFs+WBFGKLBxKW2SNfdnk=@vger.kernel.org X-Gm-Message-State: AOJu0YxPzSUriBsLNtYIA58cN0cSsLtAzCBc5APAXAtZnOBe472QkccX /dOJkV8AGu6o1rQfGePEd8yRFyKqDjf0ah/Zg50Kq0eK1u0lRqcOwRWxV11gOa9Ds5YtXjCGYL4 8rOkF5uJ2L8zSBCl3PzFGLN4touzRate9OOJkHhU= X-Gm-Gg: ATEYQzyjSi89IaYk02io0bN2lH70Fkp2aXlMenfey7LtcI7kx8uvllgibm1ubT6bAu3 Y/68c0AYB5yN5Vv/S9BWSq8zBtTsv2lburyT5XhWviRC42ej0raRzE8vh038jiJNnNnb43ITz6L aYXG6+6JKKi/kYEZqUrcfuT1r733azJbohpZ/71Gq2k0n73a2S70H2ITn46Jp9zueWOoVGERNoo MKKWJygIwGEwbmA6whpFHBEFVQE0vIQbyRDDWaGTT/pIAaLzHHvqXYZ7qgSR1MZ7IWhtsNlySsc rd7cYPa8F06BNv3PbOuD1ZlaXIUUa35Hn9yi2VIfaC40yUOgwF1E8KWumpAQOG+y34bS4hl7QEB BNApoWbKCkY0D+Ju85jSPseau+dioYwKV0XE= X-Received: by 2002:a05:6512:61c3:20b0:5a1:2e82:8dc0 with SMTP id 2adb3069b0e04-5a27957db5emr2083146e87.2.1773919202455; Thu, 19 Mar 2026 04:20:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> <20260319111241.GG3738786@noisy.programming.kicks-ass.net> In-Reply-To: <20260319111241.GG3738786@noisy.programming.kicks-ass.net> From: Uros Bizjak Date: Thu, 19 Mar 2026 12:19:50 +0100 X-Gm-Features: AaiRm50s9CQrNfZwhD0PL0D-yAxuz5giWOdjtUT-_yncbt-uQiWy8w9126UgCr4 Message-ID: Subject: Re: [RFC PATCH] sched: Add scx_cpuperf_target in sched_cpu_util() To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 19, 2026 at 12:12=E2=80=AFPM Peter Zijlstra wrote: > > On Thu, Mar 19, 2026 at 12:02:29PM +0100, Uros Bizjak wrote: > > On Thu, Mar 19, 2026 at 11:27=E2=80=AFAM Peter Zijlstra wrote: > > > > > > On Thu, Mar 19, 2026 at 11:01:03AM +0100, Uros Bizjak wrote: > > > > On Thu, Mar 19, 2026 at 10:02=E2=80=AFAM Peter Zijlstra wrote: > > > > > > > > > That fastpath is definitely better; the slowpath is worse, but th= at 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? But there is "asm goto" inside, this tells the compiler that there is a side effect, no matter what is written in the asm template. Even 'asm volatile ("nop");' inside function declares a side effect. > (and there is still __pure, for if we somehow consider the key governing > the text patching to be an 'access' in this case) __pure function also can't have side effects. > > > 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? I don't see any in this case (mixing volatiles with __const or __pure attribute), but please ask on gcc@ mailing list, if there is any other option I have missed. Uros.