All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (coretemp) Fix missing sensors with uneven core counts
@ 2026-12-05  6:12 Aveline Noir
  2026-12-05  6:19 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aveline Noir @ 2026-12-05  6:12 UTC (permalink / raw)
  To: linux
  Cc: asafbertizlioglu, linux-hwmon, sashiko-bot, bakshansky.lists,
	sashiko-reviews

topology_num_cores_per_package() returns the core count of the package
with the lowest APIC ID. If another package has more cores, e.g. because
the BIOS disabled cores on only one CPU, the extra cores get no
temperature sensors and "Adding Core N failed" is logged.

Use num_possible_cpus() as the limit instead, and allocate the array
with kvzalloc_objs() so large systems don't need a high-order
allocation.

Fixes: b89e1255c92b ("hwmon: (coretemp) replace hardcoded core count with dynamic value")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-hwmon/20260516121622.1E9DAC19425@smtp.kernel.org/
Tested-by: Asaf Nuri Bertizlioğlu <asafbertizlioglu@gmail.com>
Reviewed-by: Asaf Nuri Bertizlioğlu <asafbertizlioglu@gmail.com>
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
---
v2: Use kvzalloc_objs() as Guenter suggested, and state the exact
condition in the commit message. Kept Asaf's tags since the allocation
change is small.

Only tested in QEMU, with 2+4 cores.

v1: https://lore.kernel.org/r/20261205-coretemp-core-limit-v1-1-a7020e0e4208@gmail.com
---
 drivers/hwmon/coretemp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 96d57fe12de6..936c16310c10 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -491,9 +491,10 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
 	struct temp_data *tdata;
 
 	if (!pdata->core_data) {
-		int nr_cores = topology_num_cores_per_package();
+		/* Packages can have different numbers of cores */
+		int nr_cores = num_possible_cpus();
 
-		pdata->core_data = kzalloc_objs(struct temp_data *, nr_cores);
+		pdata->core_data = kvzalloc_objs(struct temp_data *, nr_cores);
 		if (!pdata->core_data)
 			return NULL;
 		pdata->nr_cores = nr_cores;
@@ -531,7 +532,7 @@ static void destroy_temp_data(struct platform_data *pdata, struct temp_data *tda
 {
 	if (is_pkg_temp_data(tdata)) {
 		pdata->pkg_data = NULL;
-		kfree(pdata->core_data);
+		kvfree(pdata->core_data);
 		pdata->core_data = NULL;
 		pdata->nr_cores = 0;
 	} else {
@@ -659,7 +660,7 @@ static void coretemp_device_remove(int zoneid)
 	struct platform_data *pdata = platform_get_drvdata(pdev);
 
 	ida_destroy(&pdata->ida);
-	kfree(pdata->core_data);
+	kvfree(pdata->core_data);
 	kfree(pdata);
 	platform_device_unregister(pdev);
 }

---
base-commit: 19cc08c1a6a650f8e54c0461ff198be6448f425d
change-id: 20261205-coretemp-core-limit-4e403bcd7b15


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

end of thread, other threads:[~2026-12-05 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  6:12 [PATCH v2] hwmon: (coretemp) Fix missing sensors with uneven core counts Aveline Noir
2026-12-05  6:19 ` sashiko-bot
2026-12-05 11:16 ` Asaf Nuri Bertizlioğlu
2026-12-05 16:31 ` Guenter Roeck

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.