From nobody Sun Feb 8 09:40:43 2026 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 E73C422155E; Wed, 16 Apr 2025 18:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744827177; cv=none; b=WvMYoOVzQhoEwGyVYlw6oGwtFrSWtqhKZ/obYMqoteiBzOGzMMEC14Jq/ricKyfypHvmCfV/pGbYE1CvpTN5DKizAmQ2LWKHrztsotVN28777m/B61x4jwFte5H24rs1uFVfien9j7A5Z78vVKUXaLFUpEhrGEDYzaFFV+9vcck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744827177; c=relaxed/simple; bh=iQKshVydollss9hMFH/JZu600SfS0P7cj3iiIysqwAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RY8DpAFcuCAx26Pz1fPXtMMaAoVcCv+cG3FGpv8KBKIE5cPka0KFj0D4fYDq2KcETbZczdwMZLshX3gaahUV61Q8+a3F7hFvPYWlisYG1aOMCyHt1Gu98eiWBAG7aPqJiFMmRIPJXri+TunrLBIsJOZUS2sPBobxKFfkYxzBr+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=YbwT+bgR; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="YbwT+bgR" Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 8450E662715; Wed, 16 Apr 2025 20:12:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1744827173; bh=iQKshVydollss9hMFH/JZu600SfS0P7cj3iiIysqwAQ=; h=From:Subject:Date; b=YbwT+bgRt/bKqpCoFLZViC9RyILIuDQLDJaTHohcgWXixwvNydqMC3dRQh4Re05ej Pm9RM+J/cMiK1yC6gzaJNCsK39BTAveURC5xedn2q7xnGFLIcOco335vFv9wH1FfMH SGAcJ3RMi2uewl1Al6EEOvI3gCjb3ZbhtdGjwUT0PTJlWIMc0on9rejifzmL4CP7Ln QstDDHaMTUFGryCd27t55PrhSYdpAGtMtEsSl4D2rUV1yypF46PVzR2E89r0bqMr07 aPl7+mGCL8/Hm07ghtYbOokJsUd87en2zDxkROacjHMjHj/08lvleS+KZ6gfkZKlLV a3Iydd89oX0Xg== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Lukasz Luba , Peter Zijlstra , Srinivas Pandruvada , Dietmar Eggemann , Morten Rasmussen , Vincent Guittot , Ricardo Neri , Pierre Gondois , Christian Loehle Subject: [RFT][PATCH v1 1/8] cpufreq/sched: schedutil: Add helper for governor checks Date: Wed, 16 Apr 2025 19:48:16 +0200 Message-ID: <10640940.nUPlyArG6x@rjwysocki.net> In-Reply-To: <3344336.aeNJFYEL58@rjwysocki.net> References: <3344336.aeNJFYEL58@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvvdejtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomheprhhjfiesrhhjfiihshhotghkihdrnhgvthdpnhgspghrtghpthhtohepuddupdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdh X-DCC--Metrics: v370.home.net.pl 1024; Body=11 Fuz1=11 Fuz2=11 Content-Type: text/plain; charset="utf-8" From: Rafael J. Wysocki Add a helper for checking if schedutil is the current governor for a given cpufreq policy and use it in sched_is_eas_possible() to avoid accessing cpufreq policy internals directly from there. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Christian Loehle --- v0.3 -> v1 * Change the name of the new function to sugov_is_governor(). This patch is regarded as a cleanup for 6.16. --- include/linux/cpufreq.h | 9 +++++++++ kernel/sched/cpufreq_schedutil.c | 9 +++++++-- kernel/sched/sched.h | 2 -- kernel/sched/topology.c | 6 +++--- 4 files changed, 19 insertions(+), 7 deletions(-) --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -650,6 +650,15 @@ struct cpufreq_governor *cpufreq_default_governor(void); struct cpufreq_governor *cpufreq_fallback_governor(void); =20 +#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL +bool sugov_is_governor(struct cpufreq_policy *policy); +#else +static inline bool sugov_is_governor(struct cpufreq_policy *policy) +{ + return false; +} +#endif + static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *poli= cy) { if (policy->max < policy->cur) --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -630,7 +630,7 @@ =20 /********************** cpufreq governor interface *********************/ =20 -struct cpufreq_governor schedutil_gov; +static struct cpufreq_governor schedutil_gov; =20 static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *poli= cy) { @@ -909,7 +909,7 @@ WRITE_ONCE(sg_policy->limits_changed, true); } =20 -struct cpufreq_governor schedutil_gov =3D { +static struct cpufreq_governor schedutil_gov =3D { .name =3D "schedutil", .owner =3D THIS_MODULE, .flags =3D CPUFREQ_GOV_DYNAMIC_SWITCHING, @@ -927,4 +927,9 @@ } #endif =20 +bool sugov_is_governor(struct cpufreq_policy *policy) +{ + return policy->governor =3D=3D &schedutil_gov; +} + cpufreq_governor_init(schedutil_gov); --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3509,8 +3509,6 @@ return static_branch_unlikely(&sched_energy_present); } =20 -extern struct cpufreq_governor schedutil_gov; - #else /* ! (CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL) */ =20 #define perf_domain_span(pd) NULL --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -213,7 +213,7 @@ { bool any_asym_capacity =3D false; struct cpufreq_policy *policy; - struct cpufreq_governor *gov; + bool policy_is_ready; int i; =20 /* EAS is enabled for asymmetric CPU capacity topologies. */ @@ -258,9 +258,9 @@ } return false; } - gov =3D policy->governor; + policy_is_ready =3D sugov_is_governor(policy); cpufreq_cpu_put(policy); - if (gov !=3D &schedutil_gov) { + if (!policy_is_ready) { if (sched_debug()) { pr_info("rd %*pbl: Checking EAS, schedutil is mandatory\n", cpumask_pr_args(cpu_mask));