]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tools/power turbostat: Fix --show/--hide for individual cpuidle counters
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 11 Mar 2026 09:00:33 +0000 (11:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:30:34 +0000 (13:30 +0200)
commit9b9167ec8338ed56b39ac35ca2a2dd20790834e5
tree347e331412c6ef974ed4571b4bab5c90d09bc773
parent4253a5fda4b23cb4f2e4d16200f4975995ce4908
tools/power turbostat: Fix --show/--hide for individual cpuidle counters

[ Upstream commit b6398bc2ef3a78f1be37ba01ae0a5eedaee47803 ]

Problem: individual swidle counter names (C1, C1+, C1-, etc.) cannot be
selected via --show/--hide due to two bugs in probe_cpuidle_counts():
1. The function returns immediately when BIC_cpuidle is not enabled,
   without checking deferred_add_index.
2. The deferred name check runs against name_buf before the trailing
   newline is stripped, so is_deferred_add("C1\n") never matches "C1".

Fix:
1. Relax the early return to pass through when deferred names are
   queued.
2. Strip the trailing newline from name_buf before performing deferred
   name checks.
3. Check each suffixed variant (C1+, C1, C1-) individually so that
   e.g. "--show C1+" enables only the requested metric.

In addition, introduce a helper function to avoid repeating the
condition (readability cleanup).

Fixes: ec4acd3166d8 ("tools/power turbostat: disable "cpuidle" invocation counters, by default")
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/turbostat/turbostat.c