From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 DD7EC1E487; Fri, 5 Sep 2025 09:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757065123; cv=none; b=Wgp9zyoVTNUGCDvJ8kGHKcpIxbN/MtGbVkth0vocPcO9KPQHA6Cs92t7LeDhDPqlkSbaVfECtI3HeIqlM0wAtMf0RDAWCM6zxYYW5z4hwezcBfrt8rbnj1pqE4nqAW1jPyqike4Ijj0vJ7zJ7NsmM4DUQ06WmrzcPDMP4NTPaco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757065123; c=relaxed/simple; bh=zzHB9CnyjEjIaQbhpukUYwYkaSdUqi220Hab2T3S/oM=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JLTN/PQCwJ/XDw5+sW7qLOqUmuATagwDYOv/WTgj8JwPa+F53GMYOf95SW4Zopy8fgJlbxsl8n8+FP/KrzwtNq/cpxPXwzOYZJrKwhXUCfd2rOx6xakP73RyFd/6cS9FnmJbty8qopqYpf/9zPc70HXwIrmfhm0bGpHzULSnhcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4cJB5B08w6z6L5Vh; Fri, 5 Sep 2025 17:34:38 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id CEA161402CB; Fri, 5 Sep 2025 17:38:31 +0800 (CST) Received: from localhost (10.203.177.15) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 5 Sep 2025 11:38:29 +0200 Date: Fri, 5 Sep 2025 10:38:28 +0100 From: Jonathan Cameron To: Zihuan Zhang CC: "Rafael J . wysocki" , Viresh Kumar , Catalin Marinas , "Will Deacon" , Borislav Petkov , Dave Hansen , Srinivas Pandruvada , Michael Ellerman , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , "Jani Nikula" , Rodrigo Vivi , Tvrtko Ursulin , "David Airlie" , Simona Vetter , Daniel Lezcano , Sascha Hauer , "Shawn Guo" , Eduardo Valentin , Keerthy , Ben Horgan , zhenglifeng , Zhang Rui , Len Brown , Lukasz Luba , "Pengutronix Kernel Team" , Beata Michalska , Fabio Estevam , Pavel Machek , "Sumit Gupta" , Prasanna Kumar T S M , Sudeep Holla , Yicong Yang , , , , , , , , , Subject: Re: [PATCH v4 01/10] arm64: topology: Use scope-based cleanup helper Message-ID: <20250905103828.0000726c@huawei.com> In-Reply-To: <20250903131733.57637-2-zhangzihuan@kylinos.cn> References: <20250903131733.57637-1-zhangzihuan@kylinos.cn> <20250903131733.57637-2-zhangzihuan@kylinos.cn> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To frapeml500008.china.huawei.com (7.182.85.71) On Wed, 3 Sep 2025 21:17:24 +0800 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 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 > --- > 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;