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 439F62F3C3A for ; Wed, 27 Aug 2025 09:12:40 +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=1756285962; cv=none; b=kpxw0c4fIuQ0KcBrbzsjXJMtQ4fzIAPrje53LTGfKBTBT3yaYB0fVCpOcJ2NrfLRyDvu2rOlvOp3YLnQsAORJyH3Vsk1FXVsFA/qxVmP6omSXDjCu5qbZ+cJcJC/2hBAKHgBF9orAvGdLFSaSAD9V4EZCl5upy6ndZ4aT4t4Wfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756285962; c=relaxed/simple; bh=qFqyLtiycPDNy2225NomFa+v0+8Oevp+bSIGdNB8ldQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XVivLH2emoP37dnr7+yqCsPwBFS1CVuVRQmbsPL/fhzHPx2Nyq0aQTbwMRn+/1gwfvRT6JPLzRuwFIqC+akV7/DQDSrPXCNw7Nx2eMHUJeKgp3eSFAEXDNiAJnU/raf6Q6fZy/9hhvFmHOC9aQDdPGJaprKq/ZyMjDhunNSeH1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 27EF4153B; Wed, 27 Aug 2025 02:12:31 -0700 (PDT) Received: from [10.1.196.46] (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C3023F738; Wed, 27 Aug 2025 02:12:30 -0700 (PDT) Message-ID: Date: Wed, 27 Aug 2025 10:12:28 +0100 Precedence: bulk X-Mailing-List: imx@lists.linux.dev 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: Zihuan Zhang , "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: Ben Horgan Content-Language: en-US In-Reply-To: <57016487-0fee-4821-9cd5-d6e5fe80a65d@kylinos.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Zihuan, On 8/27/25 09:55, Zihuan Zhang wrote: > Hi, > > 在 2025/8/27 16:30, Ben Horgan 写道: >> 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." > > > 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 =. > >>>               int ref_cpu; >>>   +            policy = cpufreq_cpu_get(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; >> Thanks, >> >> Ben >> Thanks, Ben