aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-05-11 10:05:09 -0400
committerIngo Molnar <mingo@kernel.org>2015-05-11 10:05:09 -0400
commit191a66353b22fad8ac89404ab4c929cbe7b0afb2 (patch)
treebd7affc4bc640eb42e5ff3285922497285f8fdd7 /tools
parentf5d6a52f511157c7476590532a23b5664b1ed877 (diff)
parentf21262b8e092a770e39fbd405cc18a0247c3af68 (diff)
Merge branch 'x86/asm' into x86/apic, to resolve a conflict
Conflicts: arch/x86/kernel/apic/io_apic.c arch/x86/kernel/apic/vector.c Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/hv/Makefile2
-rw-r--r--tools/hv/hv_vss_daemon.c10
-rw-r--r--tools/lib/api/Makefile2
-rw-r--r--tools/lib/traceevent/event-parse.c2
-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/cpupower/utils/helpers/pci.c11
-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/Makefile5
-rw-r--r--tools/testing/selftests/x86/run_x86_tests.sh2
-rw-r--r--tools/testing/selftests/x86/sysret_ss_attrs.c112
-rw-r--r--tools/testing/selftests/x86/thunks.S67
19 files changed, 269 insertions, 53 deletions
diff --git a/tools/hv/Makefile b/tools/hv/Makefile
index 99ffe61051a7..a8ab79556926 100644
--- a/tools/hv/Makefile
+++ b/tools/hv/Makefile
@@ -3,7 +3,7 @@
3CC = $(CROSS_COMPILE)gcc 3CC = $(CROSS_COMPILE)gcc
4PTHREAD_LIBS = -lpthread 4PTHREAD_LIBS = -lpthread
5WARNINGS = -Wall -Wextra 5WARNINGS = -Wall -Wextra
6CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) 6CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) $(shell getconf LFS_CFLAGS)
7 7
8all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon 8all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
9%: %.c 9%: %.c
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 5e63f70bd956..506dd0148828 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -81,6 +81,7 @@ static int vss_operate(int operation)
81 char match[] = "/dev/"; 81 char match[] = "/dev/";
82 FILE *mounts; 82 FILE *mounts;
83 struct mntent *ent; 83 struct mntent *ent;
84 char errdir[1024] = {0};
84 unsigned int cmd; 85 unsigned int cmd;
85 int error = 0, root_seen = 0, save_errno = 0; 86 int error = 0, root_seen = 0, save_errno = 0;
86 87
@@ -115,6 +116,8 @@ static int vss_operate(int operation)
115 goto err; 116 goto err;
116 } 117 }
117 118
119 endmntent(mounts);
120
118 if (root_seen) { 121 if (root_seen) {
119 error |= vss_do_freeze("/", cmd); 122 error |= vss_do_freeze("/", cmd);
120 if (error && operation == VSS_OP_FREEZE) 123 if (error && operation == VSS_OP_FREEZE)
@@ -124,16 +127,19 @@ static int vss_operate(int operation)
124 goto out; 127 goto out;
125err: 128err:
126 save_errno = errno; 129 save_errno = errno;
130 if (ent) {
131 strncpy(errdir, ent->mnt_dir, sizeof(errdir)-1);
132 endmntent(mounts);
133 }
127 vss_operate(VSS_OP_THAW); 134 vss_operate(VSS_OP_THAW);
128 /* Call syslog after we thaw all filesystems */ 135 /* Call syslog after we thaw all filesystems */
129 if (ent) 136 if (ent)
130 syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s", 137 syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
131 ent->mnt_dir, save_errno, strerror(save_errno)); 138 errdir, save_errno, strerror(save_errno));
132 else 139 else
133 syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno, 140 syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno,
134 strerror(save_errno)); 141 strerror(save_errno));
135out: 142out:
136 endmntent(mounts);
137 return error; 143 return error;
138} 144}
139 145
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/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/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/cpupower/utils/helpers/pci.c b/tools/power/cpupower/utils/helpers/pci.c
index 9690798e6446..8b278983cfc5 100644
--- a/tools/power/cpupower/utils/helpers/pci.c
+++ b/tools/power/cpupower/utils/helpers/pci.c
@@ -25,14 +25,21 @@
25struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus, 25struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus,
26 int slot, int func, int vendor, int dev) 26 int slot, int func, int vendor, int dev)
27{ 27{
28 struct pci_filter filter_nb_link = { domain, bus, slot, func, 28 struct pci_filter filter_nb_link;
29 vendor, dev };
30 struct pci_dev *device; 29 struct pci_dev *device;
31 30
32 *pacc = pci_alloc(); 31 *pacc = pci_alloc();
33 if (*pacc == NULL) 32 if (*pacc == NULL)
34 return NULL; 33 return NULL;
35 34
35 pci_filter_init(*pacc, &filter_nb_link);
36 filter_nb_link.domain = domain;
37 filter_nb_link.bus = bus;
38 filter_nb_link.slot = slot;
39 filter_nb_link.func = func;
40 filter_nb_link.vendor = vendor;
41 filter_nb_link.device = dev;
42
36 pci_init(*pacc); 43 pci_init(*pacc);
37 pci_scan_bus(*pacc); 44 pci_scan_bus(*pacc);
38 45
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..9309097f58e8 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -1,6 +1,6 @@
1.PHONY: all all_32 all_64 check_build32 clean run_tests 1.PHONY: all all_32 all_64 check_build32 clean run_tests
2 2
3TARGETS_C_BOTHBITS := sigreturn single_step_syscall 3TARGETS_C_BOTHBITS := sigreturn single_step_syscall sysret_ss_attrs
4 4
5BINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32) 5BINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32)
6BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64) 6BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
@@ -46,3 +46,6 @@ check_build32:
46 echo " yum install glibc-devel.*i686"; \ 46 echo " yum install glibc-devel.*i686"; \
47 exit 1; \ 47 exit 1; \
48 fi 48 fi
49
50# Some tests have additional dependencies.
51sysret_ss_attrs_64: thunks.S
diff --git a/tools/testing/selftests/x86/run_x86_tests.sh b/tools/testing/selftests/x86/run_x86_tests.sh
index 3fc19b376812..d25034280dd5 100644
--- a/tools/testing/selftests/x86/run_x86_tests.sh
+++ b/tools/testing/selftests/x86/run_x86_tests.sh
@@ -4,10 +4,12 @@
4# script here. 4# script here.
5./sigreturn_32 || exit 1 5./sigreturn_32 || exit 1
6./single_step_syscall_32 || exit 1 6./single_step_syscall_32 || exit 1
7./sysret_ss_attrs_32 || exit 1
7 8
8if [[ "$uname -p" -eq "x86_64" ]]; then 9if [[ "$uname -p" -eq "x86_64" ]]; then
9 ./sigreturn_64 || exit 1 10 ./sigreturn_64 || exit 1
10 ./single_step_syscall_64 || exit 1 11 ./single_step_syscall_64 || exit 1
12 ./sysret_ss_attrs_64 || exit 1
11fi 13fi
12 14
13exit 0 15exit 0
diff --git a/tools/testing/selftests/x86/sysret_ss_attrs.c b/tools/testing/selftests/x86/sysret_ss_attrs.c
new file mode 100644
index 000000000000..ce42d5a64009
--- /dev/null
+++ b/tools/testing/selftests/x86/sysret_ss_attrs.c
@@ -0,0 +1,112 @@
1/*
2 * sysret_ss_attrs.c - test that syscalls return valid hidden SS attributes
3 * Copyright (c) 2015 Andrew Lutomirski
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * On AMD CPUs, SYSRET can return with a valid SS descriptor with with
15 * the hidden attributes set to an unusable state. Make sure the kernel
16 * doesn't let this happen.
17 */
18
19#define _GNU_SOURCE
20
21#include <stdlib.h>
22#include <unistd.h>
23#include <stdio.h>
24#include <string.h>
25#include <sys/mman.h>
26#include <err.h>
27#include <stddef.h>
28#include <stdbool.h>
29#include <pthread.h>
30
31static void *threadproc(void *ctx)
32{
33 /*
34 * Do our best to cause sleeps on this CPU to exit the kernel and
35 * re-enter with SS = 0.
36 */
37 while (true)
38 ;
39
40 return NULL;
41}
42
43#ifdef __x86_64__
44extern unsigned long call32_from_64(void *stack, void (*function)(void));
45
46asm (".pushsection .text\n\t"
47 ".code32\n\t"
48 "test_ss:\n\t"
49 "pushl $0\n\t"
50 "popl %eax\n\t"
51 "ret\n\t"
52 ".code64");
53extern void test_ss(void);
54#endif
55
56int main()
57{
58 /*
59 * Start a busy-looping thread on the same CPU we're on.
60 * For simplicity, just stick everything to CPU 0. This will
61 * fail in some containers, but that's probably okay.
62 */
63 cpu_set_t cpuset;
64 CPU_ZERO(&cpuset);
65 CPU_SET(0, &cpuset);
66 if (sched_setaffinity(0, sizeof(cpuset), &cpuset) != 0)
67 printf("[WARN]\tsched_setaffinity failed\n");
68
69 pthread_t thread;
70 if (pthread_create(&thread, 0, threadproc, 0) != 0)
71 err(1, "pthread_create");
72
73#ifdef __x86_64__
74 unsigned char *stack32 = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
75 MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE,
76 -1, 0);
77 if (stack32 == MAP_FAILED)
78 err(1, "mmap");
79#endif
80
81 printf("[RUN]\tSyscalls followed by SS validation\n");
82
83 for (int i = 0; i < 1000; i++) {
84 /*
85 * Go to sleep and return using sysret (if we're 64-bit
86 * or we're 32-bit on AMD on a 64-bit kernel). On AMD CPUs,
87 * SYSRET doesn't fix up the cached SS descriptor, so the
88 * kernel needs some kind of workaround to make sure that we
89 * end the system call with a valid stack segment. This
90 * can be a confusing failure because the SS *selector*
91 * is the same regardless.
92 */
93 usleep(2);
94
95#ifdef __x86_64__
96 /*
97 * On 32-bit, just doing a syscall through glibc is enough
98 * to cause a crash if our cached SS descriptor is invalid.
99 * On 64-bit, it's not, so try extra hard.
100 */
101 call32_from_64(stack32 + 4088, test_ss);
102#endif
103 }
104
105 printf("[OK]\tWe survived\n");
106
107#ifdef __x86_64__
108 munmap(stack32, 4096);
109#endif
110
111 return 0;
112}
diff --git a/tools/testing/selftests/x86/thunks.S b/tools/testing/selftests/x86/thunks.S
new file mode 100644
index 000000000000..ce8a995bbb17
--- /dev/null
+++ b/tools/testing/selftests/x86/thunks.S
@@ -0,0 +1,67 @@
1/*
2 * thunks.S - assembly helpers for mixed-bitness code
3 * Copyright (c) 2015 Andrew Lutomirski
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * These are little helpers that make it easier to switch bitness on
15 * the fly.
16 */
17
18 .text
19
20 .global call32_from_64
21 .type call32_from_64, @function
22call32_from_64:
23 // rdi: stack to use
24 // esi: function to call
25
26 // Save registers
27 pushq %rbx
28 pushq %rbp
29 pushq %r12
30 pushq %r13
31 pushq %r14
32 pushq %r15
33 pushfq
34
35 // Switch stacks
36 mov %rsp,(%rdi)
37 mov %rdi,%rsp
38
39 // Switch to compatibility mode
40 pushq $0x23 /* USER32_CS */
41 pushq $1f
42 lretq
43
441:
45 .code32
46 // Call the function
47 call *%esi
48 // Switch back to long mode
49 jmp $0x33,$1f
50 .code64
51
521:
53 // Restore the stack
54 mov (%rsp),%rsp
55
56 // Restore registers
57 popfq
58 popq %r15
59 popq %r14
60 popq %r13
61 popq %r12
62 popq %rbp
63 popq %rbx
64
65 ret
66
67.size call32_from_64, .-call32_from_64