Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aveline Noir" <jm5905938@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (coretemp) Fix missing sensors with uneven core counts
Date: Fri, 04 Dec 2026 15:04:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-250056@kernel.org> (raw)
In-Reply-To: <20261205-coretemp-core-limit-v1-1-a7020e0e4208@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] hwmon: (coretemp) oversized contiguous core_data array in
  init_temp_data()
--

commit b4264371dd35960dd3d06c662f4625da35ac4376
Author: Aveline Noir <jm5905938@gmail.com>

hwmon: (coretemp) Fix missing sensors with uneven core counts

This commit changes init_temp_data() to size the per-zone
pdata->core_data array using num_possible_cpus() instead of
topology_num_cores_per_package(), so packages with more cores than the
first package do not run out of sensor slots.

> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index 96d57fe12de6d..2353d2d096e7c 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -491,7 +491,8 @@ 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);
>  		if (!pdata->core_data)

[Severity: Medium]
Can sizing pdata->core_data to num_possible_cpus() cause high-order
allocation failures and excessive per-zone memory use?

On x86_64 systems with more than 4096 possible CPUs (up to 8192 under
CONFIG_CPUMASK_OFFSTACK), kzalloc_objs(struct temp_data *, nr_cores)
requests an order-4 contiguous allocation (up to 64 KiB), exceeding
PAGE_ALLOC_COSTLY_ORDER.

Because destroy_temp_data() frees pdata->core_data when all housekeeping
CPUs in a zone go offline, re-onlining a CPU or loading coretemp on
fragmented memory can stall compaction or fail with -ENOMEM, leaving
cores without temperature sensors.

coretemp_init() creates one zone per package and die, so every zone now
allocates slots for all packages, dies, and SMT siblings, scaling total
memory as O(max_zones * num_possible_cpus()).

get_temp_data() also linearly scans all pdata->nr_cores entries on every
coretemp_cpu_offline() call, so misses on isolated CPUs skipped by
coretemp_cpu_online() scan all num_possible_cpus() mostly-NULL slots.

Since pdata->core_data is only used internally for lookup in
get_temp_data(), replacing the fixed array and pdata->ida with a
list_head or xarray (or at minimum using kvzalloc_objs()/kvfree()) would
avoid the costly-order allocation and per-zone over-sizing.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-coretemp-core-limit-v1-1-a7020e0e4208@gmail.com?part=1

  reply	other threads:[~2026-12-04 15:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:46 [PATCH] hwmon: (coretemp) Fix missing sensors with uneven core counts Aveline Noir
2026-12-04 15:04 ` sashiko-bot [this message]
2026-12-04 15:13   ` Aveline Noir
2026-12-04 20:34     ` Guenter Roeck
2026-12-05  6:11       ` Aveline Noir
2026-12-04 15:53 ` Asaf Nuri Bertizlioğlu
2026-12-04 16:04   ` Aveline Noir
2026-12-04 16:30     ` Asaf Nuri Bertizlioğlu
2026-12-04 16:43       ` Aveline Noir

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-250056@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jm5905938@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox