From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67E27CA0EFF for ; Wed, 27 Aug 2025 21:59:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A572C10E6C1; Wed, 27 Aug 2025 21:59:14 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by gabe.freedesktop.org (Postfix) with ESMTPS id A8BD810E3C7; Wed, 27 Aug 2025 09:22:07 +0000 (UTC) X-UUID: 49268046832711f0b29709d653e92f7d-20250827 X-CID-CACHE: Type:Local,Time:202508271655+08,HitQuantity:1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45, REQID:131c9df4-100a-4b04-9d4b-a39892c7cfc1, 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:b5736a825b981a30f067edd239e3633a, BulkI D:nil,BulkQuantity:0,Recheck:0,SF:80|81|82|83|102,TC:nil,Content:0|52,EDM: -3,IP:nil,URL:0,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 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 49268046832711f0b29709d653e92f7d-20250827 Received: from mail.kylinos.cn [(10.44.16.175)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 56545549; Wed, 27 Aug 2025 17:22:00 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 93D77E008FAB; Wed, 27 Aug 2025 17:21:59 +0800 (CST) X-ns-mid: postfix-68AECE37-425912845 Received: from [172.25.120.24] (unknown [172.25.120.24]) by mail.kylinos.cn (NSMail) with ESMTPA id 41835E008FA3; Wed, 27 Aug 2025 17:21:51 +0800 (CST) Message-ID: <5081cf6c-6e2a-4a6f-841a-e4a21c35cb21@kylinos.cn> Date: Wed, 27 Aug 2025 17:21:50 +0800 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: Ben Horgan , "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 Cc: 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 , Sudeep Holla , 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> <57016487-0fee-4821-9cd5-d6e5fe80a65d@kylinos.cn> From: Zihuan Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Wed, 27 Aug 2025 21:59:14 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, =E5=9C=A8 2025/8/27 17:12, Ben Horgan =E5=86=99=E9=81=93: > Hi Zihuan, > > On 8/27/25 09:55, Zihuan Zhang wrote: >> Hi, >> >> =E5=9C=A8 2025/8/27 16:30, Ben Horgan =E5=86=99=E9=81=93: >>> 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 >>>> --- >>>> =C2=A0 arch/arm64/kernel/topology.c | 9 +++------ >>>> =C2=A0 1 file changed, 3 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topolo= gy.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) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!houseke= eping_cpu(cpu, HK_TYPE_TICK) || >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 time_is_before_jiffies(last_update + >>>> msecs_to_jiffies(AMU_SAMPLE_EXP_MS))) { >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = struct cpufreq_policy *policy =3D cpufreq_cpu_get(cpu); >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = 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 on= e >>> =C2=A0 * statement and not group variable definitions at the top of = the >>> =C2=A0 * function when __free() is used." >> >> The reason I split the assignment into multiple lines is because >> scripts/checkpatch.pl gave a warning about the line being too long. >> >> But if you think a single-line assignment is better, I will modify it >> accordingly. > My preference, for what it's worth, would be to keep it one statement > and split the line after the =3D. Okay,=C2=A0 I will update it that way. Thanks. >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 int ref_cpu; >>>> =C2=A0 +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 policy =3D cpufreq_cpu_get(cpu); >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 if (!policy) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL; >>>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 if (!cpumask_intersects(policy->related_cpus, >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hou= sekeeping_cpumask(HK_TYPE_TICK))) { >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 cpufreq_cpu_put(policy); >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hou= sekeeping_cpumask(HK_TYPE_TICK))) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EOPNOTSUPP; >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = } >>>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 for_each_cpu_wrap(ref_cpu, policy->cpus, cpu + 1) { >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ref_cpu =3D=3D start_cpu) { >>>> @@ -329,8 +328,6 @@ int arch_freq_get_on_cpu(int cpu) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 } >>>> =C2=A0 -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 cpufreq_cpu_put(policy); >>>> - >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 if (ref_cpu >=3D nr_cpu_ids) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* No alternative to pull info from */ >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EAGAIN; >>> Thanks, >>> >>> Ben >>> > Thanks, > > Ben >