Skip to content

Commit 234458d

Browse files
committed
Merge tag 'v6.10-rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat fixes from Len Brown: "Fix three recent minor turbostat regressions" * tag 'v6.10-rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: tools/power turbostat: Add local build_bug.h header for snapshot target tools/power turbostat: Fix unc freq columns not showing with '-q' or '-l' tools/power turbostat: option '-n' is ambiguous
2 parents 5bbd9b2 + b15943c commit 234458d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

tools/power/x86/turbostat/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ turbostat : turbostat.c
1414
override CFLAGS += -O2 -Wall -Wextra -I../../../include
1515
override CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
1616
override CFLAGS += -DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"'
17+
override CFLAGS += -DBUILD_BUG_HEADER='"../../../../include/linux/build_bug.h"'
1718
override CFLAGS += -D_FILE_OFFSET_BITS=64
1819
override CFLAGS += -D_FORTIFY_SOURCE=2
1920

@@ -44,10 +45,13 @@ snapshot: turbostat
4445
@echo "#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
4546
@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
4647

48+
@echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
49+
4750
@echo PWD=. > $(SNAPSHOT)/Makefile
4851
@echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile
4952
@echo "CFLAGS += -DINTEL_FAMILY_HEADER='\"intel-family.h\"'" >> $(SNAPSHOT)/Makefile
50-
@sed -e's/.*MSRHEADER.*//' -e's/.*INTEL_FAMILY_HEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
53+
@echo "CFLAGS += -DBUILD_BUG_HEADER='\"build_bug.h\"'" >> $(SNAPSHOT)/Makefile
54+
@sed -e's/.*MSRHEADER.*//' -e's/.*INTEL_FAMILY_HEADER.*//' -e's/.*BUILD_BUG_HEADER.*//' Makefile >> $(SNAPSHOT)/Makefile
5155

5256
@rm -f $(SNAPSHOT).tar.gz
5357
tar cvzf $(SNAPSHOT).tar.gz $(SNAPSHOT)

tools/power/x86/turbostat/turbostat.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _GNU_SOURCE
1111
#include MSRHEADER
1212
#include INTEL_FAMILY_HEADER
13+
#include BUILD_BUG_HEADER
1314
#include <stdarg.h>
1415
#include <stdio.h>
1516
#include <err.h>
@@ -38,7 +39,6 @@
3839
#include <stdbool.h>
3940
#include <assert.h>
4041
#include <linux/kernel.h>
41-
#include <linux/build_bug.h>
4242

4343
#define UNUSED(x) (void)(x)
4444

@@ -5695,9 +5695,6 @@ static void probe_intel_uncore_frequency_cluster(void)
56955695
if (access("/sys/devices/system/cpu/intel_uncore_frequency/uncore00/current_freq_khz", R_OK))
56965696
return;
56975697

5698-
if (quiet)
5699-
return;
5700-
57015698
for (uncore_max_id = 0;; ++uncore_max_id) {
57025699

57035700
sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/uncore%02d", uncore_max_id);
@@ -5727,6 +5724,14 @@ static void probe_intel_uncore_frequency_cluster(void)
57275724
sprintf(path, "%s/fabric_cluster_id", path_base);
57285725
cluster_id = read_sysfs_int(path);
57295726

5727+
sprintf(path, "%s/current_freq_khz", path_base);
5728+
sprintf(name_buf, "UMHz%d.%d", domain_id, cluster_id);
5729+
5730+
add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, package_id);
5731+
5732+
if (quiet)
5733+
continue;
5734+
57305735
sprintf(path, "%s/min_freq_khz", path_base);
57315736
k = read_sysfs_int(path);
57325737
sprintf(path, "%s/max_freq_khz", path_base);
@@ -5743,11 +5748,6 @@ static void probe_intel_uncore_frequency_cluster(void)
57435748
sprintf(path, "%s/current_freq_khz", path_base);
57445749
k = read_sysfs_int(path);
57455750
fprintf(outf, " %d MHz\n", k / 1000);
5746-
5747-
sprintf(path, "%s/current_freq_khz", path_base);
5748-
sprintf(name_buf, "UMHz%d.%d", domain_id, cluster_id);
5749-
5750-
add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, package_id);
57515751
}
57525752
}
57535753

@@ -8424,7 +8424,7 @@ void cmdline(int argc, char **argv)
84248424
* Parse some options early, because they may make other options invalid,
84258425
* like adding the MSR counter with --add and at the same time using --no-msr.
84268426
*/
8427-
while ((opt = getopt_long_only(argc, argv, "MP", long_options, &option_index)) != -1) {
8427+
while ((opt = getopt_long_only(argc, argv, "MPn:", long_options, &option_index)) != -1) {
84288428
switch (opt) {
84298429
case 'M':
84308430
no_msr = 1;

0 commit comments

Comments
 (0)