From: bakshansky.lists@gmail.com
To: linux-hwmon@vger.kernel.org
Cc: linux@roeck-us.net, Roman Bakshansky <bakshansky.lists@gmail.com>
Subject: [PATCH 1/2] hwmon: (coretemp) replace hardcoded core count with dynamic value
Date: Sat, 16 May 2026 14:42:52 +0300 [thread overview]
Message-ID: <20260516114253.5466-2-bakshansky.lists@gmail.com> (raw)
In-Reply-To: <20260516114253.5466-1-bakshansky.lists@gmail.com>
From: Roman Bakshansky <bakshansky.lists@gmail.com>
The hardcoded maximum of 512 cores per package was first defined by commit
34cf8c657cf0 ("hwmon: (coretemp) Enlarge per package core count limit")
and later kept as a fallback with a TODO in commit 1a793caf6f69 ("hwmon:
(coretemp) Use dynamic allocated memory for core temp_data") because the
actual per-package core count was not reliably available at the time.
Now that topology_num_cores_per_package() is stable and suitable for use,
it's time to complete the TODO and allocate only the needed amount of
memory for core_data.
Signed-off-by: Roman Bakshansky <bakshansky.lists@gmail.com>
---
drivers/hwmon/coretemp.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 6a0d94711ead..c722b1d8e480 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -39,7 +39,6 @@ static int force_tjmax;
module_param_named(tjmax, force_tjmax, int, 0444);
MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
-#define NUM_REAL_CORES 512 /* Number of Real cores per cpu */
#define CORETEMP_NAME_LENGTH 28 /* String Length of attrs */
enum coretemp_attr_index {
@@ -485,13 +484,7 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
struct temp_data *tdata;
if (!pdata->core_data) {
- /*
- * TODO:
- * The information of actual possible cores in a package is broken for now.
- * Will replace hardcoded NUM_REAL_CORES with actual per package core count
- * when this information becomes available.
- */
- pdata->nr_cores = NUM_REAL_CORES;
+ pdata->nr_cores = topology_num_cores_per_package();
pdata->core_data = kzalloc_objs(struct temp_data *,
pdata->nr_cores);
if (!pdata->core_data)
--
2.53.0
next prev parent reply other threads:[~2026-05-16 11:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-16 11:42 [PATCH 0/2] hwmon: (coretemp) replace hardcoded core count and fix style issues bakshansky.lists
2026-05-16 11:42 ` bakshansky.lists [this message]
2026-05-16 12:16 ` [PATCH 1/2] hwmon: (coretemp) replace hardcoded core count with dynamic value sashiko-bot
2026-05-16 12:47 ` Guenter Roeck
2026-05-16 12:48 ` Guenter Roeck
2026-05-16 11:42 ` [PATCH 2/2] hwmon: (coretemp) fix coding style issues bakshansky.lists
2026-05-16 12:26 ` sashiko-bot
2026-05-16 12:50 ` Guenter Roeck
2026-05-16 15:10 ` bakshansky.lists
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=20260516114253.5466-2-bakshansky.lists@gmail.com \
--to=bakshansky.lists@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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