All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] cpufreq: use __free() for all cpufreq_cpu_get() references
@ 2025-09-01  8:57 Zihuan Zhang
  2025-09-01  8:57 ` [PATCH v3 01/12] arm64: topology: Use scope-based cleanup helper Zihuan Zhang
                   ` (13 more replies)
  0 siblings, 14 replies; 33+ messages in thread
From: Zihuan Zhang @ 2025-09-01  8:57 UTC (permalink / raw)
  To: 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
  Cc: 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, linux-pm, linux-acpi, linuxppc-dev, linux-arm-kernel,
	intel-gfx, dri-devel, imx, linux-omap, linux-kernel, Zihuan Zhang

This patchset converts all remaining cpufreq users to rely on the
__free(put_cpufreq_policy) annotation for policy references, instead of
calling cpufreq_cpu_put() manually.

Motivation:
- Reduce the chance of reference counting mistakes
- Make the code more consistent with the latest kernel style
- behavior remains the same, but reference counting is now safer 
  and easier to maintain.

The changes are split into 12 patches as they touch different subsystems
and are maintained by different people. There is no functional change.

V3:
 - drop patch 'KVM: x86: Use __free(put_cpufreq_policy) for policy reference'
 - removed 5 patches which has been applied
 - Consolidate CPUFreq policy assignments and allocations into one line,
   suggested by Ben Horgan
 - Change cpu_has_cpufreq() return type to bool, following Rafael's suggestion
 - Change the title to 'Use scope-based cleanup helper'

V2:
 - Fix compile error in powernv-cpufreq.c
 - Split patch to separate logical changes

Zihuan Zhang (12):
  arm64: topology: Use scope-based cleanup helper
  ACPI: processor: thermal: Use scope-based cleanup helper
  cpufreq: intel_pstate: Use scope-based cleanup helper
  cpufreq: longhaul: Use scope-based cleanup helper
  cpufreq: powernv: Use scope-based cleanup helper
  PM / devfreq: Use scope-based cleanup helper
  drm/i915: Use scope-based cleanup helper
  cpufreq: powerpc: macintosh: Use scope-based cleanup helper
  powercap: dtpm_cpu: Use scope-based cleanup helper
  thermal: imx: Use scope-based cleanup helper
  thermal/drivers/ti-soc-thermal: Use scope-based cleanup helper
  PM: EM: Use scope-based cleanup helper

 arch/arm64/kernel/topology.c                  |  9 +++----
 drivers/acpi/processor_thermal.c              | 18 +++++--------
 drivers/cpufreq/intel_pstate.c                |  8 +++---
 drivers/cpufreq/longhaul.c                    |  3 +--
 drivers/cpufreq/powernv-cpufreq.c             | 11 ++++----
 drivers/devfreq/governor_passive.c            | 25 +++++++-----------
 drivers/gpu/drm/i915/gt/intel_llc.c           |  4 +--
 drivers/macintosh/windfarm_cpufreq_clamp.c    |  5 +---
 drivers/powercap/dtpm_cpu.c                   | 26 +++++--------------
 drivers/thermal/imx_thermal.c                 | 12 +++------
 .../ti-soc-thermal/ti-thermal-common.c        | 11 +++-----
 kernel/power/energy_model.c                   |  9 +++----
 12 files changed, 46 insertions(+), 95 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 12/12] PM: EM: Use scope-based cleanup helper
