aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-06-10 13:31:55 -0400
committerMark Brown <broonie@kernel.org>2015-06-10 13:31:55 -0400
commit5ae4f63b5062bc4e329940cc5cecdf0856b85849 (patch)
tree63f389874f6d330f84a9d36abec2c127bd71066e /tools
parentfb5ab0e7473d41e2a9db0fcb569faf337d595838 (diff)
parent11e688862c4c8162119a4ca51c3326555966c8bb (diff)
Merge tag 'asoc-v4.2' into asoc-rt5645
ASoC: Updates for v4.2 The big thing this release has been Liam's addition of topology support to the core. We've also seen quite a bit of driver work and the continuation of Lars' refactoring for component support. - Support for loading ASoC topology maps from firmware, intended to be used to allow self-describing DSP firmware images to be built which can map controls added by the DSP to userspace without the kernel needing to know about individual DSP firmwares. - Lots of refactoring to avoid direct access to snd_soc_codec where it's not needed supporting future refactoring. - Big refactoring and cleanup serieses for the Wolfson ADSP and TI TAS2552 drivers. - Support for TI TAS571x power amplifiers. - Support for Qualcomm APQ8016 and ZTE ZX296702 SoCs. - Support for x86 systems with RT5650 and Qualcomm Storm.
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/api/Makefile2
-rw-r--r--tools/lib/lockdep/Makefile3
-rw-r--r--tools/lib/lockdep/uinclude/linux/kernel.h3
-rw-r--r--tools/lib/traceevent/event-parse.c2
-rw-r--r--tools/net/bpf_jit_disasm.c2
-rw-r--r--tools/perf/Makefile2
-rw-r--r--tools/perf/bench/futex-requeue.c15
-rw-r--r--tools/perf/bench/numa.c12
-rw-r--r--tools/perf/builtin-kmem.c58
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/builtin-trace.c10
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/probe-finder.c4
-rw-r--r--tools/power/x86/turbostat/turbostat.c224
-rw-r--r--tools/testing/selftests/powerpc/pmu/Makefile2
-rw-r--r--tools/testing/selftests/powerpc/tm/Makefile2
-rw-r--r--tools/testing/selftests/x86/Makefile53
-rwxr-xr-xtools/testing/selftests/x86/check_cc.sh16
-rw-r--r--tools/testing/selftests/x86/run_x86_tests.sh13
-rw-r--r--tools/testing/selftests/x86/trivial_32bit_program.c4
-rw-r--r--tools/testing/selftests/x86/trivial_64bit_program.c18
-rw-r--r--tools/thermal/tmon/Makefile8
-rw-r--r--tools/vm/Makefile2
24 files changed, 328 insertions, 133 deletions
diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index d8fe29fc19a4..8bd960658463 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -16,7 +16,7 @@ MAKEFLAGS += --no-print-directory
16LIBFILE = $(OUTPUT)libapi.a 16LIBFILE = $(OUTPUT)libapi.a
17 17
18CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 18CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
19CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -fPIC 19CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
20CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 20CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
21 21
22RM = rm -f 22RM = rm -f
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile
index 0c356fb65022..18ffccf00426 100644
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -14,9 +14,10 @@ define allow-override
14 $(eval $(1) = $(2))) 14 $(eval $(1) = $(2)))
15endef 15endef
16 16
17# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. 17# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
18$(call allow-override,CC,$(CROSS_COMPILE)gcc) 18$(call allow-override,CC,$(CROSS_COMPILE)gcc)
19$(call allow-override,AR,$(CROSS_COMPILE)ar) 19$(call allow-override,AR,$(CROSS_COMPILE)ar)
20$(call allow-override,LD,$(CROSS_COMPILE)ld)
20 21
21INSTALL = install 22INSTALL = install
22 23
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index a11e3c357be7..cd2cc59a5da7 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -28,6 +28,9 @@
28#define __init 28#define __init
29#define noinline 29#define noinline
30#define list_add_tail_rcu list_add_tail 30#define list_add_tail_rcu list_add_tail
31#define list_for_each_entry_rcu list_for_each_entry
32#define barrier()
33#define synchronize_sched()
31 34
32#ifndef CALLER_ADDR0 35#ifndef CALLER_ADDR0
33#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) 36#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index e0917c0f5d9f..29f94f6f0d9e 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3865,7 +3865,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3865 } else if (el_size == 4) { 3865 } else if (el_size == 4) {
3866 trace_seq_printf(s, "%u", *(uint32_t *)num); 3866 trace_seq_printf(s, "%u", *(uint32_t *)num);
3867 } else if (el_size == 8) { 3867 } else if (el_size == 8) {
3868 trace_seq_printf(s, "%lu", *(uint64_t *)num); 3868 trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
3869 } else { 3869 } else {
3870 trace_seq_printf(s, "BAD SIZE:%d 0x%x", 3870 trace_seq_printf(s, "BAD SIZE:%d 0x%x",
3871 el_size, *(uint8_t *)num); 3871 el_size, *(uint8_t *)num);
diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c
index c5baf9c591b7..618c2bcd4eab 100644
--- a/tools/net/bpf_jit_disasm.c
+++ b/tools/net/bpf_jit_disasm.c
@@ -123,6 +123,8 @@ static int get_last_jit_image(char *haystack, size_t hlen,
123 assert(ret == 0); 123 assert(ret == 0);
124 124
125 ptr = haystack; 125 ptr = haystack;
126 memset(pmatch, 0, sizeof(pmatch));
127
126 while (1) { 128 while (1) {
127 ret = regexec(&regex, ptr, 1, pmatch, 0); 129 ret = regexec(&regex, ptr, 1, pmatch, 0);
128 if (ret == 0) { 130 if (ret == 0) {
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index c699dc35eef9..d31a7bbd7cee 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -24,7 +24,7 @@ unexport MAKEFLAGS
24# (To override it, run 'make JOBS=1' and similar.) 24# (To override it, run 'make JOBS=1' and similar.)
25# 25#
26ifeq ($(JOBS),) 26ifeq ($(JOBS),)
27 JOBS := $(shell egrep -c '^processor|^CPU' /proc/cpuinfo 2>/dev/null) 27 JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
28 ifeq ($(JOBS),0) 28 ifeq ($(JOBS),0)
29 JOBS := 1 29 JOBS := 1
30 endif 30 endif
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
index bedff6b5b3cf..ad0d9b5342fb 100644
--- a/tools/perf/bench/futex-requeue.c
+++ b/tools/perf/bench/futex-requeue.c
@@ -132,6 +132,9 @@ int bench_futex_requeue(int argc, const char **argv,
132 if (!fshared) 132 if (!fshared)
133 futex_flag = FUTEX_PRIVATE_FLAG; 133 futex_flag = FUTEX_PRIVATE_FLAG;
134 134
135 if (nrequeue > nthreads)
136 nrequeue = nthreads;
137
135 printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), " 138 printf("Run summary [PID %d]: Requeuing %d threads (from [%s] %p to %p), "
136 "%d at a time.\n\n", getpid(), nthreads, 139 "%d at a time.\n\n", getpid(), nthreads,
137 fshared ? "shared":"private", &futex1, &futex2, nrequeue); 140 fshared ? "shared":"private", &futex1, &futex2, nrequeue);
@@ -161,20 +164,18 @@ int bench_futex_requeue(int argc, const char **argv,
161 164
162 /* Ok, all threads are patiently blocked, start requeueing */ 165 /* Ok, all threads are patiently blocked, start requeueing */
163 gettimeofday(&start, NULL); 166 gettimeofday(&start, NULL);
164 for (nrequeued = 0; nrequeued < nthreads; nrequeued += nrequeue) { 167 while (nrequeued < nthreads) {
165 /* 168 /*
166 * Do not wakeup any tasks blocked on futex1, allowing 169 * Do not wakeup any tasks blocked on futex1, allowing
167 * us to really measure futex_wait functionality. 170 * us to really measure futex_wait functionality.
168 */ 171 */
169 futex_cmp_requeue(&futex1, 0, &futex2, 0, 172 nrequeued += futex_cmp_requeue(&futex1, 0, &futex2, 0,
170 nrequeue, futex_flag); 173 nrequeue, futex_flag);
171 } 174 }
175
172 gettimeofday(&end, NULL); 176 gettimeofday(&end, NULL);
173 timersub(&end, &start, &runtime); 177 timersub(&end, &start, &runtime);
174 178
175 if (nrequeued > nthreads)
176 nrequeued = nthreads;
177
178 update_stats(&requeued_stats, nrequeued); 179 update_stats(&requeued_stats, nrequeued);
179 update_stats(&requeuetime_stats, runtime.tv_usec); 180 update_stats(&requeuetime_stats, runtime.tv_usec);
180 181
@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv,
184 } 185 }
185 186
186 /* everybody should be blocked on futex2, wake'em up */ 187 /* everybody should be blocked on futex2, wake'em up */
187 nrequeued = futex_wake(&futex2, nthreads, futex_flag); 188 nrequeued = futex_wake(&futex2, nrequeued, futex_flag);
188 if (nthreads != nrequeued) 189 if (nthreads != nrequeued)
189 warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads); 190 warnx("couldn't wakeup all tasks (%d/%d)", nrequeued, nthreads);
190 191
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index ebfa163b80b5..ba5efa4710b5 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -180,7 +180,7 @@ static const struct option options[] = {
180 OPT_INTEGER('H', "thp" , &p0.thp, "MADV_NOHUGEPAGE < 0 < MADV_HUGEPAGE"), 180 OPT_INTEGER('H', "thp" , &p0.thp, "MADV_NOHUGEPAGE < 0 < MADV_HUGEPAGE"),
181 OPT_BOOLEAN('c', "show_convergence", &p0.show_convergence, "show convergence details"), 181 OPT_BOOLEAN('c', "show_convergence", &p0.show_convergence, "show convergence details"),
182 OPT_BOOLEAN('m', "measure_convergence", &p0.measure_convergence, "measure convergence latency"), 182 OPT_BOOLEAN('m', "measure_convergence", &p0.measure_convergence, "measure convergence latency"),
183 OPT_BOOLEAN('q', "quiet" , &p0.show_quiet, "bzero the initial allocations"), 183 OPT_BOOLEAN('q', "quiet" , &p0.show_quiet, "quiet mode"),
184 OPT_BOOLEAN('S', "serialize-startup", &p0.serialize_startup,"serialize thread startup"), 184 OPT_BOOLEAN('S', "serialize-startup", &p0.serialize_startup,"serialize thread startup"),
185 185
186 /* Special option string parsing callbacks: */ 186 /* Special option string parsing callbacks: */
@@ -828,6 +828,9 @@ static int count_process_nodes(int process_nr)
828 td = g->threads + task_nr; 828 td = g->threads + task_nr;
829 829
830 node = numa_node_of_cpu(td->curr_cpu); 830 node = numa_node_of_cpu(td->curr_cpu);
831 if (node < 0) /* curr_cpu was likely still -1 */
832 return 0;
833
831 node_present[node] = 1; 834 node_present[node] = 1;
832 } 835 }
833 836
@@ -882,6 +885,11 @@ static void calc_convergence_compression(int *strong)
882 for (p = 0; p < g->p.nr_proc; p++) { 885 for (p = 0; p < g->p.nr_proc; p++) {
883 unsigned int nodes = count_process_nodes(p); 886 unsigned int nodes = count_process_nodes(p);
884 887
888 if (!nodes) {
889 *strong = 0;
890 return;
891 }
892
885 nodes_min = min(nodes, nodes_min); 893 nodes_min = min(nodes, nodes_min);
886 nodes_max = max(nodes, nodes_max); 894 nodes_max = max(nodes, nodes_max);
887 } 895 }
@@ -1395,7 +1403,7 @@ static void print_res(const char *name, double val,
1395 if (!name) 1403 if (!name)
1396 name = "main,"; 1404 name = "main,";
1397 1405
1398 if (g->p.show_quiet) 1406 if (!g->p.show_quiet)
1399 printf(" %-30s %15.3f, %-15s %s\n", name, val, txt_unit, txt_short); 1407 printf(" %-30s %15.3f, %-15s %s\n", name, val, txt_unit, txt_short);
1400 else 1408 else
1401 printf(" %14.3f %s\n", val, txt_long); 1409 printf(" %14.3f %s\n", val, txt_long);
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 63ea01349b6e..1634186d537c 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -319,7 +319,7 @@ static int page_stat_cmp(struct page_stat *a, struct page_stat *b)
319 return 0; 319 return 0;
320} 320}
321 321
322static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool create) 322static struct page_stat *search_page_alloc_stat(struct page_stat *pstat, bool create)
323{ 323{
324 struct rb_node **node = &page_alloc_tree.rb_node; 324 struct rb_node **node = &page_alloc_tree.rb_node;
325 struct rb_node *parent = NULL; 325 struct rb_node *parent = NULL;
@@ -331,7 +331,7 @@ static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool cre
331 parent = *node; 331 parent = *node;
332 data = rb_entry(*node, struct page_stat, node); 332 data = rb_entry(*node, struct page_stat, node);
333 333
334 cmp = page_stat_cmp(data, stat); 334 cmp = page_stat_cmp(data, pstat);
335 if (cmp < 0) 335 if (cmp < 0)
336 node = &parent->rb_left; 336 node = &parent->rb_left;
337 else if (cmp > 0) 337 else if (cmp > 0)
@@ -345,10 +345,10 @@ static struct page_stat *search_page_alloc_stat(struct page_stat *stat, bool cre
345 345
346 data = zalloc(sizeof(*data)); 346 data = zalloc(sizeof(*data));
347 if (data != NULL) { 347 if (data != NULL) {
348 data->page = stat->page; 348 data->page = pstat->page;
349 data->order = stat->order; 349 data->order = pstat->order;
350 data->gfp_flags = stat->gfp_flags; 350 data->gfp_flags = pstat->gfp_flags;
351 data->migrate_type = stat->migrate_type; 351 data->migrate_type = pstat->migrate_type;
352 352
353 rb_link_node(&data->node, parent, node); 353 rb_link_node(&data->node, parent, node);
354 rb_insert_color(&data->node, &page_alloc_tree); 354 rb_insert_color(&data->node, &page_alloc_tree);
@@ -375,7 +375,7 @@ static int perf_evsel__process_page_alloc_event(struct perf_evsel *evsel,
375 unsigned int migrate_type = perf_evsel__intval(evsel, sample, 375 unsigned int migrate_type = perf_evsel__intval(evsel, sample,
376 "migratetype"); 376 "migratetype");
377 u64 bytes = kmem_page_size << order; 377 u64 bytes = kmem_page_size << order;
378 struct page_stat *stat; 378 struct page_stat *pstat;
379 struct page_stat this = { 379 struct page_stat this = {
380 .order = order, 380 .order = order,
381 .gfp_flags = gfp_flags, 381 .gfp_flags = gfp_flags,
@@ -401,21 +401,21 @@ static int perf_evsel__process_page_alloc_event(struct perf_evsel *evsel,
401 * This is to find the current page (with correct gfp flags and 401 * This is to find the current page (with correct gfp flags and
402 * migrate type) at free event. 402 * migrate type) at free event.
403 */ 403 */
404 stat = search_page(page, true); 404 pstat = search_page(page, true);
405 if (stat == NULL) 405 if (pstat == NULL)
406 return -ENOMEM; 406 return -ENOMEM;
407 407
408 stat->order = order; 408 pstat->order = order;
409 stat->gfp_flags = gfp_flags; 409 pstat->gfp_flags = gfp_flags;
410 stat->migrate_type = migrate_type; 410 pstat->migrate_type = migrate_type;
411 411
412 this.page = page; 412 this.page = page;
413 stat = search_page_alloc_stat(&this, true); 413 pstat = search_page_alloc_stat(&this, true);
414 if (stat == NULL) 414 if (pstat == NULL)
415 return -ENOMEM; 415 return -ENOMEM;
416 416
417 stat->nr_alloc++; 417 pstat->nr_alloc++;
418 stat->alloc_bytes += bytes; 418 pstat->alloc_bytes += bytes;
419 419
420 order_stats[order][migrate_type]++; 420 order_stats[order][migrate_type]++;
421 421
@@ -428,7 +428,7 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
428 u64 page; 428 u64 page;
429 unsigned int order = perf_evsel__intval(evsel, sample, "order"); 429 unsigned int order = perf_evsel__intval(evsel, sample, "order");
430 u64 bytes = kmem_page_size << order; 430 u64 bytes = kmem_page_size << order;
431 struct page_stat *stat; 431 struct page_stat *pstat;
432 struct page_stat this = { 432 struct page_stat this = {
433 .order = order, 433 .order = order,
434 }; 434 };
@@ -441,8 +441,8 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
441 nr_page_frees++; 441 nr_page_frees++;
442 total_page_free_bytes += bytes; 442 total_page_free_bytes += bytes;
443 443
444 stat = search_page(page, false); 444 pstat = search_page(page, false);
445 if (stat == NULL) { 445 if (pstat == NULL) {
446 pr_debug2("missing free at page %"PRIx64" (order: %d)\n", 446 pr_debug2("missing free at page %"PRIx64" (order: %d)\n",
447 page, order); 447 page, order);
448 448
@@ -453,18 +453,18 @@ static int perf_evsel__process_page_free_event(struct perf_evsel *evsel,
453 } 453 }
454 454
455 this.page = page; 455 this.page = page;
456 this.gfp_flags = stat->gfp_flags; 456 this.gfp_flags = pstat->gfp_flags;
457 this.migrate_type = stat->migrate_type; 457 this.migrate_type = pstat->migrate_type;
458 458
459 rb_erase(&stat->node, &page_tree); 459 rb_erase(&pstat->node, &page_tree);
460 free(stat); 460 free(pstat);
461 461
462 stat = search_page_alloc_stat(&this, false); 462 pstat = search_page_alloc_stat(&this, false);
463 if (stat == NULL) 463 if (pstat == NULL)
464 return -ENOENT; 464 return -ENOENT;
465 465
466 stat->nr_free++; 466 pstat->nr_free++;
467 stat->free_bytes += bytes; 467 pstat->free_bytes += bytes;
468 468
469 return 0; 469 return 0;
470} 470}
@@ -640,9 +640,9 @@ static void print_page_summary(void)
640 nr_page_frees, total_page_free_bytes / 1024); 640 nr_page_frees, total_page_free_bytes / 1024);
641 printf("\n"); 641 printf("\n");
642 642
643 printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total alloc+freed requests", 643 printf("%-30s: %'16"PRIu64" [ %'16"PRIu64" KB ]\n", "Total alloc+freed requests",
644 nr_alloc_freed, (total_alloc_freed_bytes) / 1024); 644 nr_alloc_freed, (total_alloc_freed_bytes) / 1024);
645 printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total alloc-only requests", 645 printf("%-30s: %'16"PRIu64" [ %'16"PRIu64" KB ]\n", "Total alloc-only requests",
646 nr_page_allocs - nr_alloc_freed, 646 nr_page_allocs - nr_alloc_freed,
647 (total_page_alloc_bytes - total_alloc_freed_bytes) / 1024); 647 (total_page_alloc_bytes - total_alloc_freed_bytes) / 1024);
648 printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total free-only requests", 648 printf("%-30s: %'16lu [ %'16"PRIu64" KB ]\n", "Total free-only requests",
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 476cdf7afcca..b63aeda719be 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -329,7 +329,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
329 fprintf(stdout, "\n\n"); 329 fprintf(stdout, "\n\n");
330 } 330 }
331 331
332 if (sort_order == default_sort_order && 332 if (sort_order == NULL &&
333 parent_pattern == default_parent_pattern) { 333 parent_pattern == default_parent_pattern) {
334 fprintf(stdout, "#\n# (%s)\n#\n", help); 334 fprintf(stdout, "#\n# (%s)\n#\n", help);
335 335
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1cb3436276d1..6a4d5d41c671 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -733,7 +733,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
733"Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n" 733"Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
734"Check /proc/sys/kernel/kptr_restrict.\n\n" 734"Check /proc/sys/kernel/kptr_restrict.\n\n"
735"Kernel%s samples will not be resolved.\n", 735"Kernel%s samples will not be resolved.\n",
736 !RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION]) ? 736 al.map && !RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION]) ?
737 " modules" : ""); 737 " modules" : "");
738 if (use_browser <= 0) 738 if (use_browser <= 0)
739 sleep(5); 739 sleep(5);
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e124741be187..e122970361f2 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2241,10 +2241,11 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
2241 if (err < 0) 2241 if (err < 0)
2242 goto out_error_mmap; 2242 goto out_error_mmap;
2243 2243
2244 if (!target__none(&trace->opts.target))
2245 perf_evlist__enable(evlist);
2246
2244 if (forks) 2247 if (forks)
2245 perf_evlist__start_workload(evlist); 2248 perf_evlist__start_workload(evlist);
2246 else
2247 perf_evlist__enable(evlist);
2248 2249
2249 trace->multiple_threads = evlist->threads->map[0] == -1 || 2250 trace->multiple_threads = evlist->threads->map[0] == -1 ||
2250 evlist->threads->nr > 1 || 2251 evlist->threads->nr > 1 ||
@@ -2272,6 +2273,11 @@ next_event:
2272 2273
2273 if (interrupted) 2274 if (interrupted)
2274 goto out_disable; 2275 goto out_disable;
2276
2277 if (done && !draining) {
2278 perf_evlist__disable(evlist);
2279 draining = true;
2280 }
2275 } 2281 }
2276 } 2282 }
2277 2283
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d8bb616ff57c..d05b77cf35f7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1084,6 +1084,8 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
1084 * 1084 *
1085 * TODO:Group name support 1085 * TODO:Group name support
1086 */ 1086 */
1087 if (!arg)
1088 return -EINVAL;
1087 1089
1088 ptr = strpbrk(arg, ";=@+%"); 1090 ptr = strpbrk(arg, ";=@+%");
1089 if (ptr && *ptr == '=') { /* Event name */ 1091 if (ptr && *ptr == '=') { /* Event name */
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index b5bf9d5efeaf..2a76e14db732 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -578,10 +578,12 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
578 /* Search child die for local variables and parameters. */ 578 /* Search child die for local variables and parameters. */
579 if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) { 579 if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
580 /* Search again in global variables */ 580 /* Search again in global variables */
581 if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die)) 581 if (!die_find_variable_at(&pf->cu_die, pf->pvar->var,
582 0, &vr_die)) {
582 pr_warning("Failed to find '%s' in this function.\n", 583 pr_warning("Failed to find '%s' in this function.\n",
583 pf->pvar->var); 584 pf->pvar->var);
584 ret = -ENOENT; 585 ret = -ENOENT;
586 }
585 } 587 }
586 if (ret >= 0) 588 if (ret >= 0)
587 ret = convert_variable(&vr_die, pf); 589 ret = convert_variable(&vr_die, pf);
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index bac98ca3d4ca..323b65edfc97 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -52,6 +52,7 @@ unsigned int skip_c0;
52unsigned int skip_c1; 52unsigned int skip_c1;
53unsigned int do_nhm_cstates; 53unsigned int do_nhm_cstates;
54unsigned int do_snb_cstates; 54unsigned int do_snb_cstates;
55unsigned int do_knl_cstates;
55unsigned int do_pc2; 56unsigned int do_pc2;
56unsigned int do_pc3; 57unsigned int do_pc3;
57unsigned int do_pc6; 58unsigned int do_pc6;
@@ -91,6 +92,7 @@ unsigned int do_gfx_perf_limit_reasons;
91unsigned int do_ring_perf_limit_reasons; 92unsigned int do_ring_perf_limit_reasons;
92unsigned int crystal_hz; 93unsigned int crystal_hz;
93unsigned long long tsc_hz; 94unsigned long long tsc_hz;
95int base_cpu;
94 96
95#define RAPL_PKG (1 << 0) 97#define RAPL_PKG (1 << 0)
96 /* 0x610 MSR_PKG_POWER_LIMIT */ 98 /* 0x610 MSR_PKG_POWER_LIMIT */
@@ -316,7 +318,7 @@ void print_header(void)
316 318
317 if (do_nhm_cstates) 319 if (do_nhm_cstates)
318 outp += sprintf(outp, " CPU%%c1"); 320 outp += sprintf(outp, " CPU%%c1");
319 if (do_nhm_cstates && !do_slm_cstates) 321 if (do_nhm_cstates && !do_slm_cstates && !do_knl_cstates)
320 outp += sprintf(outp, " CPU%%c3"); 322 outp += sprintf(outp, " CPU%%c3");
321 if (do_nhm_cstates) 323 if (do_nhm_cstates)
322 outp += sprintf(outp, " CPU%%c6"); 324 outp += sprintf(outp, " CPU%%c6");
@@ -546,7 +548,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
546 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 548 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
547 goto done; 549 goto done;
548 550
549 if (do_nhm_cstates && !do_slm_cstates) 551 if (do_nhm_cstates && !do_slm_cstates && !do_knl_cstates)
550 outp += sprintf(outp, "%8.2f", 100.0 * c->c3/t->tsc); 552 outp += sprintf(outp, "%8.2f", 100.0 * c->c3/t->tsc);
551 if (do_nhm_cstates) 553 if (do_nhm_cstates)
552 outp += sprintf(outp, "%8.2f", 100.0 * c->c6/t->tsc); 554 outp += sprintf(outp, "%8.2f", 100.0 * c->c6/t->tsc);
@@ -1018,14 +1020,17 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
1018 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 1020 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
1019 return 0; 1021 return 0;
1020 1022
1021 if (do_nhm_cstates && !do_slm_cstates) { 1023 if (do_nhm_cstates && !do_slm_cstates && !do_knl_cstates) {
1022 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) 1024 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3))
1023 return -6; 1025 return -6;
1024 } 1026 }
1025 1027
1026 if (do_nhm_cstates) { 1028 if (do_nhm_cstates && !do_knl_cstates) {
1027 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) 1029 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6))
1028 return -7; 1030 return -7;
1031 } else if (do_knl_cstates) {
1032 if (get_msr(cpu, MSR_KNL_CORE_C6_RESIDENCY, &c->c6))
1033 return -7;
1029 } 1034 }
1030 1035
1031 if (do_snb_cstates) 1036 if (do_snb_cstates)
@@ -1150,7 +1155,7 @@ dump_nhm_platform_info(void)
1150 unsigned long long msr; 1155 unsigned long long msr;
1151 unsigned int ratio; 1156 unsigned int ratio;
1152 1157
1153 get_msr(0, MSR_NHM_PLATFORM_INFO, &msr); 1158 get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
1154 1159
1155 fprintf(stderr, "cpu0: MSR_NHM_PLATFORM_INFO: 0x%08llx\n", msr); 1160 fprintf(stderr, "cpu0: MSR_NHM_PLATFORM_INFO: 0x%08llx\n", msr);
1156 1161
@@ -1162,7 +1167,7 @@ dump_nhm_platform_info(void)
1162 fprintf(stderr, "%d * %.0f = %.0f MHz base frequency\n", 1167 fprintf(stderr, "%d * %.0f = %.0f MHz base frequency\n",
1163 ratio, bclk, ratio * bclk); 1168 ratio, bclk, ratio * bclk);
1164 1169
1165 get_msr(0, MSR_IA32_POWER_CTL, &msr); 1170 get_msr(base_cpu, MSR_IA32_POWER_CTL, &msr);
1166 fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", 1171 fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n",
1167 msr, msr & 0x2 ? "EN" : "DIS"); 1172 msr, msr & 0x2 ? "EN" : "DIS");
1168 1173
@@ -1175,7 +1180,7 @@ dump_hsw_turbo_ratio_limits(void)
1175 unsigned long long msr; 1180 unsigned long long msr;
1176 unsigned int ratio; 1181 unsigned int ratio;
1177 1182
1178 get_msr(0, MSR_TURBO_RATIO_LIMIT2, &msr); 1183 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT2, &msr);
1179 1184
1180 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT2: 0x%08llx\n", msr); 1185 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT2: 0x%08llx\n", msr);
1181 1186
@@ -1197,7 +1202,7 @@ dump_ivt_turbo_ratio_limits(void)
1197 unsigned long long msr; 1202 unsigned long long msr;
1198 unsigned int ratio; 1203 unsigned int ratio;
1199 1204
1200 get_msr(0, MSR_TURBO_RATIO_LIMIT1, &msr); 1205 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT1, &msr);
1201 1206
1202 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT1: 0x%08llx\n", msr); 1207 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT1: 0x%08llx\n", msr);
1203 1208
@@ -1249,7 +1254,7 @@ dump_nhm_turbo_ratio_limits(void)
1249 unsigned long long msr; 1254 unsigned long long msr;
1250 unsigned int ratio; 1255 unsigned int ratio;
1251 1256
1252 get_msr(0, MSR_TURBO_RATIO_LIMIT, &msr); 1257 get_msr(base_cpu, MSR_TURBO_RATIO_LIMIT, &msr);
1253 1258
1254 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT: 0x%08llx\n", msr); 1259 fprintf(stderr, "cpu0: MSR_TURBO_RATIO_LIMIT: 0x%08llx\n", msr);
1255 1260
@@ -1296,11 +1301,72 @@ dump_nhm_turbo_ratio_limits(void)
1296} 1301}
1297 1302
1298static void 1303static void
1304dump_knl_turbo_ratio_limits(void)
1305{
1306 int cores;
1307 unsigned int ratio;
1308 unsigned long long msr;
1309 int delta_cores;
1310 int delta_ratio;
1311 int i;
1312
1313 get_msr(base_cpu, MSR_NHM_TURBO_RATIO_LIMIT, &msr);
1314
1315 fprintf(stderr, "cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x%08llx\n",
1316 msr);
1317
1318 /**
1319 * Turbo encoding in KNL is as follows:
1320 * [7:0] -- Base value of number of active cores of bucket 1.
1321 * [15:8] -- Base value of freq ratio of bucket 1.
1322 * [20:16] -- +ve delta of number of active cores of bucket 2.
1323 * i.e. active cores of bucket 2 =
1324 * active cores of bucket 1 + delta
1325 * [23:21] -- Negative delta of freq ratio of bucket 2.
1326 * i.e. freq ratio of bucket 2 =
1327 * freq ratio of bucket 1 - delta
1328 * [28:24]-- +ve delta of number of active cores of bucket 3.
1329 * [31:29]-- -ve delta of freq ratio of bucket 3.
1330 * [36:32]-- +ve delta of number of active cores of bucket 4.
1331 * [39:37]-- -ve delta of freq ratio of bucket 4.
1332 * [44:40]-- +ve delta of number of active cores of bucket 5.
1333 * [47:45]-- -ve delta of freq ratio of bucket 5.
1334 * [52:48]-- +ve delta of number of active cores of bucket 6.
1335 * [55:53]-- -ve delta of freq ratio of bucket 6.
1336 * [60:56]-- +ve delta of number of active cores of bucket 7.
1337 * [63:61]-- -ve delta of freq ratio of bucket 7.
1338 */
1339 cores = msr & 0xFF;
1340 ratio = (msr >> 8) && 0xFF;
1341 if (ratio > 0)
1342 fprintf(stderr,
1343 "%d * %.0f = %.0f MHz max turbo %d active cores\n",
1344 ratio, bclk, ratio * bclk, cores);
1345
1346 for (i = 16; i < 64; i = i + 8) {
1347 delta_cores = (msr >> i) & 0x1F;
1348 delta_ratio = (msr >> (i + 5)) && 0x7;
1349 if (!delta_cores || !delta_ratio)
1350 return;
1351 cores = cores + delta_cores;
1352 ratio = ratio - delta_ratio;
1353
1354 /** -ve ratios will make successive ratio calculations
1355 * negative. Hence return instead of carrying on.
1356 */
1357 if (ratio > 0)
1358 fprintf(stderr,
1359 "%d * %.0f = %.0f MHz max turbo %d active cores\n",
1360 ratio, bclk, ratio * bclk, cores);
1361 }
1362}
1363
1364static void
1299dump_nhm_cst_cfg(void) 1365dump_nhm_cst_cfg(void)
1300{ 1366{
1301 unsigned long long msr; 1367 unsigned long long msr;
1302 1368
1303 get_msr(0, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr); 1369 get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
1304 1370
1305#define SNB_C1_AUTO_UNDEMOTE (1UL << 27) 1371#define SNB_C1_AUTO_UNDEMOTE (1UL << 27)
1306#define SNB_C3_AUTO_UNDEMOTE (1UL << 28) 1372#define SNB_C3_AUTO_UNDEMOTE (1UL << 28)
@@ -1381,12 +1447,41 @@ int parse_int_file(const char *fmt, ...)
1381} 1447}
1382 1448
1383/* 1449/*
1384 * cpu_is_first_sibling_in_core(cpu) 1450 * get_cpu_position_in_core(cpu)
1385 * return 1 if given CPU is 1st HT sibling in the core 1451 * return the position of the CPU among its HT siblings in the core
1452 * return -1 if the sibling is not in list
1386 */ 1453 */
1387int cpu_is_first_sibling_in_core(int cpu) 1454int get_cpu_position_in_core(int cpu)
1388{ 1455{
1389 return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu); 1456 char path[64];
1457 FILE *filep;
1458 int this_cpu;
1459 char character;
1460 int i;
1461
1462 sprintf(path,
1463 "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list",
1464 cpu);
1465 filep = fopen(path, "r");
1466 if (filep == NULL) {
1467 perror(path);
1468 exit(1);
1469 }
1470
1471 for (i = 0; i < topo.num_threads_per_core; i++) {
1472 fscanf(filep, "%d", &this_cpu);
1473 if (this_cpu == cpu) {
1474 fclose(filep);
1475 return i;
1476 }
1477
1478 /* Account for no separator after last thread*/
1479 if (i != (topo.num_threads_per_core - 1))
1480 fscanf(filep, "%c", &character);
1481 }
1482
1483 fclose(filep);
1484 return -1;
1390} 1485}
1391 1486
1392/* 1487/*
@@ -1412,25 +1507,31 @@ int get_num_ht_siblings(int cpu)
1412{ 1507{
1413 char path[80]; 1508 char path[80];
1414 FILE *filep; 1509 FILE *filep;
1415 int sib1, sib2; 1510 int sib1;
1416 int matches; 1511 int matches = 0;
1417 char character; 1512 char character;
1513 char str[100];
1514 char *ch;
1418 1515
1419 sprintf(path, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu); 1516 sprintf(path, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
1420 filep = fopen_or_die(path, "r"); 1517 filep = fopen_or_die(path, "r");
1518
1421 /* 1519 /*
1422 * file format: 1520 * file format:
1423 * if a pair of number with a character between: 2 siblings (eg. 1-2, or 1,4) 1521 * A ',' separated or '-' separated set of numbers
1424 * otherwinse 1 sibling (self). 1522 * (eg 1-2 or 1,3,4,5)
1425 */ 1523 */
1426 matches = fscanf(filep, "%d%c%d\n", &sib1, &character, &sib2); 1524 fscanf(filep, "%d%c\n", &sib1, &character);
1525 fseek(filep, 0, SEEK_SET);
1526 fgets(str, 100, filep);
1527 ch = strchr(str, character);
1528 while (ch != NULL) {
1529 matches++;
1530 ch = strchr(ch+1, character);
1531 }
1427 1532
1428 fclose(filep); 1533 fclose(filep);
1429 1534 return matches+1;
1430 if (matches == 3)
1431 return 2;
1432 else
1433 return 1;
1434} 1535}
1435 1536
1436/* 1537/*
@@ -1594,8 +1695,10 @@ restart:
1594void check_dev_msr() 1695void check_dev_msr()
1595{ 1696{
1596 struct stat sb; 1697 struct stat sb;
1698 char pathname[32];
1597 1699
1598 if (stat("/dev/cpu/0/msr", &sb)) 1700 sprintf(pathname, "/dev/cpu/%d/msr", base_cpu);
1701 if (stat(pathname, &sb))
1599 if (system("/sbin/modprobe msr > /dev/null 2>&1")) 1702 if (system("/sbin/modprobe msr > /dev/null 2>&1"))
1600 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); 1703 err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" ");
1601} 1704}
@@ -1608,6 +1711,7 @@ void check_permissions()
1608 cap_user_data_t cap_data = &cap_data_data; 1711 cap_user_data_t cap_data = &cap_data_data;
1609 extern int capget(cap_user_header_t hdrp, cap_user_data_t datap); 1712 extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
1610 int do_exit = 0; 1713 int do_exit = 0;
1714 char pathname[32];
1611 1715
1612 /* check for CAP_SYS_RAWIO */ 1716 /* check for CAP_SYS_RAWIO */
1613 cap_header->pid = getpid(); 1717 cap_header->pid = getpid();
@@ -1622,7 +1726,8 @@ void check_permissions()
1622 } 1726 }
1623 1727
1624 /* test file permissions */ 1728 /* test file permissions */
1625 if (euidaccess("/dev/cpu/0/msr", R_OK)) { 1729 sprintf(pathname, "/dev/cpu/%d/msr", base_cpu);
1730 if (euidaccess(pathname, R_OK)) {
1626 do_exit++; 1731 do_exit++;
1627 warn("/dev/cpu/0/msr open failed, try chown or chmod +r /dev/cpu/*/msr"); 1732 warn("/dev/cpu/0/msr open failed, try chown or chmod +r /dev/cpu/*/msr");
1628 } 1733 }
@@ -1704,7 +1809,7 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
1704 default: 1809 default:
1705 return 0; 1810 return 0;
1706 } 1811 }
1707 get_msr(0, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr); 1812 get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
1708 1813
1709 pkg_cstate_limit = pkg_cstate_limits[msr & 0xF]; 1814 pkg_cstate_limit = pkg_cstate_limits[msr & 0xF];
1710 1815
@@ -1753,6 +1858,21 @@ int has_hsw_turbo_ratio_limit(unsigned int family, unsigned int model)
1753 } 1858 }
1754} 1859}
1755 1860
1861int has_knl_turbo_ratio_limit(unsigned int family, unsigned int model)
1862{
1863 if (!genuine_intel)
1864 return 0;
1865
1866 if (family != 6)
1867 return 0;
1868
1869 switch (model) {
1870 case 0x57: /* Knights Landing */
1871 return 1;
1872 default:
1873 return 0;
1874 }
1875}
1756static void 1876static void
1757dump_cstate_pstate_config_info(family, model) 1877dump_cstate_pstate_config_info(family, model)
1758{ 1878{
@@ -1770,6 +1890,9 @@ dump_cstate_pstate_config_info(family, model)
1770 if (has_nhm_turbo_ratio_limit(family, model)) 1890 if (has_nhm_turbo_ratio_limit(family, model))
1771 dump_nhm_turbo_ratio_limits(); 1891 dump_nhm_turbo_ratio_limits();
1772 1892
1893 if (has_knl_turbo_ratio_limit(family, model))
1894 dump_knl_turbo_ratio_limits();
1895
1773 dump_nhm_cst_cfg(); 1896 dump_nhm_cst_cfg();
1774} 1897}
1775 1898
@@ -1801,7 +1924,7 @@ int print_epb(struct thread_data *t, struct core_data *c, struct pkg_data *p)
1801 if (get_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, &msr)) 1924 if (get_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, &msr))
1802 return 0; 1925 return 0;
1803 1926
1804 switch (msr & 0x7) { 1927 switch (msr & 0xF) {
1805 case ENERGY_PERF_BIAS_PERFORMANCE: 1928 case ENERGY_PERF_BIAS_PERFORMANCE:
1806 epb_string = "performance"; 1929 epb_string = "performance";
1807 break; 1930 break;
@@ -1925,7 +2048,7 @@ double get_tdp(model)
1925 unsigned long long msr; 2048 unsigned long long msr;
1926 2049
1927 if (do_rapl & RAPL_PKG_POWER_INFO) 2050 if (do_rapl & RAPL_PKG_POWER_INFO)
1928 if (!get_msr(0, MSR_PKG_POWER_INFO, &msr)) 2051 if (!get_msr(base_cpu, MSR_PKG_POWER_INFO, &msr))
1929 return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; 2052 return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units;
1930 2053
1931 switch (model) { 2054 switch (model) {
@@ -1950,6 +2073,7 @@ rapl_dram_energy_units_probe(int model, double rapl_energy_units)
1950 case 0x3F: /* HSX */ 2073 case 0x3F: /* HSX */
1951 case 0x4F: /* BDX */ 2074 case 0x4F: /* BDX */
1952 case 0x56: /* BDX-DE */ 2075 case 0x56: /* BDX-DE */
2076 case 0x57: /* KNL */
1953 return (rapl_dram_energy_units = 15.3 / 1000000); 2077 return (rapl_dram_energy_units = 15.3 / 1000000);
1954 default: 2078 default:
1955 return (rapl_energy_units); 2079 return (rapl_energy_units);
@@ -1991,6 +2115,7 @@ void rapl_probe(unsigned int family, unsigned int model)
1991 case 0x3F: /* HSX */ 2115 case 0x3F: /* HSX */
1992 case 0x4F: /* BDX */ 2116 case 0x4F: /* BDX */
1993 case 0x56: /* BDX-DE */ 2117 case 0x56: /* BDX-DE */
2118 case 0x57: /* KNL */
1994 do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_POWER_INFO | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO; 2119 do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_POWER_INFO | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO;
1995 break; 2120 break;
1996 case 0x2D: 2121 case 0x2D:
@@ -2006,7 +2131,7 @@ void rapl_probe(unsigned int family, unsigned int model)
2006 } 2131 }
2007 2132
2008 /* units on package 0, verify later other packages match */ 2133 /* units on package 0, verify later other packages match */
2009 if (get_msr(0, MSR_RAPL_POWER_UNIT, &msr)) 2134 if (get_msr(base_cpu, MSR_RAPL_POWER_UNIT, &msr))
2010 return; 2135 return;
2011 2136
2012 rapl_power_units = 1.0 / (1 << (msr & 0xF)); 2137 rapl_power_units = 1.0 / (1 << (msr & 0xF));
@@ -2331,6 +2456,17 @@ int is_slm(unsigned int family, unsigned int model)
2331 return 0; 2456 return 0;
2332} 2457}
2333 2458
2459int is_knl(unsigned int family, unsigned int model)
2460{
2461 if (!genuine_intel)
2462 return 0;
2463 switch (model) {
2464 case 0x57: /* KNL */
2465 return 1;
2466 }
2467 return 0;
2468}
2469
2334#define SLM_BCLK_FREQS 5 2470#define SLM_BCLK_FREQS 5
2335double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0}; 2471double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};
2336 2472
@@ -2340,7 +2476,7 @@ double slm_bclk(void)
2340 unsigned int i; 2476 unsigned int i;
2341 double freq; 2477 double freq;
2342 2478
2343 if (get_msr(0, MSR_FSB_FREQ, &msr)) 2479 if (get_msr(base_cpu, MSR_FSB_FREQ, &msr))
2344 fprintf(stderr, "SLM BCLK: unknown\n"); 2480 fprintf(stderr, "SLM BCLK: unknown\n");
2345 2481
2346 i = msr & 0xf; 2482 i = msr & 0xf;
@@ -2408,7 +2544,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
2408 if (!do_nhm_platform_info) 2544 if (!do_nhm_platform_info)
2409 goto guess; 2545 goto guess;
2410 2546
2411 if (get_msr(0, MSR_IA32_TEMPERATURE_TARGET, &msr)) 2547 if (get_msr(base_cpu, MSR_IA32_TEMPERATURE_TARGET, &msr))
2412 goto guess; 2548 goto guess;
2413 2549
2414 target_c_local = (msr >> 16) & 0xFF; 2550 target_c_local = (msr >> 16) & 0xFF;
@@ -2541,6 +2677,7 @@ void process_cpuid()
2541 do_c8_c9_c10 = has_hsw_msrs(family, model); 2677 do_c8_c9_c10 = has_hsw_msrs(family, model);
2542 do_skl_residency = has_skl_msrs(family, model); 2678 do_skl_residency = has_skl_msrs(family, model);
2543 do_slm_cstates = is_slm(family, model); 2679 do_slm_cstates = is_slm(family, model);
2680 do_knl_cstates = is_knl(family, model);
2544 bclk = discover_bclk(family, model); 2681 bclk = discover_bclk(family, model);
2545 2682
2546 rapl_probe(family, model); 2683 rapl_probe(family, model);
@@ -2755,13 +2892,9 @@ int initialize_counters(int cpu_id)
2755 2892
2756 my_package_id = get_physical_package_id(cpu_id); 2893 my_package_id = get_physical_package_id(cpu_id);
2757 my_core_id = get_core_id(cpu_id); 2894 my_core_id = get_core_id(cpu_id);
2758 2895 my_thread_id = get_cpu_position_in_core(cpu_id);
2759 if (cpu_is_first_sibling_in_core(cpu_id)) { 2896 if (!my_thread_id)
2760 my_thread_id = 0;
2761 topo.num_cores++; 2897 topo.num_cores++;
2762 } else {
2763 my_thread_id = 1;
2764 }
2765 2898
2766 init_counter(EVEN_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id); 2899 init_counter(EVEN_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id);
2767 init_counter(ODD_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id); 2900 init_counter(ODD_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id);
@@ -2785,13 +2918,24 @@ void setup_all_buffers(void)
2785 for_all_proc_cpus(initialize_counters); 2918 for_all_proc_cpus(initialize_counters);
2786} 2919}
2787 2920
2921void set_base_cpu(void)
2922{
2923 base_cpu = sched_getcpu();
2924 if (base_cpu < 0)
2925 err(-ENODEV, "No valid cpus found");
2926
2927 if (debug > 1)
2928 fprintf(stderr, "base_cpu = %d\n", base_cpu);
2929}
2930
2788void turbostat_init() 2931void turbostat_init()
2789{ 2932{
2933 setup_all_buffers();
2934 set_base_cpu();
2790 check_dev_msr(); 2935 check_dev_msr();
2791 check_permissions(); 2936 check_permissions();
2792 process_cpuid(); 2937 process_cpuid();
2793 2938
2794 setup_all_buffers();
2795 2939
2796 if (debug) 2940 if (debug)
2797 for_all_cpus(print_epb, ODD_COUNTERS); 2941 for_all_cpus(print_epb, ODD_COUNTERS);
@@ -2870,7 +3014,7 @@ int get_and_dump_counters(void)
2870} 3014}
2871 3015
2872void print_version() { 3016void print_version() {
2873 fprintf(stderr, "turbostat version 4.5 2 Apr, 2015" 3017 fprintf(stderr, "turbostat version 4.7 27-May, 2015"
2874 " - Len Brown <lenb@kernel.org>\n"); 3018 " - Len Brown <lenb@kernel.org>\n");
2875} 3019}
2876 3020
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile
index 5a161175bbd4..a9099d9f8f39 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -26,7 +26,7 @@ override define EMIT_TESTS
26 $(MAKE) -s -C ebb emit_tests 26 $(MAKE) -s -C ebb emit_tests
27endef 27endef
28 28
29DEFAULT_INSTALL := $(INSTALL_RULE) 29DEFAULT_INSTALL_RULE := $(INSTALL_RULE)
30override define INSTALL_RULE 30override define INSTALL_RULE
31 $(DEFAULT_INSTALL_RULE) 31 $(DEFAULT_INSTALL_RULE)
32 $(MAKE) -C ebb install 32 $(MAKE) -C ebb install
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 1b616fa79e93..6bff955e1d55 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -1,4 +1,4 @@
1TEST_PROGS := tm-resched-dscr tm-syscall 1TEST_PROGS := tm-resched-dscr
2 2
3all: $(TEST_PROGS) 3all: $(TEST_PROGS)
4 4
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index ddf63569df5a..5bdb781163d1 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -1,4 +1,8 @@
1.PHONY: all all_32 all_64 check_build32 clean run_tests 1all:
2
3include ../lib.mk
4
5.PHONY: all all_32 all_64 warn_32bit_failure clean
2 6
3TARGETS_C_BOTHBITS := sigreturn single_step_syscall 7TARGETS_C_BOTHBITS := sigreturn single_step_syscall
4 8
@@ -7,42 +11,47 @@ BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
7 11
8CFLAGS := -O2 -g -std=gnu99 -pthread -Wall 12CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
9 13
10UNAME_P := $(shell uname -p) 14UNAME_M := $(shell uname -m)
15CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
16CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
11 17
12# Always build 32-bit tests 18ifeq ($(CAN_BUILD_I386),1)
13all: all_32 19all: all_32
20TEST_PROGS += $(BINARIES_32)
21endif
14 22
15# If we're on a 64-bit host, build 64-bit tests as well 23ifeq ($(CAN_BUILD_X86_64),1)
16ifeq ($(shell uname -p),x86_64)
17all: all_64 24all: all_64
25TEST_PROGS += $(BINARIES_64)
18endif 26endif
19 27
20all_32: check_build32 $(BINARIES_32) 28all_32: $(BINARIES_32)
21 29
22all_64: $(BINARIES_64) 30all_64: $(BINARIES_64)
23 31
24clean: 32clean:
25 $(RM) $(BINARIES_32) $(BINARIES_64) 33 $(RM) $(BINARIES_32) $(BINARIES_64)
26 34
27run_tests:
28 ./run_x86_tests.sh
29
30$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c 35$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c
31 $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 36 $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
32 37
33$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c 38$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c
34 $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 39 $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
35 40
36check_build32: 41# x86_64 users should be encouraged to install 32-bit libraries
37 @if ! $(CC) -m32 -o /dev/null trivial_32bit_program.c; then \ 42ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
38 echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ 43all: warn_32bit_failure
39 echo "environment. If you are using a Debian-like"; \ 44
40 echo " distribution, try:"; \ 45warn_32bit_failure:
41 echo ""; \ 46 @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \
42 echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \ 47 echo "environment. This will reduce test coverage of 64-bit" 2>&1; \
43 echo ""; \ 48 echo "kernels. If you are using a Debian-like distribution," 2>&1; \
44 echo "If you are using a Fedora-like distribution, try:"; \ 49 echo "try:"; 2>&1; \
45 echo ""; \ 50 echo ""; \
46 echo " yum install glibc-devel.*i686"; \ 51 echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
47 exit 1; \ 52 echo ""; \
48 fi 53 echo "If you are using a Fedora-like distribution, try:"; \
54 echo ""; \
55 echo " yum install glibc-devel.*i686"; \
56 exit 0;
57endif
diff --git a/tools/testing/selftests/x86/check_cc.sh b/tools/testing/selftests/x86/check_cc.sh
new file mode 100755
index 000000000000..172d3293fb7b
--- /dev/null
+++ b/tools/testing/selftests/x86/check_cc.sh
@@ -0,0 +1,16 @@
1#!/bin/sh
2# check_cc.sh - Helper to test userspace compilation support
3# Copyright (c) 2015 Andrew Lutomirski
4# GPL v2
5
6CC="$1"
7TESTPROG="$2"
8shift 2
9
10if "$CC" -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then
11 echo 1
12else
13 echo 0
14fi
15
16exit 0
diff --git a/tools/testing/selftests/x86/run_x86_tests.sh b/tools/testing/selftests/x86/run_x86_tests.sh
deleted file mode 100644
index 3fc19b376812..000000000000
--- a/tools/testing/selftests/x86/run_x86_tests.sh
+++ /dev/null
@@ -1,13 +0,0 @@
1#!/bin/bash
2
3# This is deliberately minimal. IMO kselftests should provide a standard
4# script here.
5./sigreturn_32 || exit 1
6./single_step_syscall_32 || exit 1
7
8if [[ "$uname -p" -eq "x86_64" ]]; then
9 ./sigreturn_64 || exit 1
10 ./single_step_syscall_64 || exit 1
11fi
12
13exit 0
diff --git a/tools/testing/selftests/x86/trivial_32bit_program.c b/tools/testing/selftests/x86/trivial_32bit_program.c
index 2e231beb0a39..fabdf0f51621 100644
--- a/tools/testing/selftests/x86/trivial_32bit_program.c
+++ b/tools/testing/selftests/x86/trivial_32bit_program.c
@@ -4,6 +4,10 @@
4 * GPL v2 4 * GPL v2
5 */ 5 */
6 6
7#ifndef __i386__
8# error wrong architecture
9#endif
10
7#include <stdio.h> 11#include <stdio.h>
8 12
9int main() 13int main()
diff --git a/tools/testing/selftests/x86/trivial_64bit_program.c b/tools/testing/selftests/x86/trivial_64bit_program.c
new file mode 100644
index 000000000000..b994946c40fb
--- /dev/null
+++ b/tools/testing/selftests/x86/trivial_64bit_program.c
@@ -0,0 +1,18 @@
1/*
2 * Trivial program to check that we have a valid 32-bit build environment.
3 * Copyright (c) 2015 Andy Lutomirski
4 * GPL v2
5 */
6
7#ifndef __x86_64__
8# error wrong architecture
9#endif
10
11#include <stdio.h>
12
13int main()
14{
15 printf("\n");
16
17 return 0;
18}
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
index 0788621c8d76..2e83dd3655a2 100644
--- a/tools/thermal/tmon/Makefile
+++ b/tools/thermal/tmon/Makefile
@@ -12,10 +12,6 @@ TARGET=tmon
12INSTALL_PROGRAM=install -m 755 -p 12INSTALL_PROGRAM=install -m 755 -p
13DEL_FILE=rm -f 13DEL_FILE=rm -f
14 14
15INSTALL_CONFIGFILE=install -m 644 -p
16CONFIG_FILE=
17CONFIG_PATH=
18
19# Static builds might require -ltinfo, for instance 15# Static builds might require -ltinfo, for instance
20ifneq ($(findstring -static, $(LDFLAGS)),) 16ifneq ($(findstring -static, $(LDFLAGS)),)
21STATIC := --static 17STATIC := --static
@@ -38,13 +34,9 @@ valgrind: tmon
38install: 34install:
39 - mkdir -p $(INSTALL_ROOT)/$(BINDIR) 35 - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
40 - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 36 - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
41 - mkdir -p $(INSTALL_ROOT)/$(CONFIG_PATH)
42 - $(INSTALL_CONFIGFILE) "$(CONFIG_FILE)" "$(INSTALL_ROOT)/$(CONFIG_PATH)"
43 37
44uninstall: 38uninstall:
45 $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 39 $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
46 $(CONFIG_FILE) "$(CONFIG_PATH)"
47
48 40
49clean: 41clean:
50 find . -name "*.o" | xargs $(DEL_FILE) 42 find . -name "*.o" | xargs $(DEL_FILE)
diff --git a/tools/vm/Makefile b/tools/vm/Makefile
index ac884b65a072..93aadaf7ff63 100644
--- a/tools/vm/Makefile
+++ b/tools/vm/Makefile
@@ -3,7 +3,7 @@
3TARGETS=page-types slabinfo page_owner_sort 3TARGETS=page-types slabinfo page_owner_sort
4 4
5LIB_DIR = ../lib/api 5LIB_DIR = ../lib/api
6LIBS = $(LIB_DIR)/libapikfs.a 6LIBS = $(LIB_DIR)/libapi.a
7 7
8CC = $(CROSS_COMPILE)gcc 8CC = $(CROSS_COMPILE)gcc
9CFLAGS = -Wall -Wextra -I../lib/ 9CFLAGS = -Wall -Wextra -I../lib/