From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Zihuan Zhang <zhangzihuan@kylinos.cn>
Cc: "Rafael J . wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Krzysztof Kozlowski <krzk@kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Thierry Reding <thierry.reding@gmail.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
Eduardo Valentin <edubezval@gmail.com>,
Keerthy <j-keerthy@ti.com>, Ben Horgan <ben.horgan@arm.com>,
zhenglifeng <zhenglifeng1@huawei.com>,
Zhang Rui <rui.zhang@intel.com>, Len Brown <lenb@kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Beata Michalska <beata.michalska@arm.com>,
Fabio Estevam <festevam@gmail.com>,
Pavel Machek <pavel@kernel.org>, Sumit Gupta <sumitg@nvidia.com>,
Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Yicong Yang <yangyicong@hisilicon.com>,
linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, imx@lists.linux.dev,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 6/6] PM: EM: Use scope-based cleanup helper
Date: Fri, 5 Sep 2025 21:46:43 +0200 [thread overview]
Message-ID: <CAJZ5v0izu1_xVe_pGeJiXZqEXLxg_o30NkEjMiwzDgeU4mOGmA@mail.gmail.com> (raw)
In-Reply-To: <20250905132413.1376220-7-zhangzihuan@kylinos.cn>
On Fri, Sep 5, 2025 at 3:25 PM Zihuan Zhang <zhangzihuan@kylinos.cn> wrote:
>
> Replace the manual cpufreq_cpu_put() with __free(put_cpufreq_policy)
> annotation for policy references. This reduces the risk of reference
> counting mistakes and aligns the code with the latest kernel style.
>
> No functional change intended.
>
> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
> ---
> kernel/power/energy_model.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index ea7995a25780..5ec63b3e7d85 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -451,7 +451,6 @@ static void
> em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
> {
> struct em_perf_domain *pd = dev->em_pd;
> - struct cpufreq_policy *policy;
> int found = 0;
> int i, cpu;
>
> @@ -465,7 +464,7 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
> return;
> }
>
> - policy = cpufreq_cpu_get(cpu);
> + struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
> if (!policy) {
> dev_warn(dev, "EM: Access to CPUFreq policy failed\n");
> return;
> @@ -479,8 +478,6 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
> found++;
> }
>
> - cpufreq_cpu_put(policy);
> -
> if (!found)
> return;
>
The above changes are fine now and can be a separate patch.
> @@ -787,21 +784,19 @@ static void em_check_capacity_update(void)
>
> /* Check if CPUs capacity has changed than update EM */
> for_each_possible_cpu(cpu) {
But I'd prefer the code in this loop to be moved into a separate
function, in a separate patch, before the __free()-based
simplification of it.
> - struct cpufreq_policy *policy;
> struct em_perf_domain *pd;
> struct device *dev;
>
> if (cpumask_test_cpu(cpu, cpu_done_mask))
> continue;
>
> - policy = cpufreq_cpu_get(cpu);
> + struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
> if (!policy) {
> pr_debug("Accessing cpu%d policy failed\n", cpu);
> schedule_delayed_work(&em_update_work,
> msecs_to_jiffies(1000));
> break;
> }
> - cpufreq_cpu_put(policy);
>
> dev = get_cpu_device(cpu);
> pd = em_pd_get(dev);
> --
next prev parent reply other threads:[~2025-09-05 19:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 13:24 [PATCH v5 0/6] cpufreq: use __free() for all cpufreq_cpu_get() references Zihuan Zhang
2025-09-05 13:24 ` [PATCH v5 1/6] arm64: topology: Use scope-based cleanup helper Zihuan Zhang
2025-09-05 13:24 ` [PATCH v5 2/6] ACPI: processor: thermal: " Zihuan Zhang
2025-09-05 20:17 ` Rafael J. Wysocki
2025-09-08 9:16 ` Zihuan Zhang
2025-09-08 17:44 ` Rafael J. Wysocki
2025-09-08 17:55 ` Rafael J. Wysocki
2025-09-05 13:24 ` [PATCH v5 3/6] cpufreq: intel_pstate: " Zihuan Zhang
2025-09-05 13:31 ` Rafael J. Wysocki
2025-09-05 13:24 ` [PATCH v5 4/6] PM / devfreq: " Zihuan Zhang
2025-09-05 19:39 ` Rafael J. Wysocki
2025-09-05 13:24 ` [PATCH v5 5/6] drm/i915: " Zihuan Zhang
2025-09-05 13:24 ` [PATCH v5 6/6] PM: EM: " Zihuan Zhang
2025-09-05 19:46 ` Rafael J. Wysocki [this message]
2025-09-05 17:49 ` [PATCH v5 0/6] cpufreq: use __free() for all cpufreq_cpu_get() references Borislav Petkov
2025-09-08 9:12 ` Zihuan Zhang
2025-09-08 9:24 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJZ5v0izu1_xVe_pGeJiXZqEXLxg_o30NkEjMiwzDgeU4mOGmA@mail.gmail.com \
--to=rafael@kernel.org \
--cc=airlied@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=beata.michalska@arm.com \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=cw00.choi@samsung.com \
--cc=daniel.lezcano@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=edubezval@gmail.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=intel-gfx@lists.freedesktop.org \
--cc=j-keerthy@ti.com \
--cc=jani.nikula@linux.intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lukasz.luba@arm.com \
--cc=mpe@ellerman.id.au \
--cc=myungjoo.ham@samsung.com \
--cc=pavel@kernel.org \
--cc=ptsm@linux.microsoft.com \
--cc=rodrigo.vivi@intel.com \
--cc=rui.zhang@intel.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=simona@ffwll.ch \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sudeep.holla@arm.com \
--cc=sumitg@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=tursulin@ursulin.net \
--cc=viresh.kumar@linaro.org \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=zhangzihuan@kylinos.cn \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).