lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250905103828.0000726c@huawei.com>
Date: Fri, 5 Sep 2025 10:38:28 +0100
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Zihuan Zhang <zhangzihuan@...inos.cn>
CC: "Rafael J . wysocki" <rafael@...nel.org>, Viresh Kumar
	<viresh.kumar@...aro.org>, Catalin Marinas <catalin.marinas@....com>, "Will
 Deacon" <will@...nel.org>, Borislav Petkov <bp@...en8.de>, Dave Hansen
	<dave.hansen@...ux.intel.com>, Srinivas Pandruvada
	<srinivas.pandruvada@...ux.intel.com>, Michael Ellerman <mpe@...erman.id.au>,
	Krzysztof Kozlowski <krzk@...nel.org>, Alim Akhtar <alim.akhtar@...sung.com>,
	Thierry Reding <thierry.reding@...il.com>, MyungJoo Ham
	<myungjoo.ham@...sung.com>, Kyungmin Park <kyungmin.park@...sung.com>,
	Chanwoo Choi <cw00.choi@...sung.com>, "Jani Nikula"
	<jani.nikula@...ux.intel.com>, Rodrigo Vivi <rodrigo.vivi@...el.com>, Tvrtko
 Ursulin <tursulin@...ulin.net>, "David Airlie" <airlied@...il.com>, Simona
 Vetter <simona@...ll.ch>, Daniel Lezcano <daniel.lezcano@...nel.org>, Sascha
 Hauer <s.hauer@...gutronix.de>, "Shawn Guo" <shawnguo@...nel.org>, Eduardo
 Valentin <edubezval@...il.com>, Keerthy <j-keerthy@...com>, Ben Horgan
	<ben.horgan@....com>, zhenglifeng <zhenglifeng1@...wei.com>, Zhang Rui
	<rui.zhang@...el.com>, Len Brown <lenb@...nel.org>, Lukasz Luba
	<lukasz.luba@....com>, "Pengutronix Kernel Team" <kernel@...gutronix.de>,
	Beata Michalska <beata.michalska@....com>, Fabio Estevam
	<festevam@...il.com>, Pavel Machek <pavel@...nel.org>, "Sumit Gupta"
	<sumitg@...dia.com>, Prasanna Kumar T S M <ptsm@...ux.microsoft.com>, Sudeep
 Holla <sudeep.holla@....com>, Yicong Yang <yangyicong@...ilicon.com>,
	<linux-pm@...r.kernel.org>, <linux-acpi@...r.kernel.org>,
	<linuxppc-dev@...ts.ozlabs.org>, <linux-arm-kernel@...ts.infradead.org>,
	<intel-gfx@...ts.freedesktop.org>, <dri-devel@...ts.freedesktop.org>,
	<imx@...ts.linux.dev>, <linux-omap@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 01/10] arm64: topology: Use scope-based cleanup
 helper

On Wed,  3 Sep 2025 21:17:24 +0800
Zihuan Zhang <zhangzihuan@...inos.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@...inos.cn>
Diff is being slightly annoying in not quite showing enough context
to see that it is fine to release this at the end of scope.
What you have done looks correct to me but there is a further
potential cleanup

	for_each_cpu_wrap(ref_cpu, policy->cpus, cpu + 1) {
		if (ref_cpu == start_cpu) {
			/* Prevent verifying same CPU twice */
			ref_cpu = nr_cpu_ids;
			break;
//here, might as well return -EAGAIN as only thing in this block
//and now no advantage in sharing the exit path with the one that
//says we never matched the next condition.
		}
		if (!idle_cpu(ref_cpu))
			break;
		}

Either way I'm fine with this.
Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>

> ---
>  arch/arm64/kernel/topology.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> index 5d07ee85bdae..0eebd3492669 100644
> --- a/arch/arm64/kernel/topology.c
> +++ b/arch/arm64/kernel/topology.c
> @@ -307,17 +307,16 @@ int arch_freq_get_on_cpu(int cpu)
>  		 */
>  		if (!housekeeping_cpu(cpu, HK_TYPE_TICK) ||
>  		    time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP_MS))) {
> -			struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
> +			struct cpufreq_policy *policy __free(put_cpufreq_policy) =
> +				cpufreq_cpu_get(cpu);
>  			int ref_cpu;
>  
>  			if (!policy)
>  				return -EINVAL;
>  
>  			if (!cpumask_intersects(policy->related_cpus,
> -						housekeeping_cpumask(HK_TYPE_TICK))) {
> -				cpufreq_cpu_put(policy);
> +						housekeeping_cpumask(HK_TYPE_TICK)))
>  				return -EOPNOTSUPP;
> -			}
>  
>  			for_each_cpu_wrap(ref_cpu, policy->cpus, cpu + 1) {
>  				if (ref_cpu == start_cpu) {
> @@ -329,8 +328,6 @@ int arch_freq_get_on_cpu(int cpu)
>  					break;
>  			}
>  
> -			cpufreq_cpu_put(policy);
> -
>  			if (ref_cpu >= nr_cpu_ids)
>  				/* No alternative to pull info from */
>  				return -EAGAIN;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