From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADD21287252; Wed, 27 Aug 2025 09:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756286278; cv=none; b=n2d+cg45hAZiFojIwdqlVHknhNW8NFKheAF1AJEmRuVT1zyCyfX/je+bN6z3QbFxgGYofuDCjErIk4Z44UUE4Cd0SHYae2DJy7eGPGqtuT2dxVWNgp2QuhF7DCsnqnPX8LSBEZu0rqyR5UQFwyQw1E6Xuh17TFPPS0pf0HASxhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756286278; c=relaxed/simple; bh=D6tI8dFPhQO9vi/pFTz+Fl4xZHDFVpijJJzgtBdp4kY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hhqTDRSFlSB5NtvohbFtanbo9B675qZNiNwpPajoRqQnS9inEjyMJHJeFIYFvrVL409DevK+w4aO2HnbPmH+VRqZGcIUZ1ETsBvzEppbPGmMh9UrwpHLtzxAsmd+G71IichAOxtNrv6OldgUVoJkHDYbJfULhL6IAlci9A5js2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com; spf=none smtp.mailfrom=foss.arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=foss.arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A7AA01655; Wed, 27 Aug 2025 02:17:46 -0700 (PDT) Received: from bogus (unknown [10.57.57.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 588C63F738; Wed, 27 Aug 2025 02:17:41 -0700 (PDT) Date: Wed, 27 Aug 2025 10:17:18 +0100 From: Sudeep Holla To: Ben Horgan Cc: Zihuan Zhang , Sudeep Holla , "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , Will Deacon , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Markus Mayer , Florian Fainelli , Srinivas Pandruvada , Madhavan Srinivasan , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Daniel Lezcano , Sascha Hauer , Shawn Guo , Eduardo Valentin , Keerthy , Matthias Brugger , AngeloGioacchino Del Regno , zhenglifeng , "H . Peter Anvin" , Zhang Rui , Len Brown , Nicholas Piggin , Christophe Leroy , Lukasz Luba , Pengutronix Kernel Team , Beata Michalska , Fabio Estevam , Pavel Machek , Sumit Gupta , Prasanna Kumar T S M , Yicong Yang , linux-pm@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, linux-acpi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/18] arm64: topology: Use __free(put_cpufreq_policy) for policy reference Message-ID: <20250827-vegan-blond-marmot-eabf13@sudeepholla> References: <20250827023202.10310-1-zhangzihuan@kylinos.cn> <20250827023202.10310-2-zhangzihuan@kylinos.cn> <70f4c2ce-1dbd-4596-af78-bca1cdbbb581@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <70f4c2ce-1dbd-4596-af78-bca1cdbbb581@arm.com> On Wed, Aug 27, 2025 at 09:30:13AM +0100, Ben Horgan wrote: > Hi Zihuan, > > On 8/27/25 03:31, Zihuan Zhang 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 > > --- > > 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..e3cb6d54f35b 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); > Based on the guidance, in include/linux/cleanup.h, I would expect the > assignment to be done on this line. > > "...the recommendation is to always define and assign variables in one > * statement and not group variable definitions at the top of the > * function when __free() is used." > Agreed. I did something similar recently and there was a code path where variable wasn't initialised and ended up with freeing unassigned pointer. So it is more than just a recommendation sometimes. -- Regards, Sudeep