diff options
author | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
commit | bb799d3b980eb803ca2da4a4eefbd9308f8d988a (patch) | |
tree | 69fbe0cd6d47b23a50f5e1d87bf7489532fae149 /tools | |
parent | 919fc6e34831d1c2b58bfb5ae261dc3facc9b269 (diff) | |
parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) |
Merge tag 'v3.13-rc4' into core/locking
Merge Linux 3.13-rc4, to refresh this rather old tree with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 25 | ||||
-rw-r--r-- | tools/perf/util/header.c | 6 | ||||
-rw-r--r-- | tools/perf/util/thread.c | 11 | ||||
-rw-r--r-- | tools/power/cpupower/man/cpupower-idle-info.1 | 3 | ||||
-rw-r--r-- | tools/power/cpupower/man/cpupower-idle-set.1 | 71 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/sysfs.c | 4 | ||||
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 197 | ||||
-rw-r--r-- | tools/usb/Makefile | 5 |
8 files changed, 250 insertions, 72 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 0362d575de7d..217c82ee3665 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -1606,6 +1606,24 @@ process_arg(struct event_format *event, struct print_arg *arg, char **tok) | |||
1606 | static enum event_type | 1606 | static enum event_type |
1607 | process_op(struct event_format *event, struct print_arg *arg, char **tok); | 1607 | process_op(struct event_format *event, struct print_arg *arg, char **tok); |
1608 | 1608 | ||
1609 | /* | ||
1610 | * For __print_symbolic() and __print_flags, we need to completely | ||
1611 | * evaluate the first argument, which defines what to print next. | ||
1612 | */ | ||
1613 | static enum event_type | ||
1614 | process_field_arg(struct event_format *event, struct print_arg *arg, char **tok) | ||
1615 | { | ||
1616 | enum event_type type; | ||
1617 | |||
1618 | type = process_arg(event, arg, tok); | ||
1619 | |||
1620 | while (type == EVENT_OP) { | ||
1621 | type = process_op(event, arg, tok); | ||
1622 | } | ||
1623 | |||
1624 | return type; | ||
1625 | } | ||
1626 | |||
1609 | static enum event_type | 1627 | static enum event_type |
1610 | process_cond(struct event_format *event, struct print_arg *top, char **tok) | 1628 | process_cond(struct event_format *event, struct print_arg *top, char **tok) |
1611 | { | 1629 | { |
@@ -2371,7 +2389,7 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) | |||
2371 | goto out_free; | 2389 | goto out_free; |
2372 | } | 2390 | } |
2373 | 2391 | ||
2374 | type = process_arg(event, field, &token); | 2392 | type = process_field_arg(event, field, &token); |
2375 | 2393 | ||
2376 | /* Handle operations in the first argument */ | 2394 | /* Handle operations in the first argument */ |
2377 | while (type == EVENT_OP) | 2395 | while (type == EVENT_OP) |
@@ -2424,7 +2442,8 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) | |||
2424 | goto out_free; | 2442 | goto out_free; |
2425 | } | 2443 | } |
2426 | 2444 | ||
2427 | type = process_arg(event, field, &token); | 2445 | type = process_field_arg(event, field, &token); |
2446 | |||
2428 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 2447 | if (test_type_token(type, token, EVENT_DELIM, ",")) |
2429 | goto out_free_field; | 2448 | goto out_free_field; |
2430 | 2449 | ||
@@ -3446,7 +3465,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg | |||
3446 | * is in the bottom half of the 32 bit field. | 3465 | * is in the bottom half of the 32 bit field. |
3447 | */ | 3466 | */ |
3448 | offset &= 0xffff; | 3467 | offset &= 0xffff; |
3449 | val = (unsigned long long)(data + offset); | 3468 | val = (unsigned long long)((unsigned long)data + offset); |
3450 | break; | 3469 | break; |
3451 | default: /* not sure what to do there */ | 3470 | default: /* not sure what to do there */ |
3452 | return 0; | 3471 | return 0; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 369c03648f88..1cd035708931 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2078,8 +2078,10 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused, | |||
2078 | if (evsel->idx == (int) desc[i].leader_idx) { | 2078 | if (evsel->idx == (int) desc[i].leader_idx) { |
2079 | evsel->leader = evsel; | 2079 | evsel->leader = evsel; |
2080 | /* {anon_group} is a dummy name */ | 2080 | /* {anon_group} is a dummy name */ |
2081 | if (strcmp(desc[i].name, "{anon_group}")) | 2081 | if (strcmp(desc[i].name, "{anon_group}")) { |
2082 | evsel->group_name = desc[i].name; | 2082 | evsel->group_name = desc[i].name; |
2083 | desc[i].name = NULL; | ||
2084 | } | ||
2083 | evsel->nr_members = desc[i].nr_members; | 2085 | evsel->nr_members = desc[i].nr_members; |
2084 | 2086 | ||
2085 | if (i >= nr_groups || nr > 0) { | 2087 | if (i >= nr_groups || nr > 0) { |
@@ -2105,7 +2107,7 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused, | |||
2105 | 2107 | ||
2106 | ret = 0; | 2108 | ret = 0; |
2107 | out_free: | 2109 | out_free: |
2108 | while ((int) --i >= 0) | 2110 | for (i = 0; i < nr_groups; i++) |
2109 | free(desc[i].name); | 2111 | free(desc[i].name); |
2110 | free(desc); | 2112 | free(desc); |
2111 | 2113 | ||
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index cd8e2f592719..49eaf1d7d89d 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -70,14 +70,13 @@ int thread__set_comm(struct thread *thread, const char *str, u64 timestamp) | |||
70 | /* Override latest entry if it had no specific time coverage */ | 70 | /* Override latest entry if it had no specific time coverage */ |
71 | if (!curr->start) { | 71 | if (!curr->start) { |
72 | comm__override(curr, str, timestamp); | 72 | comm__override(curr, str, timestamp); |
73 | return 0; | 73 | } else { |
74 | new = comm__new(str, timestamp); | ||
75 | if (!new) | ||
76 | return -ENOMEM; | ||
77 | list_add(&new->list, &thread->comm_list); | ||
74 | } | 78 | } |
75 | 79 | ||
76 | new = comm__new(str, timestamp); | ||
77 | if (!new) | ||
78 | return -ENOMEM; | ||
79 | |||
80 | list_add(&new->list, &thread->comm_list); | ||
81 | thread->comm_set = true; | 80 | thread->comm_set = true; |
82 | 81 | ||
83 | return 0; | 82 | return 0; |
diff --git a/tools/power/cpupower/man/cpupower-idle-info.1 b/tools/power/cpupower/man/cpupower-idle-info.1 index 4178effd9e99..7b3646adb92f 100644 --- a/tools/power/cpupower/man/cpupower-idle-info.1 +++ b/tools/power/cpupower/man/cpupower-idle-info.1 | |||
@@ -87,4 +87,5 @@ Thomas Renninger <trenn@suse.de> | |||
87 | .fi | 87 | .fi |
88 | .SH "SEE ALSO" | 88 | .SH "SEE ALSO" |
89 | .LP | 89 | .LP |
90 | cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1) | 90 | cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1), |
91 | cpupower\-idle\-set(1) | ||
diff --git a/tools/power/cpupower/man/cpupower-idle-set.1 b/tools/power/cpupower/man/cpupower-idle-set.1 new file mode 100644 index 000000000000..6b1607272a5b --- /dev/null +++ b/tools/power/cpupower/man/cpupower-idle-set.1 | |||
@@ -0,0 +1,71 @@ | |||
1 | .TH "CPUPOWER-IDLE-SET" "1" "0.1" "" "cpupower Manual" | ||
2 | .SH "NAME" | ||
3 | .LP | ||
4 | cpupower idle\-set \- Utility to set cpu idle state specific kernel options | ||
5 | .SH "SYNTAX" | ||
6 | .LP | ||
7 | cpupower [ \-c cpulist ] idle\-info [\fIoptions\fP] | ||
8 | .SH "DESCRIPTION" | ||
9 | .LP | ||
10 | The cpupower idle\-set subcommand allows to set cpu idle, also called cpu | ||
11 | sleep state, specific options offered by the kernel. One example is disabling | ||
12 | sleep states. This can be handy for power vs performance tuning. | ||
13 | .SH "OPTIONS" | ||
14 | .LP | ||
15 | .TP | ||
16 | \fB\-d\fR \fB\-\-disable\fR | ||
17 | Disable a specific processor sleep state. | ||
18 | .TP | ||
19 | \fB\-e\fR \fB\-\-enable\fR | ||
20 | Enable a specific processor sleep state. | ||
21 | |||
22 | .SH "REMARKS" | ||
23 | .LP | ||
24 | Cpuidle Governors Policy on Disabling Sleep States | ||
25 | |||
26 | .RS 4 | ||
27 | Depending on the used cpuidle governor, implementing the kernel policy | ||
28 | how to choose sleep states, subsequent sleep states on this core, might get | ||
29 | disabled as well. | ||
30 | |||
31 | There are two cpuidle governors ladder and menu. While the ladder | ||
32 | governor is always available, if CONFIG_CPU_IDLE is selected, the | ||
33 | menu governor additionally requires CONFIG_NO_HZ. | ||
34 | |||
35 | The behavior and the effect of the disable variable depends on the | ||
36 | implementation of a particular governor. In the ladder governor, for | ||
37 | example, it is not coherent, i.e. if one is disabling a light state, | ||
38 | then all deeper states are disabled as well. Likewise, if one enables a | ||
39 | deep state but a lighter state still is disabled, then this has no effect. | ||
40 | .RE | ||
41 | .LP | ||
42 | Disabling the Lightest Sleep State may not have any Affect | ||
43 | |||
44 | .RS 4 | ||
45 | If criteria are not met to enter deeper sleep states and the lightest sleep | ||
46 | state is chosen when idle, the kernel may still enter this sleep state, | ||
47 | irrespective of whether it is disabled or not. This is also reflected in | ||
48 | the usage count of the disabled sleep state when using the cpupower idle-info | ||
49 | command. | ||
50 | .RE | ||
51 | .LP | ||
52 | Selecting specific CPU Cores | ||
53 | |||
54 | .RS 4 | ||
55 | By default processor sleep states of all CPU cores are set. Please refer | ||
56 | to the cpupower(1) manpage in the \-\-cpu option section how to disable | ||
57 | C-states of specific cores. | ||
58 | .RE | ||
59 | .SH "FILES" | ||
60 | .nf | ||
61 | \fI/sys/devices/system/cpu/cpu*/cpuidle/state*\fP | ||
62 | \fI/sys/devices/system/cpu/cpuidle/*\fP | ||
63 | .fi | ||
64 | .SH "AUTHORS" | ||
65 | .nf | ||
66 | Thomas Renninger <trenn@suse.de> | ||
67 | .fi | ||
68 | .SH "SEE ALSO" | ||
69 | .LP | ||
70 | cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1), | ||
71 | cpupower\-idle\-info(1) | ||
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c index 5cdc600e8152..851c7a16ca49 100644 --- a/tools/power/cpupower/utils/helpers/sysfs.c +++ b/tools/power/cpupower/utils/helpers/sysfs.c | |||
@@ -278,7 +278,7 @@ static char *sysfs_idlestate_get_one_string(unsigned int cpu, | |||
278 | int sysfs_is_idlestate_disabled(unsigned int cpu, | 278 | int sysfs_is_idlestate_disabled(unsigned int cpu, |
279 | unsigned int idlestate) | 279 | unsigned int idlestate) |
280 | { | 280 | { |
281 | if (sysfs_get_idlestate_count(cpu) < idlestate) | 281 | if (sysfs_get_idlestate_count(cpu) <= idlestate) |
282 | return -1; | 282 | return -1; |
283 | 283 | ||
284 | if (!sysfs_idlestate_file_exists(cpu, idlestate, | 284 | if (!sysfs_idlestate_file_exists(cpu, idlestate, |
@@ -303,7 +303,7 @@ int sysfs_idlestate_disable(unsigned int cpu, | |||
303 | char value[SYSFS_PATH_MAX]; | 303 | char value[SYSFS_PATH_MAX]; |
304 | int bytes_written; | 304 | int bytes_written; |
305 | 305 | ||
306 | if (sysfs_get_idlestate_count(cpu) < idlestate) | 306 | if (sysfs_get_idlestate_count(cpu) <= idlestate) |
307 | return -1; | 307 | return -1; |
308 | 308 | ||
309 | if (!sysfs_idlestate_file_exists(cpu, idlestate, | 309 | if (!sysfs_idlestate_file_exists(cpu, idlestate, |
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index fe702076ca46..9d77f13c2d25 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * turbostat -- show CPU frequency and C-state residency | 2 | * turbostat -- show CPU frequency and C-state residency |
3 | * on modern Intel turbo-capable processors. | 3 | * on modern Intel turbo-capable processors. |
4 | * | 4 | * |
5 | * Copyright (c) 2012 Intel Corporation. | 5 | * Copyright (c) 2013 Intel Corporation. |
6 | * Len Brown <len.brown@intel.com> | 6 | * Len Brown <len.brown@intel.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
@@ -47,6 +47,8 @@ unsigned int skip_c1; | |||
47 | unsigned int do_nhm_cstates; | 47 | unsigned int do_nhm_cstates; |
48 | unsigned int do_snb_cstates; | 48 | unsigned int do_snb_cstates; |
49 | unsigned int do_c8_c9_c10; | 49 | unsigned int do_c8_c9_c10; |
50 | unsigned int do_slm_cstates; | ||
51 | unsigned int use_c1_residency_msr; | ||
50 | unsigned int has_aperf; | 52 | unsigned int has_aperf; |
51 | unsigned int has_epb; | 53 | unsigned int has_epb; |
52 | unsigned int units = 1000000000; /* Ghz etc */ | 54 | unsigned int units = 1000000000; /* Ghz etc */ |
@@ -81,6 +83,8 @@ double rapl_joule_counter_range; | |||
81 | #define RAPL_DRAM (1 << 3) | 83 | #define RAPL_DRAM (1 << 3) |
82 | #define RAPL_PKG_PERF_STATUS (1 << 4) | 84 | #define RAPL_PKG_PERF_STATUS (1 << 4) |
83 | #define RAPL_DRAM_PERF_STATUS (1 << 5) | 85 | #define RAPL_DRAM_PERF_STATUS (1 << 5) |
86 | #define RAPL_PKG_POWER_INFO (1 << 6) | ||
87 | #define RAPL_CORE_POLICY (1 << 7) | ||
84 | #define TJMAX_DEFAULT 100 | 88 | #define TJMAX_DEFAULT 100 |
85 | 89 | ||
86 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) | 90 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
@@ -96,7 +100,7 @@ struct thread_data { | |||
96 | unsigned long long tsc; | 100 | unsigned long long tsc; |
97 | unsigned long long aperf; | 101 | unsigned long long aperf; |
98 | unsigned long long mperf; | 102 | unsigned long long mperf; |
99 | unsigned long long c1; /* derived */ | 103 | unsigned long long c1; |
100 | unsigned long long extra_msr64; | 104 | unsigned long long extra_msr64; |
101 | unsigned long long extra_delta64; | 105 | unsigned long long extra_delta64; |
102 | unsigned long long extra_msr32; | 106 | unsigned long long extra_msr32; |
@@ -266,7 +270,7 @@ void print_header(void) | |||
266 | outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64); | 270 | outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64); |
267 | if (do_nhm_cstates) | 271 | if (do_nhm_cstates) |
268 | outp += sprintf(outp, " %%c1"); | 272 | outp += sprintf(outp, " %%c1"); |
269 | if (do_nhm_cstates) | 273 | if (do_nhm_cstates && !do_slm_cstates) |
270 | outp += sprintf(outp, " %%c3"); | 274 | outp += sprintf(outp, " %%c3"); |
271 | if (do_nhm_cstates) | 275 | if (do_nhm_cstates) |
272 | outp += sprintf(outp, " %%c6"); | 276 | outp += sprintf(outp, " %%c6"); |
@@ -280,9 +284,9 @@ void print_header(void) | |||
280 | 284 | ||
281 | if (do_snb_cstates) | 285 | if (do_snb_cstates) |
282 | outp += sprintf(outp, " %%pc2"); | 286 | outp += sprintf(outp, " %%pc2"); |
283 | if (do_nhm_cstates) | 287 | if (do_nhm_cstates && !do_slm_cstates) |
284 | outp += sprintf(outp, " %%pc3"); | 288 | outp += sprintf(outp, " %%pc3"); |
285 | if (do_nhm_cstates) | 289 | if (do_nhm_cstates && !do_slm_cstates) |
286 | outp += sprintf(outp, " %%pc6"); | 290 | outp += sprintf(outp, " %%pc6"); |
287 | if (do_snb_cstates) | 291 | if (do_snb_cstates) |
288 | outp += sprintf(outp, " %%pc7"); | 292 | outp += sprintf(outp, " %%pc7"); |
@@ -480,7 +484,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
480 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) | 484 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) |
481 | goto done; | 485 | goto done; |
482 | 486 | ||
483 | if (do_nhm_cstates) | 487 | if (do_nhm_cstates && !do_slm_cstates) |
484 | outp += sprintf(outp, " %6.2f", 100.0 * c->c3/t->tsc); | 488 | outp += sprintf(outp, " %6.2f", 100.0 * c->c3/t->tsc); |
485 | if (do_nhm_cstates) | 489 | if (do_nhm_cstates) |
486 | outp += sprintf(outp, " %6.2f", 100.0 * c->c6/t->tsc); | 490 | outp += sprintf(outp, " %6.2f", 100.0 * c->c6/t->tsc); |
@@ -499,9 +503,9 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
499 | 503 | ||
500 | if (do_snb_cstates) | 504 | if (do_snb_cstates) |
501 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc2/t->tsc); | 505 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc2/t->tsc); |
502 | if (do_nhm_cstates) | 506 | if (do_nhm_cstates && !do_slm_cstates) |
503 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc3/t->tsc); | 507 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc3/t->tsc); |
504 | if (do_nhm_cstates) | 508 | if (do_nhm_cstates && !do_slm_cstates) |
505 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); | 509 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); |
506 | if (do_snb_cstates) | 510 | if (do_snb_cstates) |
507 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); | 511 | outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); |
@@ -648,17 +652,24 @@ delta_thread(struct thread_data *new, struct thread_data *old, | |||
648 | } | 652 | } |
649 | 653 | ||
650 | 654 | ||
651 | /* | 655 | if (use_c1_residency_msr) { |
652 | * As counter collection is not atomic, | 656 | /* |
653 | * it is possible for mperf's non-halted cycles + idle states | 657 | * Some models have a dedicated C1 residency MSR, |
654 | * to exceed TSC's all cycles: show c1 = 0% in that case. | 658 | * which should be more accurate than the derivation below. |
655 | */ | 659 | */ |
656 | if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) | 660 | } else { |
657 | old->c1 = 0; | 661 | /* |
658 | else { | 662 | * As counter collection is not atomic, |
659 | /* normal case, derive c1 */ | 663 | * it is possible for mperf's non-halted cycles + idle states |
660 | old->c1 = old->tsc - old->mperf - core_delta->c3 | 664 | * to exceed TSC's all cycles: show c1 = 0% in that case. |
665 | */ | ||
666 | if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) | ||
667 | old->c1 = 0; | ||
668 | else { | ||
669 | /* normal case, derive c1 */ | ||
670 | old->c1 = old->tsc - old->mperf - core_delta->c3 | ||
661 | - core_delta->c6 - core_delta->c7; | 671 | - core_delta->c6 - core_delta->c7; |
672 | } | ||
662 | } | 673 | } |
663 | 674 | ||
664 | if (old->mperf == 0) { | 675 | if (old->mperf == 0) { |
@@ -872,13 +883,21 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
872 | if (get_msr(cpu, extra_msr_offset64, &t->extra_msr64)) | 883 | if (get_msr(cpu, extra_msr_offset64, &t->extra_msr64)) |
873 | return -5; | 884 | return -5; |
874 | 885 | ||
886 | if (use_c1_residency_msr) { | ||
887 | if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) | ||
888 | return -6; | ||
889 | } | ||
890 | |||
875 | /* collect core counters only for 1st thread in core */ | 891 | /* collect core counters only for 1st thread in core */ |
876 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) | 892 | if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) |
877 | return 0; | 893 | return 0; |
878 | 894 | ||
879 | if (do_nhm_cstates) { | 895 | if (do_nhm_cstates && !do_slm_cstates) { |
880 | if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) | 896 | if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) |
881 | return -6; | 897 | return -6; |
898 | } | ||
899 | |||
900 | if (do_nhm_cstates) { | ||
882 | if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) | 901 | if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) |
883 | return -7; | 902 | return -7; |
884 | } | 903 | } |
@@ -898,7 +917,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
898 | if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) | 917 | if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) |
899 | return 0; | 918 | return 0; |
900 | 919 | ||
901 | if (do_nhm_cstates) { | 920 | if (do_nhm_cstates && !do_slm_cstates) { |
902 | if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) | 921 | if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) |
903 | return -9; | 922 | return -9; |
904 | if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) | 923 | if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) |
@@ -977,7 +996,7 @@ void print_verbose_header(void) | |||
977 | ratio, bclk, ratio * bclk); | 996 | ratio, bclk, ratio * bclk); |
978 | 997 | ||
979 | get_msr(0, MSR_IA32_POWER_CTL, &msr); | 998 | get_msr(0, MSR_IA32_POWER_CTL, &msr); |
980 | fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E: %sabled)\n", | 999 | fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", |
981 | msr, msr & 0x2 ? "EN" : "DIS"); | 1000 | msr, msr & 0x2 ? "EN" : "DIS"); |
982 | 1001 | ||
983 | if (!do_ivt_turbo_ratio_limit) | 1002 | if (!do_ivt_turbo_ratio_limit) |
@@ -1046,25 +1065,28 @@ print_nhm_turbo_ratio_limits: | |||
1046 | 1065 | ||
1047 | switch(msr & 0x7) { | 1066 | switch(msr & 0x7) { |
1048 | case 0: | 1067 | case 0: |
1049 | fprintf(stderr, "pc0"); | 1068 | fprintf(stderr, do_slm_cstates ? "no pkg states" : "pc0"); |
1050 | break; | 1069 | break; |
1051 | case 1: | 1070 | case 1: |
1052 | fprintf(stderr, do_snb_cstates ? "pc2" : "pc0"); | 1071 | fprintf(stderr, do_slm_cstates ? "no pkg states" : do_snb_cstates ? "pc2" : "pc0"); |
1053 | break; | 1072 | break; |
1054 | case 2: | 1073 | case 2: |
1055 | fprintf(stderr, do_snb_cstates ? "pc6-noret" : "pc3"); | 1074 | fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc6-noret" : "pc3"); |
1056 | break; | 1075 | break; |
1057 | case 3: | 1076 | case 3: |
1058 | fprintf(stderr, "pc6"); | 1077 | fprintf(stderr, do_slm_cstates ? "invalid" : "pc6"); |
1059 | break; | 1078 | break; |
1060 | case 4: | 1079 | case 4: |
1061 | fprintf(stderr, "pc7"); | 1080 | fprintf(stderr, do_slm_cstates ? "pc4" : "pc7"); |
1062 | break; | 1081 | break; |
1063 | case 5: | 1082 | case 5: |
1064 | fprintf(stderr, do_snb_cstates ? "pc7s" : "invalid"); | 1083 | fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc7s" : "invalid"); |
1084 | break; | ||
1085 | case 6: | ||
1086 | fprintf(stderr, do_slm_cstates ? "pc6" : "invalid"); | ||
1065 | break; | 1087 | break; |
1066 | case 7: | 1088 | case 7: |
1067 | fprintf(stderr, "unlimited"); | 1089 | fprintf(stderr, do_slm_cstates ? "pc7" : "unlimited"); |
1068 | break; | 1090 | break; |
1069 | default: | 1091 | default: |
1070 | fprintf(stderr, "invalid"); | 1092 | fprintf(stderr, "invalid"); |
@@ -1460,6 +1482,8 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model) | |||
1460 | case 0x3F: /* HSW */ | 1482 | case 0x3F: /* HSW */ |
1461 | case 0x45: /* HSW */ | 1483 | case 0x45: /* HSW */ |
1462 | case 0x46: /* HSW */ | 1484 | case 0x46: /* HSW */ |
1485 | case 0x37: /* BYT */ | ||
1486 | case 0x4D: /* AVN */ | ||
1463 | return 1; | 1487 | return 1; |
1464 | case 0x2E: /* Nehalem-EX Xeon - Beckton */ | 1488 | case 0x2E: /* Nehalem-EX Xeon - Beckton */ |
1465 | case 0x2F: /* Westmere-EX Xeon - Eagleton */ | 1489 | case 0x2F: /* Westmere-EX Xeon - Eagleton */ |
@@ -1532,14 +1556,33 @@ int print_epb(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1532 | #define RAPL_POWER_GRANULARITY 0x7FFF /* 15 bit power granularity */ | 1556 | #define RAPL_POWER_GRANULARITY 0x7FFF /* 15 bit power granularity */ |
1533 | #define RAPL_TIME_GRANULARITY 0x3F /* 6 bit time granularity */ | 1557 | #define RAPL_TIME_GRANULARITY 0x3F /* 6 bit time granularity */ |
1534 | 1558 | ||
1559 | double get_tdp(model) | ||
1560 | { | ||
1561 | unsigned long long msr; | ||
1562 | |||
1563 | if (do_rapl & RAPL_PKG_POWER_INFO) | ||
1564 | if (!get_msr(0, MSR_PKG_POWER_INFO, &msr)) | ||
1565 | return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; | ||
1566 | |||
1567 | switch (model) { | ||
1568 | case 0x37: | ||
1569 | case 0x4D: | ||
1570 | return 30.0; | ||
1571 | default: | ||
1572 | return 135.0; | ||
1573 | } | ||
1574 | } | ||
1575 | |||
1576 | |||
1535 | /* | 1577 | /* |
1536 | * rapl_probe() | 1578 | * rapl_probe() |
1537 | * | 1579 | * |
1538 | * sets do_rapl | 1580 | * sets do_rapl, rapl_power_units, rapl_energy_units, rapl_time_units |
1539 | */ | 1581 | */ |
1540 | void rapl_probe(unsigned int family, unsigned int model) | 1582 | void rapl_probe(unsigned int family, unsigned int model) |
1541 | { | 1583 | { |
1542 | unsigned long long msr; | 1584 | unsigned long long msr; |
1585 | unsigned int time_unit; | ||
1543 | double tdp; | 1586 | double tdp; |
1544 | 1587 | ||
1545 | if (!genuine_intel) | 1588 | if (!genuine_intel) |
@@ -1555,11 +1598,15 @@ void rapl_probe(unsigned int family, unsigned int model) | |||
1555 | case 0x3F: /* HSW */ | 1598 | case 0x3F: /* HSW */ |
1556 | case 0x45: /* HSW */ | 1599 | case 0x45: /* HSW */ |
1557 | case 0x46: /* HSW */ | 1600 | case 0x46: /* HSW */ |
1558 | do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX; | 1601 | do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO; |
1559 | break; | 1602 | break; |
1560 | case 0x2D: | 1603 | case 0x2D: |
1561 | case 0x3E: | 1604 | case 0x3E: |
1562 | do_rapl = RAPL_PKG | RAPL_CORES | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS; | 1605 | do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS | RAPL_PKG_POWER_INFO; |
1606 | break; | ||
1607 | case 0x37: /* BYT */ | ||
1608 | case 0x4D: /* AVN */ | ||
1609 | do_rapl = RAPL_PKG | RAPL_CORES ; | ||
1563 | break; | 1610 | break; |
1564 | default: | 1611 | default: |
1565 | return; | 1612 | return; |
@@ -1570,19 +1617,22 @@ void rapl_probe(unsigned int family, unsigned int model) | |||
1570 | return; | 1617 | return; |
1571 | 1618 | ||
1572 | rapl_power_units = 1.0 / (1 << (msr & 0xF)); | 1619 | rapl_power_units = 1.0 / (1 << (msr & 0xF)); |
1573 | rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); | 1620 | if (model == 0x37) |
1574 | rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF)); | 1621 | rapl_energy_units = 1.0 * (1 << (msr >> 8 & 0x1F)) / 1000000; |
1622 | else | ||
1623 | rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); | ||
1575 | 1624 | ||
1576 | /* get TDP to determine energy counter range */ | 1625 | time_unit = msr >> 16 & 0xF; |
1577 | if (get_msr(0, MSR_PKG_POWER_INFO, &msr)) | 1626 | if (time_unit == 0) |
1578 | return; | 1627 | time_unit = 0xA; |
1579 | 1628 | ||
1580 | tdp = ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; | 1629 | rapl_time_units = 1.0 / (1 << (time_unit)); |
1581 | 1630 | ||
1582 | rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp; | 1631 | tdp = get_tdp(model); |
1583 | 1632 | ||
1633 | rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp; | ||
1584 | if (verbose) | 1634 | if (verbose) |
1585 | fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range\n", rapl_joule_counter_range); | 1635 | fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp); |
1586 | 1636 | ||
1587 | return; | 1637 | return; |
1588 | } | 1638 | } |
@@ -1668,7 +1718,6 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1668 | { | 1718 | { |
1669 | unsigned long long msr; | 1719 | unsigned long long msr; |
1670 | int cpu; | 1720 | int cpu; |
1671 | double local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units; | ||
1672 | 1721 | ||
1673 | if (!do_rapl) | 1722 | if (!do_rapl) |
1674 | return 0; | 1723 | return 0; |
@@ -1686,23 +1735,13 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1686 | if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) | 1735 | if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) |
1687 | return -1; | 1736 | return -1; |
1688 | 1737 | ||
1689 | local_rapl_power_units = 1.0 / (1 << (msr & 0xF)); | ||
1690 | local_rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); | ||
1691 | local_rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF)); | ||
1692 | |||
1693 | if (local_rapl_power_units != rapl_power_units) | ||
1694 | fprintf(stderr, "cpu%d, ERROR: Power units mis-match\n", cpu); | ||
1695 | if (local_rapl_energy_units != rapl_energy_units) | ||
1696 | fprintf(stderr, "cpu%d, ERROR: Energy units mis-match\n", cpu); | ||
1697 | if (local_rapl_time_units != rapl_time_units) | ||
1698 | fprintf(stderr, "cpu%d, ERROR: Time units mis-match\n", cpu); | ||
1699 | |||
1700 | if (verbose) { | 1738 | if (verbose) { |
1701 | fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx " | 1739 | fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx " |
1702 | "(%f Watts, %f Joules, %f sec.)\n", cpu, msr, | 1740 | "(%f Watts, %f Joules, %f sec.)\n", cpu, msr, |
1703 | local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units); | 1741 | rapl_power_units, rapl_energy_units, rapl_time_units); |
1704 | } | 1742 | } |
1705 | if (do_rapl & RAPL_PKG) { | 1743 | if (do_rapl & RAPL_PKG_POWER_INFO) { |
1744 | |||
1706 | if (get_msr(cpu, MSR_PKG_POWER_INFO, &msr)) | 1745 | if (get_msr(cpu, MSR_PKG_POWER_INFO, &msr)) |
1707 | return -5; | 1746 | return -5; |
1708 | 1747 | ||
@@ -1714,6 +1753,9 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1714 | ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, | 1753 | ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, |
1715 | ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); | 1754 | ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); |
1716 | 1755 | ||
1756 | } | ||
1757 | if (do_rapl & RAPL_PKG) { | ||
1758 | |||
1717 | if (get_msr(cpu, MSR_PKG_POWER_LIMIT, &msr)) | 1759 | if (get_msr(cpu, MSR_PKG_POWER_LIMIT, &msr)) |
1718 | return -9; | 1760 | return -9; |
1719 | 1761 | ||
@@ -1749,12 +1791,16 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
1749 | 1791 | ||
1750 | print_power_limit_msr(cpu, msr, "DRAM Limit"); | 1792 | print_power_limit_msr(cpu, msr, "DRAM Limit"); |
1751 | } | 1793 | } |
1752 | if (do_rapl & RAPL_CORES) { | 1794 | if (do_rapl & RAPL_CORE_POLICY) { |
1753 | if (verbose) { | 1795 | if (verbose) { |
1754 | if (get_msr(cpu, MSR_PP0_POLICY, &msr)) | 1796 | if (get_msr(cpu, MSR_PP0_POLICY, &msr)) |
1755 | return -7; | 1797 | return -7; |
1756 | 1798 | ||
1757 | fprintf(stderr, "cpu%d: MSR_PP0_POLICY: %lld\n", cpu, msr & 0xF); | 1799 | fprintf(stderr, "cpu%d: MSR_PP0_POLICY: %lld\n", cpu, msr & 0xF); |
1800 | } | ||
1801 | } | ||
1802 | if (do_rapl & RAPL_CORES) { | ||
1803 | if (verbose) { | ||
1758 | 1804 | ||
1759 | if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) | 1805 | if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) |
1760 | return -9; | 1806 | return -9; |
@@ -1813,10 +1859,48 @@ int has_c8_c9_c10(unsigned int family, unsigned int model) | |||
1813 | } | 1859 | } |
1814 | 1860 | ||
1815 | 1861 | ||
1862 | int is_slm(unsigned int family, unsigned int model) | ||
1863 | { | ||
1864 | if (!genuine_intel) | ||
1865 | return 0; | ||
1866 | switch (model) { | ||
1867 | case 0x37: /* BYT */ | ||
1868 | case 0x4D: /* AVN */ | ||
1869 | return 1; | ||
1870 | } | ||
1871 | return 0; | ||
1872 | } | ||
1873 | |||
1874 | #define SLM_BCLK_FREQS 5 | ||
1875 | double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0}; | ||
1876 | |||
1877 | double slm_bclk(void) | ||
1878 | { | ||
1879 | unsigned long long msr = 3; | ||
1880 | unsigned int i; | ||
1881 | double freq; | ||
1882 | |||
1883 | if (get_msr(0, MSR_FSB_FREQ, &msr)) | ||
1884 | fprintf(stderr, "SLM BCLK: unknown\n"); | ||
1885 | |||
1886 | i = msr & 0xf; | ||
1887 | if (i >= SLM_BCLK_FREQS) { | ||
1888 | fprintf(stderr, "SLM BCLK[%d] invalid\n", i); | ||
1889 | msr = 3; | ||
1890 | } | ||
1891 | freq = slm_freq_table[i]; | ||
1892 | |||
1893 | fprintf(stderr, "SLM BCLK: %.1f Mhz\n", freq); | ||
1894 | |||
1895 | return freq; | ||
1896 | } | ||
1897 | |||
1816 | double discover_bclk(unsigned int family, unsigned int model) | 1898 | double discover_bclk(unsigned int family, unsigned int model) |
1817 | { | 1899 | { |
1818 | if (is_snb(family, model)) | 1900 | if (is_snb(family, model)) |
1819 | return 100.00; | 1901 | return 100.00; |
1902 | else if (is_slm(family, model)) | ||
1903 | return slm_bclk(); | ||
1820 | else | 1904 | else |
1821 | return 133.33; | 1905 | return 133.33; |
1822 | } | 1906 | } |
@@ -1873,7 +1957,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk | |||
1873 | fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", | 1957 | fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", |
1874 | cpu, msr, target_c_local); | 1958 | cpu, msr, target_c_local); |
1875 | 1959 | ||
1876 | if (target_c_local < 85 || target_c_local > 120) | 1960 | if (target_c_local < 85 || target_c_local > 127) |
1877 | goto guess; | 1961 | goto guess; |
1878 | 1962 | ||
1879 | tcc_activation_temp = target_c_local; | 1963 | tcc_activation_temp = target_c_local; |
@@ -1970,6 +2054,7 @@ void check_cpuid() | |||
1970 | do_smi = do_nhm_cstates; | 2054 | do_smi = do_nhm_cstates; |
1971 | do_snb_cstates = is_snb(family, model); | 2055 | do_snb_cstates = is_snb(family, model); |
1972 | do_c8_c9_c10 = has_c8_c9_c10(family, model); | 2056 | do_c8_c9_c10 = has_c8_c9_c10(family, model); |
2057 | do_slm_cstates = is_slm(family, model); | ||
1973 | bclk = discover_bclk(family, model); | 2058 | bclk = discover_bclk(family, model); |
1974 | 2059 | ||
1975 | do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); | 2060 | do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); |
@@ -2331,7 +2416,7 @@ int main(int argc, char **argv) | |||
2331 | cmdline(argc, argv); | 2416 | cmdline(argc, argv); |
2332 | 2417 | ||
2333 | if (verbose) | 2418 | if (verbose) |
2334 | fprintf(stderr, "turbostat v3.4 April 17, 2013" | 2419 | fprintf(stderr, "turbostat v3.5 April 26, 2013" |
2335 | " - Len Brown <lenb@kernel.org>\n"); | 2420 | " - Len Brown <lenb@kernel.org>\n"); |
2336 | 2421 | ||
2337 | turbostat_init(); | 2422 | turbostat_init(); |
diff --git a/tools/usb/Makefile b/tools/usb/Makefile index 396d6c44e9d7..acf2165c04e6 100644 --- a/tools/usb/Makefile +++ b/tools/usb/Makefile | |||
@@ -3,11 +3,12 @@ | |||
3 | CC = $(CROSS_COMPILE)gcc | 3 | CC = $(CROSS_COMPILE)gcc |
4 | PTHREAD_LIBS = -lpthread | 4 | PTHREAD_LIBS = -lpthread |
5 | WARNINGS = -Wall -Wextra | 5 | WARNINGS = -Wall -Wextra |
6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include | 6 | CFLAGS = $(WARNINGS) -g -I../include |
7 | LDFLAGS = $(PTHREAD_LIBS) | ||
7 | 8 | ||
8 | all: testusb ffs-test | 9 | all: testusb ffs-test |
9 | %: %.c | 10 | %: %.c |
10 | $(CC) $(CFLAGS) -o $@ $^ | 11 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) |
11 | 12 | ||
12 | clean: | 13 | clean: |
13 | $(RM) testusb ffs-test | 14 | $(RM) testusb ffs-test |