Skip to content

Commit 9581e24

Browse files
committed
Merge tag 'linux-cpupower-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux
Pull cpupower utility updates for v5.5 from Shuah Khan: "This cpupower update for Linux 5.5-rc1 consists of bug fixes and improvements to make it more accurate by removing the userspace to kernel transition and read_msr initiated IPI delays." * tag 'linux-cpupower-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux: cpupower: ToDo: Update ToDo with ideas for per_cpu_schedule handling cpupower: mperf_monitor: Update cpupower to use the RDPRU instruction cpupower: mperf_monitor: Introduce per_cpu_schedule flag cpupower: Move needs_root variable into a sub-struct cpupower : Handle set and info subcommands correctly tools/power/cpupower: Fix initializer override in hsw_ext_cstates
2 parents fef4ac8 + 4611a4f commit 9581e24

File tree

13 files changed

+100
-19
lines changed

13 files changed

+100
-19
lines changed

tools/power/cpupower/ToDo

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@ ToDos sorted by priority:
88
- Add another c1e debug idle monitor
99
-> Is by design racy with BIOS, but could be added
1010
with a --force option and some "be careful" messages
11+
- Add cpu_start()/cpu_stop() callbacks for monitor
12+
-> This is to move the per_cpu logic from inside the
13+
monitor to outside it. This can be given higher
14+
priority in fork_it.
15+
- Fork as many processes as there are CPUs in case the
16+
per_cpu_schedule flag is set.
17+
-> Bind forked process to each cpu.
18+
-> Execute start measures via the forked processes on
19+
each cpu.
20+
-> Run test executable in a forked process.
21+
-> Execute stop measures via the forked processes on
22+
each cpu.
23+
This would be ideal as it will not introduce noise in the
24+
tested executable.

tools/power/cpupower/utils/cpupower-info.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <errno.h>
1111
#include <string.h>
1212
#include <getopt.h>
13+
#include <sys/utsname.h>
1314

1415
#include "helpers/helpers.h"
1516
#include "helpers/sysfs.h"
@@ -30,6 +31,7 @@ int cmd_info(int argc, char **argv)
3031
extern char *optarg;
3132
extern int optind, opterr, optopt;
3233
unsigned int cpu;
34+
struct utsname uts;
3335

3436
union {
3537
struct {
@@ -39,6 +41,13 @@ int cmd_info(int argc, char **argv)
3941
} params = {};
4042
int ret = 0;
4143

44+
ret = uname(&uts);
45+
if (!ret && (!strcmp(uts.machine, "ppc64le") ||
46+
!strcmp(uts.machine, "ppc64"))) {
47+
fprintf(stderr, _("Subcommand not supported on POWER.\n"));
48+
return ret;
49+
}
50+
4251
setlocale(LC_ALL, "");
4352
textdomain(PACKAGE);
4453

tools/power/cpupower/utils/cpupower-set.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <errno.h>
1111
#include <string.h>
1212
#include <getopt.h>
13+
#include <sys/utsname.h>
1314

1415
#include "helpers/helpers.h"
1516
#include "helpers/sysfs.h"
@@ -31,6 +32,7 @@ int cmd_set(int argc, char **argv)
3132
extern char *optarg;
3233
extern int optind, opterr, optopt;
3334
unsigned int cpu;
35+
struct utsname uts;
3436

3537
union {
3638
struct {
@@ -41,6 +43,13 @@ int cmd_set(int argc, char **argv)
4143
int perf_bias = 0;
4244
int ret = 0;
4345

46+
ret = uname(&uts);
47+
if (!ret && (!strcmp(uts.machine, "ppc64le") ||
48+
!strcmp(uts.machine, "ppc64"))) {
49+
fprintf(stderr, _("Subcommand not supported on POWER.\n"));
50+
return ret;
51+
}
52+
4453
setlocale(LC_ALL, "");
4554
textdomain(PACKAGE);
4655

tools/power/cpupower/utils/helpers/cpuid.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info)
131131
if (ext_cpuid_level >= 0x80000007 &&
132132
(cpuid_edx(0x80000007) & (1 << 9)))
133133
cpu_info->caps |= CPUPOWER_CAP_AMD_CBP;
134+
135+
if (ext_cpuid_level >= 0x80000008 &&
136+
cpuid_ebx(0x80000008) & (1 << 4))
137+
cpu_info->caps |= CPUPOWER_CAP_AMD_RDPRU;
134138
}
135139

136140
if (cpu_info->vendor == X86_VENDOR_INTEL) {

tools/power/cpupower/utils/helpers/helpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
6969
#define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010
7070
#define CPUPOWER_CAP_IS_SNB 0x00000020
7171
#define CPUPOWER_CAP_INTEL_IDA 0x00000040
72+
#define CPUPOWER_CAP_AMD_RDPRU 0x00000080
7273

7374
#define CPUPOWER_AMD_CPBDIS 0x02000000
7475

tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ struct cpuidle_monitor amd_fam14h_monitor = {
328328
.stop = amd_fam14h_stop,
329329
.do_register = amd_fam14h_register,
330330
.unregister = amd_fam14h_unregister,
331-
.needs_root = 1,
331+
.flags.needs_root = 1,
332332
.overflow_s = OVERFLOW_MS / 1000,
333333
};
334334
#endif /* #if defined(__i386__) || defined(__x86_64__) */

tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ struct cpuidle_monitor cpuidle_sysfs_monitor = {
207207
.stop = cpuidle_stop,
208208
.do_register = cpuidle_register,
209209
.unregister = cpuidle_unregister,
210-
.needs_root = 0,
210+
.flags.needs_root = 0,
211211
.overflow_s = UINT_MAX,
212212
};

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ int cmd_monitor(int argc, char **argv)
408408
dprint("Try to register: %s\n", all_monitors[num]->name);
409409
test_mon = all_monitors[num]->do_register();
410410
if (test_mon) {
411-
if (test_mon->needs_root && !run_as_root) {
411+
if (test_mon->flags.needs_root && !run_as_root) {
412412
fprintf(stderr, _("Available monitor %s needs "
413413
"root access\n"), test_mon->name);
414414
continue;

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ struct cpuidle_monitor {
6060
struct cpuidle_monitor* (*do_register) (void);
6161
void (*unregister)(void);
6262
unsigned int overflow_s;
63-
int needs_root;
63+
struct {
64+
unsigned int needs_root:1;
65+
unsigned int per_cpu_schedule:1;
66+
} flags;
6467
};
6568

6669
extern long long timespec_diff_us(struct timespec start, struct timespec end);

tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ static cstate_t hsw_ext_cstates[HSW_EXT_CSTATE_COUNT] = {
3939
{
4040
.name = "PC9",
4141
.desc = N_("Processor Package C9"),
42-
.desc = N_("Processor Package C2"),
4342
.id = PC9,
4443
.range = RANGE_PACKAGE,
4544
.get_count_percent = hsw_ext_get_count_percent,
@@ -188,7 +187,7 @@ struct cpuidle_monitor intel_hsw_ext_monitor = {
188187
.stop = hsw_ext_stop,
189188
.do_register = hsw_ext_register,
190189
.unregister = hsw_ext_unregister,
191-
.needs_root = 1,
190+
.flags.needs_root = 1,
192191
.overflow_s = 922000000 /* 922337203 seconds TSC overflow
193192
at 20GHz */
194193
};

0 commit comments

Comments
 (0)