From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 14CEF1C01; Thu, 28 Aug 2025 02:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756348393; cv=none; b=qdQwRnG7ZRTW0FD4CrqYNHyD5vx2DxFGZSPQocFhga+M1BL3SiH7TfC+VQgo5ha3UhlEM5v4q14tne4LQMnCW7cO/s4jd9mFFhPyCelaH0Fx5vuNq1B8k0ofEJXTQpR5a8qcxHImoGdT+ePtLjUV4UCRZv9CgfCfng6ajpc/zuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756348393; c=relaxed/simple; bh=a96c67ue2iadTZlK8+Yj568Jo90zgVFy17g6x/9BkaU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QlKfrw6q4GgAs4aILQxDp08sveGD9zeO5KLfKp05I/qKSoTNejiwI5wwR7ZHhWFLBh1qzmcvqyHgWVf89O4u21KX5KHASHiLrzPm9Qdoj7XwVGGIz+AkbYp78C5CkVl004fUgn5wj3Pfv7mpP4HtfczyZFBiTw6gwo3uki0IeMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 502860d683b711f0b29709d653e92f7d-20250828 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:bbfdf95e-1728-4506-9bc0-05a18e21652f,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6493067,CLOUDID:f93684e576c78dc40936662dca05dad7,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:80|81|82|83|102,TC:nil,Content:0|52,EDM: -3,IP:nil,URL:99|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA :0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULS X-UUID: 502860d683b711f0b29709d653e92f7d-20250828 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 469337678; Thu, 28 Aug 2025 10:32:59 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4C11EE008FAC; Thu, 28 Aug 2025 10:32:59 +0800 (CST) X-ns-mid: postfix-68AFBFDB-172902359 Received: from [172.25.120.24] (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id ADF7BE008FAB; Thu, 28 Aug 2025 10:32:47 +0800 (CST) Message-ID: <6f6c1e35-101d-4ef1-ac6e-5db337ccdd84@kylinos.cn> Date: Thu, 28 Aug 2025 10:32:46 +0800 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/18] arm64: topology: Use __free(put_cpufreq_policy) for policy reference To: Sudeep Holla , Ben Horgan Cc: "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 References: <20250827023202.10310-1-zhangzihuan@kylinos.cn> <20250827023202.10310-2-zhangzihuan@kylinos.cn> <70f4c2ce-1dbd-4596-af78-bca1cdbbb581@arm.com> <1756341899099493.57.seg@mailgw.kylinos.cn> From: Zihuan Zhang In-Reply-To: <1756341899099493.57.seg@mailgw.kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable =E5=9C=A8 2025/8/27 17:17, Sudeep Holla =E5=86=99=E9=81=93: > 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/topolog= y.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_SAM= PLE_EXP_MS))) { >>> - struct cpufreq_policy *policy =3D 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 wher= e > variable wasn't initialised and ended up with freeing unassigned pointe= r. > So it is more than just a recommendation sometimes. > Thanks a lot for your suggestions. We are also considering introducing a WITH_CPUFREQ_POLICY wrapper to=20 encapsulate the cpufreq_cpu_get/put usage, so that the release order=20 won=E2=80=99t be accidentally changed. Link:=20 https://lore.kernel.org/all/874d821e-8ea3-40ac-921b-c19bb380a456@kylinos.= cn/ Do you have any suggestions or preferences on this direction?