@ 2025-09-02 15:53 ` Dan Carpenter
  0 siblings, 0 replies; 33+ messages in thread
From: kernel test robot @ 2025-09-02 15:25 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250901085748.36795-13-zhangzihuan@kylinos.cn>
References: <20250901085748.36795-13-zhangzihuan@kylinos.cn>
TO: Zihuan Zhang <zhangzihuan@kylinos.cn>
TO: "Rafael J . wysocki" <rafael@kernel.org>
TO: Viresh Kumar <viresh.kumar@linaro.org>
TO: Catalin Marinas <catalin.marinas@arm.com>
TO: Will Deacon <will@kernel.org>
TO: Borislav Petkov <bp@alien8.de>
TO: Dave Hansen <dave.hansen@linux.intel.com>
TO: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
TO: Michael Ellerman <mpe@ellerman.id.au>
TO: Krzysztof Kozlowski <krzk@kernel.org>
TO: Alim Akhtar <alim.akhtar@samsung.com>
TO: Thierry Reding <thierry.reding@gmail.com>
TO: MyungJoo Ham <myungjoo.ham@samsung.com>
TO: Kyungmin Park <kyungmin.park@samsung.com>
TO: Chanwoo Choi <cw00.choi@samsung.com>
TO: Jani Nikula <jani.nikula@linux.intel.com>
TO: Rodrigo Vivi <rodrigo.vivi@intel.com>
TO: Tvrtko Ursulin <tursulin@ursulin.net>
TO: David Airlie <airlied@gmail.com>
TO: Simona Vetter <simona@ffwll.ch>
TO: Daniel Lezcano <daniel.lezcano@kernel.org>
TO: Sascha Hauer <s.hauer@pengutronix.de>
TO: Shawn Guo <shawnguo@kernel.org>
TO: Eduardo Valentin <edubezval@gmail.com>
TO: Keerthy <j-keerthy@ti.com>
CC: Ben Horgan <ben.horgan@arm.com>
CC: zhenglifeng <zhenglifeng1@huawei.com>
CC: Zhang Rui <rui.zhang@intel.com>
CC: Len Brown <lenb@kernel.org>
CC: Lukasz Luba <lukasz.luba@arm.com>
CC: Pengutronix Kernel Team <kernel@pengutronix.de>

Hi Zihuan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/bleeding-edge rafael-pm/thermal arm64/for-next/core linus/master v6.17-rc4 next-20250902]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Zihuan-Zhang/arm64-topology-Use-scope-based-cleanup-helper/20250901-170106
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20250901085748.36795-13-zhangzihuan%40kylinos.cn
patch subject: [PATCH v3 12/12] PM: EM: Use scope-based cleanup helper
:::::: branch date: 30 hours ago
:::::: commit date: 30 hours ago
config: powerpc64-randconfig-r071-20250902 (https://download.01.org/0day-ci/archive/20250902/202509022308.CeaKUqJM-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 2e122990391b2ba062e6308a12cfedf7206270ba)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202509022308.CeaKUqJM-lkp@intel.com/

smatch warnings:
kernel/power/energy_model.c:454 em_cpufreq_update_efficiencies() error: uninitialized symbol 'policy'.
kernel/power/energy_model.c:454 em_cpufreq_update_efficiencies() error: uninitialized symbol 'policy'.

vim +/policy +454 kernel/power/energy_model.c

1bc138c6229599 Lukasz Luba       2020-06-10  449  
e7b1cc9a7ea6d7 Lukasz Luba       2024-02-08  450  static void
e7b1cc9a7ea6d7 Lukasz Luba       2024-02-08  451  em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
e458716a92b57f Vincent Donnefort 2021-09-08  452  {
e458716a92b57f Vincent Donnefort 2021-09-08  453  	struct em_perf_domain *pd = dev->em_pd;
3a096464b04b72 Zihuan Zhang      2025-09-01 @454  	struct cpufreq_policy *policy __free(put_cpufreq_policy);
e458716a92b57f Vincent Donnefort 2021-09-08  455  	int found = 0;
99907d6054f2d3 Lukasz Luba       2024-02-08  456  	int i, cpu;
e458716a92b57f Vincent Donnefort 2021-09-08  457  
e7b1cc9a7ea6d7 Lukasz Luba       2024-02-08  458  	if (!_is_cpu_device(dev))
e458716a92b57f Vincent Donnefort 2021-09-08  459  		return;
e458716a92b57f Vincent Donnefort 2021-09-08  460  
99907d6054f2d3 Lukasz Luba       2024-02-08  461  	/* Try to get a CPU which is active and in this PD */
99907d6054f2d3 Lukasz Luba       2024-02-08  462  	cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask);
99907d6054f2d3 Lukasz Luba       2024-02-08  463  	if (cpu >= nr_cpu_ids) {
99907d6054f2d3 Lukasz Luba       2024-02-08  464  		dev_warn(dev, "EM: No online CPU for CPUFreq policy\n");
99907d6054f2d3 Lukasz Luba       2024-02-08  465  		return;
99907d6054f2d3 Lukasz Luba       2024-02-08  466  	}
99907d6054f2d3 Lukasz Luba       2024-02-08  467  
99907d6054f2d3 Lukasz Luba       2024-02-08  468  	policy = cpufreq_cpu_get(cpu);
e458716a92b57f Vincent Donnefort 2021-09-08  469  	if (!policy) {
4274521fabee05 Lukasz Luba       2024-02-08  470  		dev_warn(dev, "EM: Access to CPUFreq policy failed\n");
e458716a92b57f Vincent Donnefort 2021-09-08  471  		return;
e458716a92b57f Vincent Donnefort 2021-09-08  472  	}
e458716a92b57f Vincent Donnefort 2021-09-08  473  
e458716a92b57f Vincent Donnefort 2021-09-08  474  	for (i = 0; i < pd->nr_perf_states; i++) {
e458716a92b57f Vincent Donnefort 2021-09-08  475  		if (!(table[i].flags & EM_PERF_STATE_INEFFICIENT))
e458716a92b57f Vincent Donnefort 2021-09-08  476  			continue;
e458716a92b57f Vincent Donnefort 2021-09-08  477  
e458716a92b57f Vincent Donnefort 2021-09-08  478  		if (!cpufreq_table_set_inefficient(policy, table[i].frequency))
e458716a92b57f Vincent Donnefort 2021-09-08  479  			found++;
e458716a92b57f Vincent Donnefort 2021-09-08  480  	}
e458716a92b57f Vincent Donnefort 2021-09-08  481  
e458716a92b57f Vincent Donnefort 2021-09-08  482  	if (!found)
e458716a92b57f Vincent Donnefort 2021-09-08  483  		return;
e458716a92b57f Vincent Donnefort 2021-09-08  484  
e458716a92b57f Vincent Donnefort 2021-09-08  485  	/*
e458716a92b57f Vincent Donnefort 2021-09-08  486  	 * Efficiencies have been installed in CPUFreq, inefficient frequencies
e458716a92b57f Vincent Donnefort 2021-09-08  487  	 * will be skipped. The EM can do the same.
e458716a92b57f Vincent Donnefort 2021-09-08  488  	 */
e458716a92b57f Vincent Donnefort 2021-09-08  489  	pd->flags |= EM_PERF_DOMAIN_SKIP_INEFFICIENCIES;
e458716a92b57f Vincent Donnefort 2021-09-08  490  }
e458716a92b57f Vincent Donnefort 2021-09-08  491  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2025-09-03 11:43 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01  8:57 [PATCH v3 00/12] cpufreq: use __free() for all cpufreq_cpu_get() references Zihuan Zhang
2025-09-01  8:57 ` [PATCH v3 01/12] arm64: topology: Use scope-based cleanup helper Zihuan Zhang
2025-09-02  5:26   ` kernel test robot
2025-09-01  8:57 ` [PATCH v3 02/12] ACPI: processor: thermal: " Zihuan Zhang
2025-09-03 11:07   ` Rafael J. Wysocki
2025-09-01  8:57 ` [PATCH v3 03/12] cpufreq: intel_pstate: " Zihuan Zhang
2025-09-01 15:17   ` Rafael J. Wysocki
2025-09-02 10:32     ` Zihuan Zhang
2025-09-02 11:47       ` Rafael J. Wysocki
2025-09-03  0:51         ` Zihuan Zhang
2025-09-03 11:04           ` Rafael J. Wysocki
2025-09-01  8:57 ` [PATCH v3 04/12] cpufreq: longhaul: " Zihuan Zhang
2025-09-02 15:58   ` Krzysztof Kozlowski
2025-09-01  8:57 ` [PATCH v3 05/12] cpufreq: powernv: " Zihuan Zhang
2025-09-01  8:57 ` [PATCH v3 06/12] PM / devfreq: " Zihuan Zhang
2025-09-01  8:57 ` [PATCH v3 07/12] drm/i915: " Zihuan Zhang
2025-09-01  8:57 ` [PATCH v3 08/12] cpufreq: powerpc: macintosh: " Zihuan Zhang
2025-09-02 15:59   ` Krzysztof Kozlowski
2025-09-01  8:57 ` [PATCH v3 09/12] powercap: dtpm_cpu: " Zihuan Zhang
2025-09-03 11:43   ` Rafael J. Wysocki
2025-09-01  8:57 ` [PATCH v3 10/12] thermal: imx: " Zihuan Zhang
2025-09-02  6:30   ` kernel test robot
2025-09-01  8:57 ` [PATCH v3 11/12] thermal/drivers/ti-soc-thermal: " Zihuan Zhang
2025-09-02  6:19   ` kernel test robot
2025-09-01  8:57 ` [PATCH v3 12/12] PM: EM: " Zihuan Zhang
2025-09-02 15:57   ` Krzysztof Kozlowski
2025-09-03  2:12     ` Zihuan Zhang
2025-09-03  6:11       ` Krzysztof Kozlowski
2025-09-02 16:44 ` ✓ i915.CI.BAT: success for cpufreq: use __free() for all cpufreq_cpu_get() references (rev3) Patchwork
2025-09-03  0:41 ` ✗ i915.CI.Full: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2025-09-02 15:25 [PATCH v3 12/12] PM: EM: Use scope-based cleanup helper kernel test robot
2025-09-02 15:53 ` Dan Carpenter
2025-09-03  2:30 ` Zihuan Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.