From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 04/13] tools/power turbostat: Fix --cpu-set 0 regression on HT systems
Date: Sat, 25 Apr 2026 14:42:07 -0400 [thread overview]
Message-ID: <2c52f942fcf21c8e09c7dac669fca591cec2692b.1777141988.git.len.brown@intel.com> (raw)
In-Reply-To: <feffac1874820d501e51cd8dcee697063b792c82.1777141988.git.len.brown@intel.com>
From: Len Brown <len.brown@intel.com>
"turbostat --cpu-set 0" appears to hang if cpu0 has an HT sibling.
This is because the initialization code recognizes that it does not
have to open perf files for the HT sibling, but the HT support
in the collection code sees the HT sibling and tries to read
from an uninitialized file descriptor, 0 (standard input).
Access HT siblings only when they are in the allowed set.
Fixes: a2b4d0f8bf07 ("tools/power turbostat: Favor cpu# over core#")
Signed-off-by: Len Brown <len.brown@intel.com>
Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
tools/power/x86/turbostat/turbostat.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index d6b4fd17c5f3..7f61f07ceb31 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2427,11 +2427,17 @@ char *sys_lpi_file_debugfs = "/sys/kernel/debug/pmc_core/slp_s0_residency_usec";
int cpu_is_not_present(int cpu)
{
+ if (cpu < 0)
+ return 1;
+
return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set);
}
int cpu_is_not_allowed(int cpu)
{
+ if (cpu < 0)
+ return 1;
+
return !CPU_ISSET_S(cpu, cpu_allowed_setsize, cpu_allowed_set);
}
@@ -2473,9 +2479,12 @@ int for_all_cpus(int (func) (struct thread_data *, struct core_data *, struct pk
int i;
for (i = MAX_HT_ID; i > 0; --i) { /* ht_id 0 is self */
- if (cpus[cpu].ht_sibling_cpu_id[i] <= 0)
+ int sibling_cpu_id = cpus[cpu].ht_sibling_cpu_id[i];
+
+ if (cpu_is_not_allowed(sibling_cpu_id))
continue;
- t = &thread_base[cpus[cpu].ht_sibling_cpu_id[i]];
+
+ t = &thread_base[sibling_cpu_id];
retval |= func(t, c, p);
}
@@ -6252,10 +6261,13 @@ int for_all_cpus_2(int (func) (struct thread_data *, struct core_data *,
int i;
for (i = MAX_HT_ID; i > 0; --i) { /* ht_id 0 is self */
- if (cpus[cpu].ht_sibling_cpu_id[i] <= 0)
+ int sibling_cpu_id = cpus[cpu].ht_sibling_cpu_id[i];
+
+ if (cpu_is_not_allowed(sibling_cpu_id))
continue;
- t = &thread_base[cpus[cpu].ht_sibling_cpu_id[i]];
- t2 = &thread_base2[cpus[cpu].ht_sibling_cpu_id[i]];
+
+ t = &thread_base[sibling_cpu_id];
+ t2 = &thread_base2[sibling_cpu_id];
retval |= func(t, c, p, t2, c2, p2);
}
--
2.45.2
next prev parent reply other threads:[~2026-04-25 18:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 18:42 [PATCH 0/13] Power Utilities update for Linux-7.1 Len Brown
2026-04-25 18:42 ` [PATCH 01/13] tools/power/x86: Add SOC slider and platform profile support Len Brown
2026-04-25 18:42 ` [PATCH 02/13] tools/power turbostat: Fix AMD RAPL regression on big systems Len Brown
2026-04-25 18:42 ` [PATCH 03/13] tools/power turbostat: Fix unrecognized option '-P' Len Brown
2026-04-25 18:42 ` Len Brown [this message]
2026-04-25 18:42 ` [PATCH 05/13] tools/power turbostat: Fix --cpu-set 1 regression on HT systems Len Brown
2026-04-25 18:42 ` [PATCH 06/13] tools/power turbostat: Cleanup print helper functions Len Brown
2026-04-25 18:42 ` [PATCH 07/13] tools/power turbostat: Print core_id and apic_id in hex Len Brown
2026-04-25 18:42 ` [PATCH 08/13] tools/power turbostat: Show module_id column Len Brown
2026-04-25 18:42 ` [PATCH 09/13] tools/power turbostat: Process HT siblings in CPU order Len Brown
2026-04-25 18:42 ` [PATCH 10/13] tools/power turbostat: v2026.04.21 Len Brown
2026-04-25 18:42 ` [PATCH 11/13] tools/power x86_energy_perf_policy: Enhances SoC Slider related checks Len Brown
2026-04-25 18:42 ` [PATCH 12/13] tools/power x86_energy_perf_policy.8: Document SoC Slider Options Len Brown
2026-04-25 18:42 ` [PATCH 13/13] tools/power x86_energy_perf_policy: Version 2026.04.25 Len Brown
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=2c52f942fcf21c8e09c7dac669fca591cec2692b.1777141988.git.len.brown@intel.com \
--to=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/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
all inboxes | Powered by JetHome®