diff options
Diffstat (limited to 'tools')
48 files changed, 390 insertions, 223 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 2975632d51e2..c8fe6d177119 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature | |||
@@ -41,6 +41,7 @@ FEATURE_TESTS ?= \ | |||
41 | libelf-getphdrnum \ | 41 | libelf-getphdrnum \ |
42 | libelf-mmap \ | 42 | libelf-mmap \ |
43 | libnuma \ | 43 | libnuma \ |
44 | numa_num_possible_cpus \ | ||
44 | libperl \ | 45 | libperl \ |
45 | libpython \ | 46 | libpython \ |
46 | libpython-version \ | 47 | libpython-version \ |
@@ -51,7 +52,8 @@ FEATURE_TESTS ?= \ | |||
51 | timerfd \ | 52 | timerfd \ |
52 | libdw-dwarf-unwind \ | 53 | libdw-dwarf-unwind \ |
53 | zlib \ | 54 | zlib \ |
54 | lzma | 55 | lzma \ |
56 | get_cpuid | ||
55 | 57 | ||
56 | FEATURE_DISPLAY ?= \ | 58 | FEATURE_DISPLAY ?= \ |
57 | dwarf \ | 59 | dwarf \ |
@@ -61,13 +63,15 @@ FEATURE_DISPLAY ?= \ | |||
61 | libbfd \ | 63 | libbfd \ |
62 | libelf \ | 64 | libelf \ |
63 | libnuma \ | 65 | libnuma \ |
66 | numa_num_possible_cpus \ | ||
64 | libperl \ | 67 | libperl \ |
65 | libpython \ | 68 | libpython \ |
66 | libslang \ | 69 | libslang \ |
67 | libunwind \ | 70 | libunwind \ |
68 | libdw-dwarf-unwind \ | 71 | libdw-dwarf-unwind \ |
69 | zlib \ | 72 | zlib \ |
70 | lzma | 73 | lzma \ |
74 | get_cpuid | ||
71 | 75 | ||
72 | # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. | 76 | # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. |
73 | # If in the future we need per-feature checks/flags for features not | 77 | # If in the future we need per-feature checks/flags for features not |
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 74ca42093d70..e43a2971bf56 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile | |||
@@ -19,6 +19,7 @@ FILES= \ | |||
19 | test-libelf-getphdrnum.bin \ | 19 | test-libelf-getphdrnum.bin \ |
20 | test-libelf-mmap.bin \ | 20 | test-libelf-mmap.bin \ |
21 | test-libnuma.bin \ | 21 | test-libnuma.bin \ |
22 | test-numa_num_possible_cpus.bin \ | ||
22 | test-libperl.bin \ | 23 | test-libperl.bin \ |
23 | test-libpython.bin \ | 24 | test-libpython.bin \ |
24 | test-libpython-version.bin \ | 25 | test-libpython-version.bin \ |
@@ -34,7 +35,8 @@ FILES= \ | |||
34 | test-compile-x32.bin \ | 35 | test-compile-x32.bin \ |
35 | test-zlib.bin \ | 36 | test-zlib.bin \ |
36 | test-lzma.bin \ | 37 | test-lzma.bin \ |
37 | test-bpf.bin | 38 | test-bpf.bin \ |
39 | test-get_cpuid.bin | ||
38 | 40 | ||
39 | CC := $(CROSS_COMPILE)gcc -MD | 41 | CC := $(CROSS_COMPILE)gcc -MD |
40 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config | 42 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config |
@@ -87,6 +89,9 @@ test-libelf-getphdrnum.bin: | |||
87 | test-libnuma.bin: | 89 | test-libnuma.bin: |
88 | $(BUILD) -lnuma | 90 | $(BUILD) -lnuma |
89 | 91 | ||
92 | test-numa_num_possible_cpus.bin: | ||
93 | $(BUILD) -lnuma | ||
94 | |||
90 | test-libunwind.bin: | 95 | test-libunwind.bin: |
91 | $(BUILD) -lelf | 96 | $(BUILD) -lelf |
92 | 97 | ||
@@ -162,6 +167,9 @@ test-zlib.bin: | |||
162 | test-lzma.bin: | 167 | test-lzma.bin: |
163 | $(BUILD) -llzma | 168 | $(BUILD) -llzma |
164 | 169 | ||
170 | test-get_cpuid.bin: | ||
171 | $(BUILD) | ||
172 | |||
165 | test-bpf.bin: | 173 | test-bpf.bin: |
166 | $(BUILD) | 174 | $(BUILD) |
167 | 175 | ||
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 84689a67814a..33cf6f20bd4e 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c | |||
@@ -77,6 +77,10 @@ | |||
77 | # include "test-libnuma.c" | 77 | # include "test-libnuma.c" |
78 | #undef main | 78 | #undef main |
79 | 79 | ||
80 | #define main main_test_numa_num_possible_cpus | ||
81 | # include "test-numa_num_possible_cpus.c" | ||
82 | #undef main | ||
83 | |||
80 | #define main main_test_timerfd | 84 | #define main main_test_timerfd |
81 | # include "test-timerfd.c" | 85 | # include "test-timerfd.c" |
82 | #undef main | 86 | #undef main |
@@ -117,6 +121,10 @@ | |||
117 | # include "test-lzma.c" | 121 | # include "test-lzma.c" |
118 | #undef main | 122 | #undef main |
119 | 123 | ||
124 | #define main main_test_get_cpuid | ||
125 | # include "test-get_cpuid.c" | ||
126 | #undef main | ||
127 | |||
120 | int main(int argc, char *argv[]) | 128 | int main(int argc, char *argv[]) |
121 | { | 129 | { |
122 | main_test_libpython(); | 130 | main_test_libpython(); |
@@ -136,6 +144,7 @@ int main(int argc, char *argv[]) | |||
136 | main_test_libbfd(); | 144 | main_test_libbfd(); |
137 | main_test_backtrace(); | 145 | main_test_backtrace(); |
138 | main_test_libnuma(); | 146 | main_test_libnuma(); |
147 | main_test_numa_num_possible_cpus(); | ||
139 | main_test_timerfd(); | 148 | main_test_timerfd(); |
140 | main_test_stackprotector_all(); | 149 | main_test_stackprotector_all(); |
141 | main_test_libdw_dwarf_unwind(); | 150 | main_test_libdw_dwarf_unwind(); |
@@ -143,6 +152,7 @@ int main(int argc, char *argv[]) | |||
143 | main_test_zlib(); | 152 | main_test_zlib(); |
144 | main_test_pthread_attr_setaffinity_np(); | 153 | main_test_pthread_attr_setaffinity_np(); |
145 | main_test_lzma(); | 154 | main_test_lzma(); |
155 | main_test_get_cpuid(); | ||
146 | 156 | ||
147 | return 0; | 157 | return 0; |
148 | } | 158 | } |
diff --git a/tools/build/feature/test-get_cpuid.c b/tools/build/feature/test-get_cpuid.c new file mode 100644 index 000000000000..d7a2c407130d --- /dev/null +++ b/tools/build/feature/test-get_cpuid.c | |||
@@ -0,0 +1,7 @@ | |||
1 | #include <cpuid.h> | ||
2 | |||
3 | int main(void) | ||
4 | { | ||
5 | unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; | ||
6 | return __get_cpuid(0x15, &eax, &ebx, &ecx, &edx); | ||
7 | } | ||
diff --git a/tools/build/feature/test-numa_num_possible_cpus.c b/tools/build/feature/test-numa_num_possible_cpus.c new file mode 100644 index 000000000000..2606e94b0659 --- /dev/null +++ b/tools/build/feature/test-numa_num_possible_cpus.c | |||
@@ -0,0 +1,6 @@ | |||
1 | #include <numa.h> | ||
2 | |||
3 | int main(void) | ||
4 | { | ||
5 | return numa_num_possible_cpus(); | ||
6 | } | ||
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 4d885934b919..cf42b090477b 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -3795,7 +3795,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
3795 | struct format_field *field; | 3795 | struct format_field *field; |
3796 | struct printk_map *printk; | 3796 | struct printk_map *printk; |
3797 | long long val, fval; | 3797 | long long val, fval; |
3798 | unsigned long addr; | 3798 | unsigned long long addr; |
3799 | char *str; | 3799 | char *str; |
3800 | unsigned char *hex; | 3800 | unsigned char *hex; |
3801 | int print; | 3801 | int print; |
@@ -3828,13 +3828,30 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
3828 | */ | 3828 | */ |
3829 | if (!(field->flags & FIELD_IS_ARRAY) && | 3829 | if (!(field->flags & FIELD_IS_ARRAY) && |
3830 | field->size == pevent->long_size) { | 3830 | field->size == pevent->long_size) { |
3831 | addr = *(unsigned long *)(data + field->offset); | 3831 | |
3832 | /* Handle heterogeneous recording and processing | ||
3833 | * architectures | ||
3834 | * | ||
3835 | * CASE I: | ||
3836 | * Traces recorded on 32-bit devices (32-bit | ||
3837 | * addressing) and processed on 64-bit devices: | ||
3838 | * In this case, only 32 bits should be read. | ||
3839 | * | ||
3840 | * CASE II: | ||
3841 | * Traces recorded on 64 bit devices and processed | ||
3842 | * on 32-bit devices: | ||
3843 | * In this case, 64 bits must be read. | ||
3844 | */ | ||
3845 | addr = (pevent->long_size == 8) ? | ||
3846 | *(unsigned long long *)(data + field->offset) : | ||
3847 | (unsigned long long)*(unsigned int *)(data + field->offset); | ||
3848 | |||
3832 | /* Check if it matches a print format */ | 3849 | /* Check if it matches a print format */ |
3833 | printk = find_printk(pevent, addr); | 3850 | printk = find_printk(pevent, addr); |
3834 | if (printk) | 3851 | if (printk) |
3835 | trace_seq_puts(s, printk->printk); | 3852 | trace_seq_puts(s, printk->printk); |
3836 | else | 3853 | else |
3837 | trace_seq_printf(s, "%lx", addr); | 3854 | trace_seq_printf(s, "%llx", addr); |
3838 | break; | 3855 | break; |
3839 | } | 3856 | } |
3840 | str = malloc(len + 1); | 3857 | str = malloc(len + 1); |
diff --git a/tools/perf/Documentation/intel-pt.txt b/tools/perf/Documentation/intel-pt.txt index 4a0501d7a3b4..c94c9de3173e 100644 --- a/tools/perf/Documentation/intel-pt.txt +++ b/tools/perf/Documentation/intel-pt.txt | |||
@@ -364,21 +364,6 @@ cyc_thresh Specifies how frequently CYC packets are produced - see cyc | |||
364 | 364 | ||
365 | CYC packets are not requested by default. | 365 | CYC packets are not requested by default. |
366 | 366 | ||
367 | no_force_psb This is a driver option and is not in the IA32_RTIT_CTL MSR. | ||
368 | |||
369 | It stops the driver resetting the byte count to zero whenever | ||
370 | enabling the trace (for example on context switches) which in | ||
371 | turn results in no PSB being forced. However some processors | ||
372 | will produce a PSB anyway. | ||
373 | |||
374 | In any case, there is still a PSB when the trace is enabled for | ||
375 | the first time. | ||
376 | |||
377 | no_force_psb can be used to slightly decrease the trace size but | ||
378 | may make it harder for the decoder to recover from errors. | ||
379 | |||
380 | no_force_psb is not selected by default. | ||
381 | |||
382 | 367 | ||
383 | new snapshot option | 368 | new snapshot option |
384 | ------------------- | 369 | ------------------- |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index eb51325e8ad9..284a76e04628 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -768,8 +768,8 @@ static int process_exit_event(struct perf_tool *tool, | |||
768 | if (!evsel->attr.sample_id_all) { | 768 | if (!evsel->attr.sample_id_all) { |
769 | sample->cpu = 0; | 769 | sample->cpu = 0; |
770 | sample->time = 0; | 770 | sample->time = 0; |
771 | sample->tid = event->comm.tid; | 771 | sample->tid = event->fork.tid; |
772 | sample->pid = event->comm.pid; | 772 | sample->pid = event->fork.pid; |
773 | } | 773 | } |
774 | print_sample_start(sample, thread, evsel); | 774 | print_sample_start(sample, thread, evsel); |
775 | perf_event__fprintf(event, stdout); | 775 | perf_event__fprintf(event, stdout); |
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 827557fc7511..38a08539f4bf 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -573,9 +573,14 @@ ifndef NO_LIBNUMA | |||
573 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); | 573 | msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); |
574 | NO_LIBNUMA := 1 | 574 | NO_LIBNUMA := 1 |
575 | else | 575 | else |
576 | CFLAGS += -DHAVE_LIBNUMA_SUPPORT | 576 | ifeq ($(feature-numa_num_possible_cpus), 0) |
577 | EXTLIBS += -lnuma | 577 | msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8); |
578 | $(call detected,CONFIG_NUMA) | 578 | NO_LIBNUMA := 1 |
579 | else | ||
580 | CFLAGS += -DHAVE_LIBNUMA_SUPPORT | ||
581 | EXTLIBS += -lnuma | ||
582 | $(call detected,CONFIG_NUMA) | ||
583 | endif | ||
579 | endif | 584 | endif |
580 | endif | 585 | endif |
581 | 586 | ||
@@ -621,8 +626,13 @@ ifdef LIBBABELTRACE | |||
621 | endif | 626 | endif |
622 | 627 | ||
623 | ifndef NO_AUXTRACE | 628 | ifndef NO_AUXTRACE |
624 | $(call detected,CONFIG_AUXTRACE) | 629 | ifeq ($(feature-get_cpuid), 0) |
625 | CFLAGS += -DHAVE_AUXTRACE_SUPPORT | 630 | msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); |
631 | NO_AUXTRACE := 1 | ||
632 | else | ||
633 | $(call detected,CONFIG_AUXTRACE) | ||
634 | CFLAGS += -DHAVE_AUXTRACE_SUPPORT | ||
635 | endif | ||
626 | endif | 636 | endif |
627 | 637 | ||
628 | # Among the variables below, these: | 638 | # Among the variables below, these: |
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 1aa21c90731b..5b83f56a3b6f 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -34,6 +34,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
34 | .disabled = 1, | 34 | .disabled = 1, |
35 | .freq = 1, | 35 | .freq = 1, |
36 | }; | 36 | }; |
37 | struct cpu_map *cpus; | ||
38 | struct thread_map *threads; | ||
37 | 39 | ||
38 | attr.sample_freq = 500; | 40 | attr.sample_freq = 500; |
39 | 41 | ||
@@ -50,14 +52,19 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
50 | } | 52 | } |
51 | perf_evlist__add(evlist, evsel); | 53 | perf_evlist__add(evlist, evsel); |
52 | 54 | ||
53 | evlist->cpus = cpu_map__dummy_new(); | 55 | cpus = cpu_map__dummy_new(); |
54 | evlist->threads = thread_map__new_by_tid(getpid()); | 56 | threads = thread_map__new_by_tid(getpid()); |
55 | if (!evlist->cpus || !evlist->threads) { | 57 | if (!cpus || !threads) { |
56 | err = -ENOMEM; | 58 | err = -ENOMEM; |
57 | pr_debug("Not enough memory to create thread/cpu maps\n"); | 59 | pr_debug("Not enough memory to create thread/cpu maps\n"); |
58 | goto out_delete_evlist; | 60 | goto out_free_maps; |
59 | } | 61 | } |
60 | 62 | ||
63 | perf_evlist__set_maps(evlist, cpus, threads); | ||
64 | |||
65 | cpus = NULL; | ||
66 | threads = NULL; | ||
67 | |||
61 | if (perf_evlist__open(evlist)) { | 68 | if (perf_evlist__open(evlist)) { |
62 | const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate"; | 69 | const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate"; |
63 | 70 | ||
@@ -107,6 +114,9 @@ next_event: | |||
107 | err = -1; | 114 | err = -1; |
108 | } | 115 | } |
109 | 116 | ||
117 | out_free_maps: | ||
118 | cpu_map__put(cpus); | ||
119 | thread_map__put(threads); | ||
110 | out_delete_evlist: | 120 | out_delete_evlist: |
111 | perf_evlist__delete(evlist); | 121 | perf_evlist__delete(evlist); |
112 | return err; | 122 | return err; |
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 3a8fedef83bc..add16385f13e 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -43,6 +43,8 @@ int test__task_exit(void) | |||
43 | }; | 43 | }; |
44 | const char *argv[] = { "true", NULL }; | 44 | const char *argv[] = { "true", NULL }; |
45 | char sbuf[STRERR_BUFSIZE]; | 45 | char sbuf[STRERR_BUFSIZE]; |
46 | struct cpu_map *cpus; | ||
47 | struct thread_map *threads; | ||
46 | 48 | ||
47 | signal(SIGCHLD, sig_handler); | 49 | signal(SIGCHLD, sig_handler); |
48 | 50 | ||
@@ -58,14 +60,19 @@ int test__task_exit(void) | |||
58 | * perf_evlist__prepare_workload we'll fill in the only thread | 60 | * perf_evlist__prepare_workload we'll fill in the only thread |
59 | * we're monitoring, the one forked there. | 61 | * we're monitoring, the one forked there. |
60 | */ | 62 | */ |
61 | evlist->cpus = cpu_map__dummy_new(); | 63 | cpus = cpu_map__dummy_new(); |
62 | evlist->threads = thread_map__new_by_tid(-1); | 64 | threads = thread_map__new_by_tid(-1); |
63 | if (!evlist->cpus || !evlist->threads) { | 65 | if (!cpus || !threads) { |
64 | err = -ENOMEM; | 66 | err = -ENOMEM; |
65 | pr_debug("Not enough memory to create thread/cpu maps\n"); | 67 | pr_debug("Not enough memory to create thread/cpu maps\n"); |
66 | goto out_delete_evlist; | 68 | goto out_free_maps; |
67 | } | 69 | } |
68 | 70 | ||
71 | perf_evlist__set_maps(evlist, cpus, threads); | ||
72 | |||
73 | cpus = NULL; | ||
74 | threads = NULL; | ||
75 | |||
69 | err = perf_evlist__prepare_workload(evlist, &target, argv, false, | 76 | err = perf_evlist__prepare_workload(evlist, &target, argv, false, |
70 | workload_exec_failed_signal); | 77 | workload_exec_failed_signal); |
71 | if (err < 0) { | 78 | if (err < 0) { |
@@ -114,6 +121,9 @@ retry: | |||
114 | err = -1; | 121 | err = -1; |
115 | } | 122 | } |
116 | 123 | ||
124 | out_free_maps: | ||
125 | cpu_map__put(cpus); | ||
126 | thread_map__put(threads); | ||
117 | out_delete_evlist: | 127 | out_delete_evlist: |
118 | perf_evlist__delete(evlist); | 128 | perf_evlist__delete(evlist); |
119 | return err; | 129 | return err; |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index cf86f2d3a5e7..c04c60d4863c 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1968,7 +1968,8 @@ skip_annotation: | |||
1968 | &options[nr_options], dso); | 1968 | &options[nr_options], dso); |
1969 | nr_options += add_map_opt(browser, &actions[nr_options], | 1969 | nr_options += add_map_opt(browser, &actions[nr_options], |
1970 | &options[nr_options], | 1970 | &options[nr_options], |
1971 | browser->selection->map); | 1971 | browser->selection ? |
1972 | browser->selection->map : NULL); | ||
1972 | 1973 | ||
1973 | /* perf script support */ | 1974 | /* perf script support */ |
1974 | if (browser->he_selection) { | 1975 | if (browser->he_selection) { |
@@ -1976,6 +1977,15 @@ skip_annotation: | |||
1976 | &actions[nr_options], | 1977 | &actions[nr_options], |
1977 | &options[nr_options], | 1978 | &options[nr_options], |
1978 | thread, NULL); | 1979 | thread, NULL); |
1980 | /* | ||
1981 | * Note that browser->selection != NULL | ||
1982 | * when browser->he_selection is not NULL, | ||
1983 | * so we don't need to check browser->selection | ||
1984 | * before fetching browser->selection->sym like what | ||
1985 | * we do before fetching browser->selection->map. | ||
1986 | * | ||
1987 | * See hist_browser__show_entry. | ||
1988 | */ | ||
1979 | nr_options += add_script_opt(browser, | 1989 | nr_options += add_script_opt(browser, |
1980 | &actions[nr_options], | 1990 | &actions[nr_options], |
1981 | &options[nr_options], | 1991 | &options[nr_options], |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 349bc96ca1fe..e5f18a288b74 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -17,6 +17,7 @@ libperf-y += levenshtein.o | |||
17 | libperf-y += llvm-utils.o | 17 | libperf-y += llvm-utils.o |
18 | libperf-y += parse-options.o | 18 | libperf-y += parse-options.o |
19 | libperf-y += parse-events.o | 19 | libperf-y += parse-events.o |
20 | libperf-y += perf_regs.o | ||
20 | libperf-y += path.o | 21 | libperf-y += path.o |
21 | libperf-y += rbtree.o | 22 | libperf-y += rbtree.o |
22 | libperf-y += bitmap.o | 23 | libperf-y += bitmap.o |
@@ -103,7 +104,6 @@ libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o | |||
103 | 104 | ||
104 | libperf-y += scripting-engines/ | 105 | libperf-y += scripting-engines/ |
105 | 106 | ||
106 | libperf-$(CONFIG_PERF_REGS) += perf_regs.o | ||
107 | libperf-$(CONFIG_ZLIB) += zlib.o | 107 | libperf-$(CONFIG_ZLIB) += zlib.o |
108 | libperf-$(CONFIG_LZMA) += lzma.o | 108 | libperf-$(CONFIG_LZMA) += lzma.o |
109 | 109 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index d51a5200c8af..c8fc8a258f42 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -124,6 +124,33 @@ void perf_evlist__delete(struct perf_evlist *evlist) | |||
124 | free(evlist); | 124 | free(evlist); |
125 | } | 125 | } |
126 | 126 | ||
127 | static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, | ||
128 | struct perf_evsel *evsel) | ||
129 | { | ||
130 | /* | ||
131 | * We already have cpus for evsel (via PMU sysfs) so | ||
132 | * keep it, if there's no target cpu list defined. | ||
133 | */ | ||
134 | if (!evsel->own_cpus || evlist->has_user_cpus) { | ||
135 | cpu_map__put(evsel->cpus); | ||
136 | evsel->cpus = cpu_map__get(evlist->cpus); | ||
137 | } else if (evsel->cpus != evsel->own_cpus) { | ||
138 | cpu_map__put(evsel->cpus); | ||
139 | evsel->cpus = cpu_map__get(evsel->own_cpus); | ||
140 | } | ||
141 | |||
142 | thread_map__put(evsel->threads); | ||
143 | evsel->threads = thread_map__get(evlist->threads); | ||
144 | } | ||
145 | |||
146 | static void perf_evlist__propagate_maps(struct perf_evlist *evlist) | ||
147 | { | ||
148 | struct perf_evsel *evsel; | ||
149 | |||
150 | evlist__for_each(evlist, evsel) | ||
151 | __perf_evlist__propagate_maps(evlist, evsel); | ||
152 | } | ||
153 | |||
127 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) | 154 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) |
128 | { | 155 | { |
129 | entry->evlist = evlist; | 156 | entry->evlist = evlist; |
@@ -133,18 +160,19 @@ void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) | |||
133 | 160 | ||
134 | if (!evlist->nr_entries++) | 161 | if (!evlist->nr_entries++) |
135 | perf_evlist__set_id_pos(evlist); | 162 | perf_evlist__set_id_pos(evlist); |
163 | |||
164 | __perf_evlist__propagate_maps(evlist, entry); | ||
136 | } | 165 | } |
137 | 166 | ||
138 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, | 167 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, |
139 | struct list_head *list, | 168 | struct list_head *list) |
140 | int nr_entries) | ||
141 | { | 169 | { |
142 | bool set_id_pos = !evlist->nr_entries; | 170 | struct perf_evsel *evsel, *temp; |
143 | 171 | ||
144 | list_splice_tail(list, &evlist->entries); | 172 | __evlist__for_each_safe(list, temp, evsel) { |
145 | evlist->nr_entries += nr_entries; | 173 | list_del_init(&evsel->node); |
146 | if (set_id_pos) | 174 | perf_evlist__add(evlist, evsel); |
147 | perf_evlist__set_id_pos(evlist); | 175 | } |
148 | } | 176 | } |
149 | 177 | ||
150 | void __perf_evlist__set_leader(struct list_head *list) | 178 | void __perf_evlist__set_leader(struct list_head *list) |
@@ -210,7 +238,7 @@ static int perf_evlist__add_attrs(struct perf_evlist *evlist, | |||
210 | list_add_tail(&evsel->node, &head); | 238 | list_add_tail(&evsel->node, &head); |
211 | } | 239 | } |
212 | 240 | ||
213 | perf_evlist__splice_list_tail(evlist, &head, nr_attrs); | 241 | perf_evlist__splice_list_tail(evlist, &head); |
214 | 242 | ||
215 | return 0; | 243 | return 0; |
216 | 244 | ||
@@ -1103,71 +1131,56 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages, | |||
1103 | return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false); | 1131 | return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false); |
1104 | } | 1132 | } |
1105 | 1133 | ||
1106 | static int perf_evlist__propagate_maps(struct perf_evlist *evlist, | ||
1107 | bool has_user_cpus) | ||
1108 | { | ||
1109 | struct perf_evsel *evsel; | ||
1110 | |||
1111 | evlist__for_each(evlist, evsel) { | ||
1112 | /* | ||
1113 | * We already have cpus for evsel (via PMU sysfs) so | ||
1114 | * keep it, if there's no target cpu list defined. | ||
1115 | */ | ||
1116 | if (evsel->cpus && has_user_cpus) | ||
1117 | cpu_map__put(evsel->cpus); | ||
1118 | |||
1119 | if (!evsel->cpus || has_user_cpus) | ||
1120 | evsel->cpus = cpu_map__get(evlist->cpus); | ||
1121 | |||
1122 | evsel->threads = thread_map__get(evlist->threads); | ||
1123 | |||
1124 | if ((evlist->cpus && !evsel->cpus) || | ||
1125 | (evlist->threads && !evsel->threads)) | ||
1126 | return -ENOMEM; | ||
1127 | } | ||
1128 | |||
1129 | return 0; | ||
1130 | } | ||
1131 | |||
1132 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) | 1134 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) |
1133 | { | 1135 | { |
1134 | evlist->threads = thread_map__new_str(target->pid, target->tid, | 1136 | struct cpu_map *cpus; |
1135 | target->uid); | 1137 | struct thread_map *threads; |
1138 | |||
1139 | threads = thread_map__new_str(target->pid, target->tid, target->uid); | ||
1136 | 1140 | ||
1137 | if (evlist->threads == NULL) | 1141 | if (!threads) |
1138 | return -1; | 1142 | return -1; |
1139 | 1143 | ||
1140 | if (target__uses_dummy_map(target)) | 1144 | if (target__uses_dummy_map(target)) |
1141 | evlist->cpus = cpu_map__dummy_new(); | 1145 | cpus = cpu_map__dummy_new(); |
1142 | else | 1146 | else |
1143 | evlist->cpus = cpu_map__new(target->cpu_list); | 1147 | cpus = cpu_map__new(target->cpu_list); |
1144 | 1148 | ||
1145 | if (evlist->cpus == NULL) | 1149 | if (!cpus) |
1146 | goto out_delete_threads; | 1150 | goto out_delete_threads; |
1147 | 1151 | ||
1148 | return perf_evlist__propagate_maps(evlist, !!target->cpu_list); | 1152 | evlist->has_user_cpus = !!target->cpu_list; |
1153 | |||
1154 | perf_evlist__set_maps(evlist, cpus, threads); | ||
1155 | |||
1156 | return 0; | ||
1149 | 1157 | ||
1150 | out_delete_threads: | 1158 | out_delete_threads: |
1151 | thread_map__put(evlist->threads); | 1159 | thread_map__put(threads); |
1152 | evlist->threads = NULL; | ||
1153 | return -1; | 1160 | return -1; |
1154 | } | 1161 | } |
1155 | 1162 | ||
1156 | int perf_evlist__set_maps(struct perf_evlist *evlist, | 1163 | void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, |
1157 | struct cpu_map *cpus, | 1164 | struct thread_map *threads) |
1158 | struct thread_map *threads) | ||
1159 | { | 1165 | { |
1160 | if (evlist->cpus) | 1166 | /* |
1167 | * Allow for the possibility that one or another of the maps isn't being | ||
1168 | * changed i.e. don't put it. Note we are assuming the maps that are | ||
1169 | * being applied are brand new and evlist is taking ownership of the | ||
1170 | * original reference count of 1. If that is not the case it is up to | ||
1171 | * the caller to increase the reference count. | ||
1172 | */ | ||
1173 | if (cpus != evlist->cpus) { | ||
1161 | cpu_map__put(evlist->cpus); | 1174 | cpu_map__put(evlist->cpus); |
1175 | evlist->cpus = cpus; | ||
1176 | } | ||
1162 | 1177 | ||
1163 | evlist->cpus = cpus; | 1178 | if (threads != evlist->threads) { |
1164 | |||
1165 | if (evlist->threads) | ||
1166 | thread_map__put(evlist->threads); | 1179 | thread_map__put(evlist->threads); |
1180 | evlist->threads = threads; | ||
1181 | } | ||
1167 | 1182 | ||
1168 | evlist->threads = threads; | 1183 | perf_evlist__propagate_maps(evlist); |
1169 | |||
1170 | return perf_evlist__propagate_maps(evlist, false); | ||
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel) | 1186 | int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel) |
@@ -1387,6 +1400,8 @@ void perf_evlist__close(struct perf_evlist *evlist) | |||
1387 | 1400 | ||
1388 | static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist) | 1401 | static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist) |
1389 | { | 1402 | { |
1403 | struct cpu_map *cpus; | ||
1404 | struct thread_map *threads; | ||
1390 | int err = -ENOMEM; | 1405 | int err = -ENOMEM; |
1391 | 1406 | ||
1392 | /* | 1407 | /* |
@@ -1398,20 +1413,19 @@ static int perf_evlist__create_syswide_maps(struct perf_evlist *evlist) | |||
1398 | * error, and we may not want to do that fallback to a | 1413 | * error, and we may not want to do that fallback to a |
1399 | * default cpu identity map :-\ | 1414 | * default cpu identity map :-\ |
1400 | */ | 1415 | */ |
1401 | evlist->cpus = cpu_map__new(NULL); | 1416 | cpus = cpu_map__new(NULL); |
1402 | if (evlist->cpus == NULL) | 1417 | if (!cpus) |
1403 | goto out; | 1418 | goto out; |
1404 | 1419 | ||
1405 | evlist->threads = thread_map__new_dummy(); | 1420 | threads = thread_map__new_dummy(); |
1406 | if (evlist->threads == NULL) | 1421 | if (!threads) |
1407 | goto out_free_cpus; | 1422 | goto out_put; |
1408 | 1423 | ||
1409 | err = 0; | 1424 | perf_evlist__set_maps(evlist, cpus, threads); |
1410 | out: | 1425 | out: |
1411 | return err; | 1426 | return err; |
1412 | out_free_cpus: | 1427 | out_put: |
1413 | cpu_map__put(evlist->cpus); | 1428 | cpu_map__put(cpus); |
1414 | evlist->cpus = NULL; | ||
1415 | goto out; | 1429 | goto out; |
1416 | } | 1430 | } |
1417 | 1431 | ||
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index b39a6198f4ac..115d8b53c601 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -42,6 +42,7 @@ struct perf_evlist { | |||
42 | int nr_mmaps; | 42 | int nr_mmaps; |
43 | bool overwrite; | 43 | bool overwrite; |
44 | bool enabled; | 44 | bool enabled; |
45 | bool has_user_cpus; | ||
45 | size_t mmap_len; | 46 | size_t mmap_len; |
46 | int id_pos; | 47 | int id_pos; |
47 | int is_pos; | 48 | int is_pos; |
@@ -155,9 +156,8 @@ int perf_evlist__enable_event_idx(struct perf_evlist *evlist, | |||
155 | void perf_evlist__set_selected(struct perf_evlist *evlist, | 156 | void perf_evlist__set_selected(struct perf_evlist *evlist, |
156 | struct perf_evsel *evsel); | 157 | struct perf_evsel *evsel); |
157 | 158 | ||
158 | int perf_evlist__set_maps(struct perf_evlist *evlist, | 159 | void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, |
159 | struct cpu_map *cpus, | 160 | struct thread_map *threads); |
160 | struct thread_map *threads); | ||
161 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target); | 161 | int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target); |
162 | int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel); | 162 | int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel); |
163 | 163 | ||
@@ -179,8 +179,7 @@ bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist); | |||
179 | bool perf_evlist__valid_read_format(struct perf_evlist *evlist); | 179 | bool perf_evlist__valid_read_format(struct perf_evlist *evlist); |
180 | 180 | ||
181 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, | 181 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, |
182 | struct list_head *list, | 182 | struct list_head *list); |
183 | int nr_entries); | ||
184 | 183 | ||
185 | static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) | 184 | static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) |
186 | { | 185 | { |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index c53f79123b37..5410483d5219 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1033,6 +1033,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) | |||
1033 | perf_evsel__free_config_terms(evsel); | 1033 | perf_evsel__free_config_terms(evsel); |
1034 | close_cgroup(evsel->cgrp); | 1034 | close_cgroup(evsel->cgrp); |
1035 | cpu_map__put(evsel->cpus); | 1035 | cpu_map__put(evsel->cpus); |
1036 | cpu_map__put(evsel->own_cpus); | ||
1036 | thread_map__put(evsel->threads); | 1037 | thread_map__put(evsel->threads); |
1037 | zfree(&evsel->group_name); | 1038 | zfree(&evsel->group_name); |
1038 | zfree(&evsel->name); | 1039 | zfree(&evsel->name); |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 298e6bbca200..ef8925f7211a 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -98,6 +98,7 @@ struct perf_evsel { | |||
98 | struct cgroup_sel *cgrp; | 98 | struct cgroup_sel *cgrp; |
99 | void *handler; | 99 | void *handler; |
100 | struct cpu_map *cpus; | 100 | struct cpu_map *cpus; |
101 | struct cpu_map *own_cpus; | ||
101 | struct thread_map *threads; | 102 | struct thread_map *threads; |
102 | unsigned int sample_size; | 103 | unsigned int sample_size; |
103 | int id_pos; | 104 | int id_pos; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 41814547da15..fce6634aebe2 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1438,7 +1438,7 @@ static int process_nrcpus(struct perf_file_section *section __maybe_unused, | |||
1438 | if (ph->needs_swap) | 1438 | if (ph->needs_swap) |
1439 | nr = bswap_32(nr); | 1439 | nr = bswap_32(nr); |
1440 | 1440 | ||
1441 | ph->env.nr_cpus_online = nr; | 1441 | ph->env.nr_cpus_avail = nr; |
1442 | 1442 | ||
1443 | ret = readn(fd, &nr, sizeof(nr)); | 1443 | ret = readn(fd, &nr, sizeof(nr)); |
1444 | if (ret != sizeof(nr)) | 1444 | if (ret != sizeof(nr)) |
@@ -1447,7 +1447,7 @@ static int process_nrcpus(struct perf_file_section *section __maybe_unused, | |||
1447 | if (ph->needs_swap) | 1447 | if (ph->needs_swap) |
1448 | nr = bswap_32(nr); | 1448 | nr = bswap_32(nr); |
1449 | 1449 | ||
1450 | ph->env.nr_cpus_avail = nr; | 1450 | ph->env.nr_cpus_online = nr; |
1451 | return 0; | 1451 | return 0; |
1452 | } | 1452 | } |
1453 | 1453 | ||
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index ea768625ab5b..eb0e7f8bf515 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c | |||
@@ -623,7 +623,7 @@ static int intel_bts_process_event(struct perf_session *session, | |||
623 | if (err) | 623 | if (err) |
624 | return err; | 624 | return err; |
625 | if (event->header.type == PERF_RECORD_EXIT) { | 625 | if (event->header.type == PERF_RECORD_EXIT) { |
626 | err = intel_bts_process_tid_exit(bts, event->comm.tid); | 626 | err = intel_bts_process_tid_exit(bts, event->fork.tid); |
627 | if (err) | 627 | if (err) |
628 | return err; | 628 | return err; |
629 | } | 629 | } |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index bb41c20e6005..535d86f8e4d1 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -1494,7 +1494,7 @@ static int intel_pt_process_event(struct perf_session *session, | |||
1494 | if (pt->timeless_decoding) { | 1494 | if (pt->timeless_decoding) { |
1495 | if (event->header.type == PERF_RECORD_EXIT) { | 1495 | if (event->header.type == PERF_RECORD_EXIT) { |
1496 | err = intel_pt_process_timeless_queues(pt, | 1496 | err = intel_pt_process_timeless_queues(pt, |
1497 | event->comm.tid, | 1497 | event->fork.tid, |
1498 | sample->time); | 1498 | sample->time); |
1499 | } | 1499 | } |
1500 | } else if (timestamp) { | 1500 | } else if (timestamp) { |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d826e6f515db..21ed6ee63da9 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -287,8 +287,8 @@ __add_event(struct list_head *list, int *idx, | |||
287 | if (!evsel) | 287 | if (!evsel) |
288 | return NULL; | 288 | return NULL; |
289 | 289 | ||
290 | if (cpus) | 290 | evsel->cpus = cpu_map__get(cpus); |
291 | evsel->cpus = cpu_map__get(cpus); | 291 | evsel->own_cpus = cpu_map__get(cpus); |
292 | 292 | ||
293 | if (name) | 293 | if (name) |
294 | evsel->name = strdup(name); | 294 | evsel->name = strdup(name); |
@@ -1140,10 +1140,9 @@ int parse_events(struct perf_evlist *evlist, const char *str, | |||
1140 | ret = parse_events__scanner(str, &data, PE_START_EVENTS); | 1140 | ret = parse_events__scanner(str, &data, PE_START_EVENTS); |
1141 | perf_pmu__parse_cleanup(); | 1141 | perf_pmu__parse_cleanup(); |
1142 | if (!ret) { | 1142 | if (!ret) { |
1143 | int entries = data.idx - evlist->nr_entries; | ||
1144 | struct perf_evsel *last; | 1143 | struct perf_evsel *last; |
1145 | 1144 | ||
1146 | perf_evlist__splice_list_tail(evlist, &data.list, entries); | 1145 | perf_evlist__splice_list_tail(evlist, &data.list); |
1147 | evlist->nr_groups += data.nr_groups; | 1146 | evlist->nr_groups += data.nr_groups; |
1148 | last = perf_evlist__last(evlist); | 1147 | last = perf_evlist__last(evlist); |
1149 | last->cmdline_group_boundary = true; | 1148 | last->cmdline_group_boundary = true; |
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 591905a02b92..9cd70819c795 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y | |||
@@ -255,7 +255,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc | |||
255 | list_add_tail(&term->list, head); | 255 | list_add_tail(&term->list, head); |
256 | 256 | ||
257 | ALLOC_LIST(list); | 257 | ALLOC_LIST(list); |
258 | ABORT_ON(parse_events_add_pmu(list, &data->idx, "cpu", head)); | 258 | ABORT_ON(parse_events_add_pmu(data, list, "cpu", head)); |
259 | parse_events__free_terms(head); | 259 | parse_events__free_terms(head); |
260 | $$ = list; | 260 | $$ = list; |
261 | } | 261 | } |
diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index 885e8ac83997..6b8eb13e14e4 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c | |||
@@ -6,6 +6,7 @@ const struct sample_reg __weak sample_reg_masks[] = { | |||
6 | SMPL_REG_END | 6 | SMPL_REG_END |
7 | }; | 7 | }; |
8 | 8 | ||
9 | #ifdef HAVE_PERF_REGS_SUPPORT | ||
9 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) | 10 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) |
10 | { | 11 | { |
11 | int i, idx = 0; | 12 | int i, idx = 0; |
@@ -29,3 +30,4 @@ out: | |||
29 | *valp = regs->cache_regs[id]; | 30 | *valp = regs->cache_regs[id]; |
30 | return 0; | 31 | return 0; |
31 | } | 32 | } |
33 | #endif | ||
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h index 2984dcc54d67..679d6e493962 100644 --- a/tools/perf/util/perf_regs.h +++ b/tools/perf/util/perf_regs.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __PERF_REGS_H | 2 | #define __PERF_REGS_H |
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/compiler.h> | ||
5 | 6 | ||
6 | struct regs_dump; | 7 | struct regs_dump; |
7 | 8 | ||
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index eb5f18b75402..c6f9af78f6f5 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -270,12 +270,13 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso) | |||
270 | int ret = 0; | 270 | int ret = 0; |
271 | 271 | ||
272 | if (module) { | 272 | if (module) { |
273 | list_for_each_entry(dso, &host_machine->dsos.head, node) { | 273 | char module_name[128]; |
274 | if (!dso->kernel) | 274 | |
275 | continue; | 275 | snprintf(module_name, sizeof(module_name), "[%s]", module); |
276 | if (strncmp(dso->short_name + 1, module, | 276 | map = map_groups__find_by_name(&host_machine->kmaps, MAP__FUNCTION, module_name); |
277 | dso->short_name_len - 2) == 0) | 277 | if (map) { |
278 | goto found; | 278 | dso = map->dso; |
279 | goto found; | ||
279 | } | 280 | } |
280 | pr_debug("Failed to find module %s.\n", module); | 281 | pr_debug("Failed to find module %s.\n", module); |
281 | return -ENOENT; | 282 | return -ENOENT; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 8a4537ee9bc3..fc3f7c922f99 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1580,7 +1580,10 @@ static int __perf_session__process_events(struct perf_session *session, | |||
1580 | file_offset = page_offset; | 1580 | file_offset = page_offset; |
1581 | head = data_offset - page_offset; | 1581 | head = data_offset - page_offset; |
1582 | 1582 | ||
1583 | if (data_size && (data_offset + data_size < file_size)) | 1583 | if (data_size == 0) |
1584 | goto out; | ||
1585 | |||
1586 | if (data_offset + data_size < file_size) | ||
1584 | file_size = data_offset + data_size; | 1587 | file_size = data_offset + data_size; |
1585 | 1588 | ||
1586 | ui_progress__init(&prog, file_size, "Processing events..."); | 1589 | ui_progress__init(&prog, file_size, "Processing events..."); |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 415c359de465..2d065d065b67 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -196,7 +196,8 @@ static void zero_per_pkg(struct perf_evsel *counter) | |||
196 | memset(counter->per_pkg_mask, 0, MAX_NR_CPUS); | 196 | memset(counter->per_pkg_mask, 0, MAX_NR_CPUS); |
197 | } | 197 | } |
198 | 198 | ||
199 | static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip) | 199 | static int check_per_pkg(struct perf_evsel *counter, |
200 | struct perf_counts_values *vals, int cpu, bool *skip) | ||
200 | { | 201 | { |
201 | unsigned long *mask = counter->per_pkg_mask; | 202 | unsigned long *mask = counter->per_pkg_mask; |
202 | struct cpu_map *cpus = perf_evsel__cpus(counter); | 203 | struct cpu_map *cpus = perf_evsel__cpus(counter); |
@@ -218,6 +219,17 @@ static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip) | |||
218 | counter->per_pkg_mask = mask; | 219 | counter->per_pkg_mask = mask; |
219 | } | 220 | } |
220 | 221 | ||
222 | /* | ||
223 | * we do not consider an event that has not run as a good | ||
224 | * instance to mark a package as used (skip=1). Otherwise | ||
225 | * we may run into a situation where the first CPU in a package | ||
226 | * is not running anything, yet the second is, and this function | ||
227 | * would mark the package as used after the first CPU and would | ||
228 | * not read the values from the second CPU. | ||
229 | */ | ||
230 | if (!(vals->run && vals->ena)) | ||
231 | return 0; | ||
232 | |||
221 | s = cpu_map__get_socket(cpus, cpu); | 233 | s = cpu_map__get_socket(cpus, cpu); |
222 | if (s < 0) | 234 | if (s < 0) |
223 | return -1; | 235 | return -1; |
@@ -235,7 +247,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel | |||
235 | static struct perf_counts_values zero; | 247 | static struct perf_counts_values zero; |
236 | bool skip = false; | 248 | bool skip = false; |
237 | 249 | ||
238 | if (check_per_pkg(evsel, cpu, &skip)) { | 250 | if (check_per_pkg(evsel, count, cpu, &skip)) { |
239 | pr_err("failed to read per-pkg counter\n"); | 251 | pr_err("failed to read per-pkg counter\n"); |
240 | return -1; | 252 | return -1; |
241 | } | 253 | } |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 53bb5f59ec58..475d88d0a1c9 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -38,7 +38,7 @@ static inline char *bfd_demangle(void __maybe_unused *v, | |||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT | 40 | #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT |
41 | int elf_getphdrnum(Elf *elf, size_t *dst) | 41 | static int elf_getphdrnum(Elf *elf, size_t *dst) |
42 | { | 42 | { |
43 | GElf_Ehdr gehdr; | 43 | GElf_Ehdr gehdr; |
44 | GElf_Ehdr *ehdr; | 44 | GElf_Ehdr *ehdr; |
@@ -1271,8 +1271,6 @@ out_close: | |||
1271 | static int kcore__init(struct kcore *kcore, char *filename, int elfclass, | 1271 | static int kcore__init(struct kcore *kcore, char *filename, int elfclass, |
1272 | bool temp) | 1272 | bool temp) |
1273 | { | 1273 | { |
1274 | GElf_Ehdr *ehdr; | ||
1275 | |||
1276 | kcore->elfclass = elfclass; | 1274 | kcore->elfclass = elfclass; |
1277 | 1275 | ||
1278 | if (temp) | 1276 | if (temp) |
@@ -1289,9 +1287,7 @@ static int kcore__init(struct kcore *kcore, char *filename, int elfclass, | |||
1289 | if (!gelf_newehdr(kcore->elf, elfclass)) | 1287 | if (!gelf_newehdr(kcore->elf, elfclass)) |
1290 | goto out_end; | 1288 | goto out_end; |
1291 | 1289 | ||
1292 | ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr); | 1290 | memset(&kcore->ehdr, 0, sizeof(GElf_Ehdr)); |
1293 | if (!ehdr) | ||
1294 | goto out_end; | ||
1295 | 1291 | ||
1296 | return 0; | 1292 | return 0; |
1297 | 1293 | ||
@@ -1348,23 +1344,18 @@ static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count) | |||
1348 | static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset, | 1344 | static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset, |
1349 | u64 addr, u64 len) | 1345 | u64 addr, u64 len) |
1350 | { | 1346 | { |
1351 | GElf_Phdr gphdr; | 1347 | GElf_Phdr phdr = { |
1352 | GElf_Phdr *phdr; | 1348 | .p_type = PT_LOAD, |
1353 | 1349 | .p_flags = PF_R | PF_W | PF_X, | |
1354 | phdr = gelf_getphdr(kcore->elf, idx, &gphdr); | 1350 | .p_offset = offset, |
1355 | if (!phdr) | 1351 | .p_vaddr = addr, |
1356 | return -1; | 1352 | .p_paddr = 0, |
1357 | 1353 | .p_filesz = len, | |
1358 | phdr->p_type = PT_LOAD; | 1354 | .p_memsz = len, |
1359 | phdr->p_flags = PF_R | PF_W | PF_X; | 1355 | .p_align = page_size, |
1360 | phdr->p_offset = offset; | 1356 | }; |
1361 | phdr->p_vaddr = addr; | 1357 | |
1362 | phdr->p_paddr = 0; | 1358 | if (!gelf_update_phdr(kcore->elf, idx, &phdr)) |
1363 | phdr->p_filesz = len; | ||
1364 | phdr->p_memsz = len; | ||
1365 | phdr->p_align = page_size; | ||
1366 | |||
1367 | if (!gelf_update_phdr(kcore->elf, idx, phdr)) | ||
1368 | return -1; | 1359 | return -1; |
1369 | 1360 | ||
1370 | return 0; | 1361 | return 0; |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 7acafb3c5592..c2cd9bf2348b 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -709,7 +709,7 @@ bool find_process(const char *name) | |||
709 | 709 | ||
710 | dir = opendir(procfs__mountpoint()); | 710 | dir = opendir(procfs__mountpoint()); |
711 | if (!dir) | 711 | if (!dir) |
712 | return -1; | 712 | return false; |
713 | 713 | ||
714 | /* Walk through the directory. */ | 714 | /* Walk through the directory. */ |
715 | while (ret && (d = readdir(dir)) != NULL) { | 715 | while (ret && (d = readdir(dir)) != NULL) { |
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 9655cb49c7cb..bde0ef1a63df 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -71,8 +71,11 @@ unsigned int extra_msr_offset32; | |||
71 | unsigned int extra_msr_offset64; | 71 | unsigned int extra_msr_offset64; |
72 | unsigned int extra_delta_offset32; | 72 | unsigned int extra_delta_offset32; |
73 | unsigned int extra_delta_offset64; | 73 | unsigned int extra_delta_offset64; |
74 | unsigned int aperf_mperf_multiplier = 1; | ||
74 | int do_smi; | 75 | int do_smi; |
75 | double bclk; | 76 | double bclk; |
77 | double base_hz; | ||
78 | double tsc_tweak = 1.0; | ||
76 | unsigned int show_pkg; | 79 | unsigned int show_pkg; |
77 | unsigned int show_core; | 80 | unsigned int show_core; |
78 | unsigned int show_cpu; | 81 | unsigned int show_cpu; |
@@ -502,7 +505,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
502 | /* %Busy */ | 505 | /* %Busy */ |
503 | if (has_aperf) { | 506 | if (has_aperf) { |
504 | if (!skip_c0) | 507 | if (!skip_c0) |
505 | outp += sprintf(outp, "%8.2f", 100.0 * t->mperf/t->tsc); | 508 | outp += sprintf(outp, "%8.2f", 100.0 * t->mperf/t->tsc/tsc_tweak); |
506 | else | 509 | else |
507 | outp += sprintf(outp, "********"); | 510 | outp += sprintf(outp, "********"); |
508 | } | 511 | } |
@@ -510,7 +513,7 @@ int format_counters(struct thread_data *t, struct core_data *c, | |||
510 | /* Bzy_MHz */ | 513 | /* Bzy_MHz */ |
511 | if (has_aperf) | 514 | if (has_aperf) |
512 | outp += sprintf(outp, "%8.0f", | 515 | outp += sprintf(outp, "%8.0f", |
513 | 1.0 * t->tsc / units * t->aperf / t->mperf / interval_float); | 516 | 1.0 * t->tsc * tsc_tweak / units * t->aperf / t->mperf / interval_float); |
514 | 517 | ||
515 | /* TSC_MHz */ | 518 | /* TSC_MHz */ |
516 | outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float); | 519 | outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float); |
@@ -984,6 +987,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
984 | return -3; | 987 | return -3; |
985 | if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) | 988 | if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf)) |
986 | return -4; | 989 | return -4; |
990 | t->aperf = t->aperf * aperf_mperf_multiplier; | ||
991 | t->mperf = t->mperf * aperf_mperf_multiplier; | ||
987 | } | 992 | } |
988 | 993 | ||
989 | if (do_smi) { | 994 | if (do_smi) { |
@@ -1149,6 +1154,19 @@ int slv_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCLRSV, PCLRSV, PCL__4, PCLRSV, | |||
1149 | int amt_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; | 1154 | int amt_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; |
1150 | int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; | 1155 | int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; |
1151 | 1156 | ||
1157 | |||
1158 | static void | ||
1159 | calculate_tsc_tweak() | ||
1160 | { | ||
1161 | unsigned long long msr; | ||
1162 | unsigned int base_ratio; | ||
1163 | |||
1164 | get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr); | ||
1165 | base_ratio = (msr >> 8) & 0xFF; | ||
1166 | base_hz = base_ratio * bclk * 1000000; | ||
1167 | tsc_tweak = base_hz / tsc_hz; | ||
1168 | } | ||
1169 | |||
1152 | static void | 1170 | static void |
1153 | dump_nhm_platform_info(void) | 1171 | dump_nhm_platform_info(void) |
1154 | { | 1172 | { |
@@ -1926,8 +1944,6 @@ int has_config_tdp(unsigned int family, unsigned int model) | |||
1926 | 1944 | ||
1927 | switch (model) { | 1945 | switch (model) { |
1928 | case 0x3A: /* IVB */ | 1946 | case 0x3A: /* IVB */ |
1929 | case 0x3E: /* IVB Xeon */ | ||
1930 | |||
1931 | case 0x3C: /* HSW */ | 1947 | case 0x3C: /* HSW */ |
1932 | case 0x3F: /* HSX */ | 1948 | case 0x3F: /* HSX */ |
1933 | case 0x45: /* HSW */ | 1949 | case 0x45: /* HSW */ |
@@ -2543,6 +2559,13 @@ int is_knl(unsigned int family, unsigned int model) | |||
2543 | return 0; | 2559 | return 0; |
2544 | } | 2560 | } |
2545 | 2561 | ||
2562 | unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model) | ||
2563 | { | ||
2564 | if (is_knl(family, model)) | ||
2565 | return 1024; | ||
2566 | return 1; | ||
2567 | } | ||
2568 | |||
2546 | #define SLM_BCLK_FREQS 5 | 2569 | #define SLM_BCLK_FREQS 5 |
2547 | double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0}; | 2570 | double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0}; |
2548 | 2571 | ||
@@ -2744,6 +2767,9 @@ void process_cpuid() | |||
2744 | } | 2767 | } |
2745 | } | 2768 | } |
2746 | 2769 | ||
2770 | if (has_aperf) | ||
2771 | aperf_mperf_multiplier = get_aperf_mperf_multiplier(family, model); | ||
2772 | |||
2747 | do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model); | 2773 | do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model); |
2748 | do_snb_cstates = has_snb_msrs(family, model); | 2774 | do_snb_cstates = has_snb_msrs(family, model); |
2749 | do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2); | 2775 | do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2); |
@@ -2762,6 +2788,9 @@ void process_cpuid() | |||
2762 | if (debug) | 2788 | if (debug) |
2763 | dump_cstate_pstate_config_info(); | 2789 | dump_cstate_pstate_config_info(); |
2764 | 2790 | ||
2791 | if (has_skl_msrs(family, model)) | ||
2792 | calculate_tsc_tweak(); | ||
2793 | |||
2765 | return; | 2794 | return; |
2766 | } | 2795 | } |
2767 | 2796 | ||
@@ -3090,7 +3119,7 @@ int get_and_dump_counters(void) | |||
3090 | } | 3119 | } |
3091 | 3120 | ||
3092 | void print_version() { | 3121 | void print_version() { |
3093 | fprintf(stderr, "turbostat version 4.7 17-June, 2015" | 3122 | fprintf(stderr, "turbostat version 4.8 26-Sep, 2015" |
3094 | " - Len Brown <lenb@kernel.org>\n"); | 3123 | " - Len Brown <lenb@kernel.org>\n"); |
3095 | } | 3124 | } |
3096 | 3125 | ||
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 89b05e2222c9..cfe121353eec 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -16,12 +16,12 @@ TARGETS += powerpc | |||
16 | TARGETS += ptrace | 16 | TARGETS += ptrace |
17 | TARGETS += seccomp | 17 | TARGETS += seccomp |
18 | TARGETS += size | 18 | TARGETS += size |
19 | TARGETS += static_keys | ||
19 | TARGETS += sysctl | 20 | TARGETS += sysctl |
20 | ifneq (1, $(quicktest)) | 21 | ifneq (1, $(quicktest)) |
21 | TARGETS += timers | 22 | TARGETS += timers |
22 | endif | 23 | endif |
23 | TARGETS += user | 24 | TARGETS += user |
24 | TARGETS += jumplabel | ||
25 | TARGETS += vm | 25 | TARGETS += vm |
26 | TARGETS += x86 | 26 | TARGETS += x86 |
27 | TARGETS += zram | 27 | TARGETS += zram |
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile index 6b76bfdc847e..4e400eb83657 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | CFLAGS = -Wall | 1 | CFLAGS = -Wall |
2 | BINARIES = execveat | 2 | BINARIES = execveat |
3 | DEPS = execveat.symlink execveat.denatured script | 3 | DEPS = execveat.symlink execveat.denatured script subdir |
4 | all: $(BINARIES) $(DEPS) | 4 | all: $(BINARIES) $(DEPS) |
5 | 5 | ||
6 | subdir: | 6 | subdir: |
@@ -22,7 +22,5 @@ TEST_FILES := $(DEPS) | |||
22 | 22 | ||
23 | include ../lib.mk | 23 | include ../lib.mk |
24 | 24 | ||
25 | override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\"" | ||
26 | |||
27 | clean: | 25 | clean: |
28 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* | 26 | rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* |
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile index 0acbeca47225..4e6ed13e7f66 100644 --- a/tools/testing/selftests/ftrace/Makefile +++ b/tools/testing/selftests/ftrace/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | all: | 1 | all: |
2 | 2 | ||
3 | TEST_PROGS := ftracetest | 3 | TEST_PROGS := ftracetest |
4 | TEST_DIRS := test.d/ | 4 | TEST_DIRS := test.d |
5 | 5 | ||
6 | include ../lib.mk | 6 | include ../lib.mk |
7 | 7 | ||
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 97f1c6742066..50a93f5f13d6 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk | |||
@@ -12,13 +12,10 @@ run_tests: all | |||
12 | $(RUN_TESTS) | 12 | $(RUN_TESTS) |
13 | 13 | ||
14 | define INSTALL_RULE | 14 | define INSTALL_RULE |
15 | @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ | 15 | @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ |
16 | mkdir -p $(INSTALL_PATH); \ | 16 | mkdir -p ${INSTALL_PATH}; \ |
17 | for TEST_DIR in $(TEST_DIRS); do \ | 17 | echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ |
18 | cp -r $$TEST_DIR $(INSTALL_PATH); \ | 18 | rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ |
19 | done; \ | ||
20 | echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \ | ||
21 | install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \ | ||
22 | fi | 19 | fi |
23 | endef | 20 | endef |
24 | 21 | ||
diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile index 877a50355d7f..a1a97085847d 100644 --- a/tools/testing/selftests/membarrier/Makefile +++ b/tools/testing/selftests/membarrier/Makefile | |||
@@ -1,11 +1,10 @@ | |||
1 | CFLAGS += -g -I../../../../usr/include/ | 1 | CFLAGS += -g -I../../../../usr/include/ |
2 | 2 | ||
3 | all: | ||
4 | $(CC) $(CFLAGS) membarrier_test.c -o membarrier_test | ||
5 | |||
6 | TEST_PROGS := membarrier_test | 3 | TEST_PROGS := membarrier_test |
7 | 4 | ||
5 | all: $(TEST_PROGS) | ||
6 | |||
8 | include ../lib.mk | 7 | include ../lib.mk |
9 | 8 | ||
10 | clean: | 9 | clean: |
11 | $(RM) membarrier_test | 10 | $(RM) $(TEST_PROGS) |
diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c index dde312508007..535f0fef4d0b 100644 --- a/tools/testing/selftests/membarrier/membarrier_test.c +++ b/tools/testing/selftests/membarrier/membarrier_test.c | |||
@@ -1,9 +1,6 @@ | |||
1 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
2 | #define __EXPORTED_HEADERS__ | ||
3 | |||
4 | #include <linux/membarrier.h> | 2 | #include <linux/membarrier.h> |
5 | #include <asm-generic/unistd.h> | 3 | #include <syscall.h> |
6 | #include <sys/syscall.h> | ||
7 | #include <stdio.h> | 4 | #include <stdio.h> |
8 | #include <errno.h> | 5 | #include <errno.h> |
9 | #include <string.h> | 6 | #include <string.h> |
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile index 0e3b41eb85cd..eebac29acbd9 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile | |||
@@ -1,8 +1,8 @@ | |||
1 | CFLAGS = -O2 | 1 | CFLAGS += -O2 |
2 | LDLIBS = -lrt -lpthread -lpopt | ||
3 | TEST_PROGS := mq_open_tests mq_perf_tests | ||
2 | 4 | ||
3 | all: | 5 | all: $(TEST_PROGS) |
4 | $(CC) $(CFLAGS) mq_open_tests.c -o mq_open_tests -lrt | ||
5 | $(CC) $(CFLAGS) -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt | ||
6 | 6 | ||
7 | include ../lib.mk | 7 | include ../lib.mk |
8 | 8 | ||
@@ -11,8 +11,6 @@ override define RUN_TESTS | |||
11 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" | 11 | @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" |
12 | endef | 12 | endef |
13 | 13 | ||
14 | TEST_PROGS := mq_open_tests mq_perf_tests | ||
15 | |||
16 | override define EMIT_TESTS | 14 | override define EMIT_TESTS |
17 | echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\"" | 15 | echo "./mq_open_tests /test1 || echo \"selftests: mq_open_tests [FAIL]\"" |
18 | echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" | 16 | echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" |
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index a004b4cce99e..770f47adf295 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c | |||
@@ -1210,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) | |||
1210 | # define ARCH_REGS struct pt_regs | 1210 | # define ARCH_REGS struct pt_regs |
1211 | # define SYSCALL_NUM gpr[0] | 1211 | # define SYSCALL_NUM gpr[0] |
1212 | # define SYSCALL_RET gpr[3] | 1212 | # define SYSCALL_RET gpr[3] |
1213 | #elif defined(__s390__) | ||
1214 | # define ARCH_REGS s390_regs | ||
1215 | # define SYSCALL_NUM gprs[2] | ||
1216 | # define SYSCALL_RET gprs[2] | ||
1213 | #else | 1217 | #else |
1214 | # error "Do not know how to find your architecture's registers and syscalls" | 1218 | # error "Do not know how to find your architecture's registers and syscalls" |
1215 | #endif | 1219 | #endif |
@@ -1243,7 +1247,8 @@ void change_syscall(struct __test_metadata *_metadata, | |||
1243 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); | 1247 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); |
1244 | EXPECT_EQ(0, ret); | 1248 | EXPECT_EQ(0, ret); |
1245 | 1249 | ||
1246 | #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) | 1250 | #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \ |
1251 | defined(__powerpc__) || defined(__s390__) | ||
1247 | { | 1252 | { |
1248 | regs.SYSCALL_NUM = syscall; | 1253 | regs.SYSCALL_NUM = syscall; |
1249 | } | 1254 | } |
@@ -1281,17 +1286,21 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee, | |||
1281 | ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); | 1286 | ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); |
1282 | EXPECT_EQ(0, ret); | 1287 | EXPECT_EQ(0, ret); |
1283 | 1288 | ||
1289 | /* Validate and take action on expected syscalls. */ | ||
1284 | switch (msg) { | 1290 | switch (msg) { |
1285 | case 0x1002: | 1291 | case 0x1002: |
1286 | /* change getpid to getppid. */ | 1292 | /* change getpid to getppid. */ |
1293 | EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee)); | ||
1287 | change_syscall(_metadata, tracee, __NR_getppid); | 1294 | change_syscall(_metadata, tracee, __NR_getppid); |
1288 | break; | 1295 | break; |
1289 | case 0x1003: | 1296 | case 0x1003: |
1290 | /* skip gettid. */ | 1297 | /* skip gettid. */ |
1298 | EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee)); | ||
1291 | change_syscall(_metadata, tracee, -1); | 1299 | change_syscall(_metadata, tracee, -1); |
1292 | break; | 1300 | break; |
1293 | case 0x1004: | 1301 | case 0x1004: |
1294 | /* do nothing (allow getppid) */ | 1302 | /* do nothing (allow getppid) */ |
1303 | EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee)); | ||
1295 | break; | 1304 | break; |
1296 | default: | 1305 | default: |
1297 | EXPECT_EQ(0, msg) { | 1306 | EXPECT_EQ(0, msg) { |
@@ -1409,6 +1418,8 @@ TEST_F(TRACE_syscall, syscall_dropped) | |||
1409 | # define __NR_seccomp 277 | 1418 | # define __NR_seccomp 277 |
1410 | # elif defined(__powerpc__) | 1419 | # elif defined(__powerpc__) |
1411 | # define __NR_seccomp 358 | 1420 | # define __NR_seccomp 358 |
1421 | # elif defined(__s390__) | ||
1422 | # define __NR_seccomp 348 | ||
1412 | # else | 1423 | # else |
1413 | # warning "seccomp syscall number unknown for this architecture" | 1424 | # warning "seccomp syscall number unknown for this architecture" |
1414 | # define __NR_seccomp 0xffff | 1425 | # define __NR_seccomp 0xffff |
@@ -1453,6 +1464,9 @@ TEST(seccomp_syscall) | |||
1453 | 1464 | ||
1454 | /* Reject insane operation. */ | 1465 | /* Reject insane operation. */ |
1455 | ret = seccomp(-1, 0, &prog); | 1466 | ret = seccomp(-1, 0, &prog); |
1467 | ASSERT_NE(ENOSYS, errno) { | ||
1468 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1469 | } | ||
1456 | EXPECT_EQ(EINVAL, errno) { | 1470 | EXPECT_EQ(EINVAL, errno) { |
1457 | TH_LOG("Did not reject crazy op value!"); | 1471 | TH_LOG("Did not reject crazy op value!"); |
1458 | } | 1472 | } |
@@ -1501,6 +1515,9 @@ TEST(seccomp_syscall_mode_lock) | |||
1501 | } | 1515 | } |
1502 | 1516 | ||
1503 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); | 1517 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
1518 | ASSERT_NE(ENOSYS, errno) { | ||
1519 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1520 | } | ||
1504 | EXPECT_EQ(0, ret) { | 1521 | EXPECT_EQ(0, ret) { |
1505 | TH_LOG("Could not install filter!"); | 1522 | TH_LOG("Could not install filter!"); |
1506 | } | 1523 | } |
@@ -1535,6 +1552,9 @@ TEST(TSYNC_first) | |||
1535 | 1552 | ||
1536 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, | 1553 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
1537 | &prog); | 1554 | &prog); |
1555 | ASSERT_NE(ENOSYS, errno) { | ||
1556 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1557 | } | ||
1538 | EXPECT_EQ(0, ret) { | 1558 | EXPECT_EQ(0, ret) { |
1539 | TH_LOG("Could not install initial filter with TSYNC!"); | 1559 | TH_LOG("Could not install initial filter with TSYNC!"); |
1540 | } | 1560 | } |
@@ -1694,6 +1714,9 @@ TEST_F(TSYNC, siblings_fail_prctl) | |||
1694 | 1714 | ||
1695 | /* Check prctl failure detection by requesting sib 0 diverge. */ | 1715 | /* Check prctl failure detection by requesting sib 0 diverge. */ |
1696 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); | 1716 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
1717 | ASSERT_NE(ENOSYS, errno) { | ||
1718 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1719 | } | ||
1697 | ASSERT_EQ(0, ret) { | 1720 | ASSERT_EQ(0, ret) { |
1698 | TH_LOG("setting filter failed"); | 1721 | TH_LOG("setting filter failed"); |
1699 | } | 1722 | } |
@@ -1731,6 +1754,9 @@ TEST_F(TSYNC, two_siblings_with_ancestor) | |||
1731 | } | 1754 | } |
1732 | 1755 | ||
1733 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1756 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1757 | ASSERT_NE(ENOSYS, errno) { | ||
1758 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1759 | } | ||
1734 | ASSERT_EQ(0, ret) { | 1760 | ASSERT_EQ(0, ret) { |
1735 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1761 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1736 | } | 1762 | } |
@@ -1805,6 +1831,9 @@ TEST_F(TSYNC, two_siblings_with_no_filter) | |||
1805 | 1831 | ||
1806 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, | 1832 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
1807 | &self->apply_prog); | 1833 | &self->apply_prog); |
1834 | ASSERT_NE(ENOSYS, errno) { | ||
1835 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1836 | } | ||
1808 | ASSERT_EQ(0, ret) { | 1837 | ASSERT_EQ(0, ret) { |
1809 | TH_LOG("Could install filter on all threads!"); | 1838 | TH_LOG("Could install filter on all threads!"); |
1810 | } | 1839 | } |
@@ -1833,6 +1862,9 @@ TEST_F(TSYNC, two_siblings_with_one_divergence) | |||
1833 | } | 1862 | } |
1834 | 1863 | ||
1835 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1864 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1865 | ASSERT_NE(ENOSYS, errno) { | ||
1866 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1867 | } | ||
1836 | ASSERT_EQ(0, ret) { | 1868 | ASSERT_EQ(0, ret) { |
1837 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1869 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1838 | } | 1870 | } |
@@ -1890,6 +1922,9 @@ TEST_F(TSYNC, two_siblings_not_under_filter) | |||
1890 | } | 1922 | } |
1891 | 1923 | ||
1892 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); | 1924 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
1925 | ASSERT_NE(ENOSYS, errno) { | ||
1926 | TH_LOG("Kernel does not support seccomp syscall!"); | ||
1927 | } | ||
1893 | ASSERT_EQ(0, ret) { | 1928 | ASSERT_EQ(0, ret) { |
1894 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); | 1929 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
1895 | } | 1930 | } |
diff --git a/tools/testing/selftests/seccomp/test_harness.h b/tools/testing/selftests/seccomp/test_harness.h index 977a6afc4489..fb2841601f2f 100644 --- a/tools/testing/selftests/seccomp/test_harness.h +++ b/tools/testing/selftests/seccomp/test_harness.h | |||
@@ -370,11 +370,8 @@ | |||
370 | __typeof__(_expected) __exp = (_expected); \ | 370 | __typeof__(_expected) __exp = (_expected); \ |
371 | __typeof__(_seen) __seen = (_seen); \ | 371 | __typeof__(_seen) __seen = (_seen); \ |
372 | if (!(__exp _t __seen)) { \ | 372 | if (!(__exp _t __seen)) { \ |
373 | unsigned long long __exp_print = 0; \ | 373 | unsigned long long __exp_print = (unsigned long long)__exp; \ |
374 | unsigned long long __seen_print = 0; \ | 374 | unsigned long long __seen_print = (unsigned long long)__seen; \ |
375 | /* Avoid casting complaints the scariest way we can. */ \ | ||
376 | memcpy(&__exp_print, &__exp, sizeof(__exp)); \ | ||
377 | memcpy(&__seen_print, &__seen, sizeof(__seen)); \ | ||
378 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ | 375 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
379 | #_expected, __exp_print, #_t, \ | 376 | #_expected, __exp_print, #_t, \ |
380 | #_seen, __seen_print); \ | 377 | #_seen, __seen_print); \ |
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index d36fab7d8ebd..3c53cac15de1 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for vm selftests | 1 | # Makefile for vm selftests |
2 | 2 | ||
3 | CFLAGS = -Wall | 3 | CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) |
4 | BINARIES = compaction_test | 4 | BINARIES = compaction_test |
5 | BINARIES += hugepage-mmap | 5 | BINARIES += hugepage-mmap |
6 | BINARIES += hugepage-shm | 6 | BINARIES += hugepage-shm |
@@ -12,8 +12,11 @@ BINARIES += userfaultfd | |||
12 | all: $(BINARIES) | 12 | all: $(BINARIES) |
13 | %: %.c | 13 | %: %.c |
14 | $(CC) $(CFLAGS) -o $@ $^ -lrt | 14 | $(CC) $(CFLAGS) -o $@ $^ -lrt |
15 | userfaultfd: userfaultfd.c | 15 | userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h |
16 | $(CC) $(CFLAGS) -O2 -o $@ $^ -lpthread | 16 | $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread |
17 | |||
18 | ../../../../usr/include/linux/kernel.h: | ||
19 | make -C ../../../.. headers_install | ||
17 | 20 | ||
18 | TEST_PROGS := run_vmtests | 21 | TEST_PROGS := run_vmtests |
19 | TEST_FILES := $(BINARIES) | 22 | TEST_FILES := $(BINARIES) |
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 2c7cca6f26a4..d77ed41b2094 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c | |||
@@ -64,17 +64,9 @@ | |||
64 | #include <sys/syscall.h> | 64 | #include <sys/syscall.h> |
65 | #include <sys/ioctl.h> | 65 | #include <sys/ioctl.h> |
66 | #include <pthread.h> | 66 | #include <pthread.h> |
67 | #include "../../../../include/uapi/linux/userfaultfd.h" | 67 | #include <linux/userfaultfd.h> |
68 | 68 | ||
69 | #ifdef __x86_64__ | 69 | #ifdef __NR_userfaultfd |
70 | #define __NR_userfaultfd 323 | ||
71 | #elif defined(__i386__) | ||
72 | #define __NR_userfaultfd 374 | ||
73 | #elif defined(__powewrpc__) | ||
74 | #define __NR_userfaultfd 364 | ||
75 | #else | ||
76 | #error "missing __NR_userfaultfd definition" | ||
77 | #endif | ||
78 | 70 | ||
79 | static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; | 71 | static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; |
80 | 72 | ||
@@ -430,7 +422,7 @@ static int userfaultfd_stress(void) | |||
430 | struct uffdio_register uffdio_register; | 422 | struct uffdio_register uffdio_register; |
431 | struct uffdio_api uffdio_api; | 423 | struct uffdio_api uffdio_api; |
432 | unsigned long cpu; | 424 | unsigned long cpu; |
433 | int uffd_flags; | 425 | int uffd_flags, err; |
434 | unsigned long userfaults[nr_cpus]; | 426 | unsigned long userfaults[nr_cpus]; |
435 | 427 | ||
436 | if (posix_memalign(&area, page_size, nr_pages * page_size)) { | 428 | if (posix_memalign(&area, page_size, nr_pages * page_size)) { |
@@ -473,6 +465,14 @@ static int userfaultfd_stress(void) | |||
473 | *area_mutex(area_src, nr) = (pthread_mutex_t) | 465 | *area_mutex(area_src, nr) = (pthread_mutex_t) |
474 | PTHREAD_MUTEX_INITIALIZER; | 466 | PTHREAD_MUTEX_INITIALIZER; |
475 | count_verify[nr] = *area_count(area_src, nr) = 1; | 467 | count_verify[nr] = *area_count(area_src, nr) = 1; |
468 | /* | ||
469 | * In the transition between 255 to 256, powerpc will | ||
470 | * read out of order in my_bcmp and see both bytes as | ||
471 | * zero, so leave a placeholder below always non-zero | ||
472 | * after the count, to avoid my_bcmp to trigger false | ||
473 | * positives. | ||
474 | */ | ||
475 | *(area_count(area_src, nr) + 1) = 1; | ||
476 | } | 476 | } |
477 | 477 | ||
478 | pipefd = malloc(sizeof(int) * nr_cpus * 2); | 478 | pipefd = malloc(sizeof(int) * nr_cpus * 2); |
@@ -499,6 +499,7 @@ static int userfaultfd_stress(void) | |||
499 | pthread_attr_init(&attr); | 499 | pthread_attr_init(&attr); |
500 | pthread_attr_setstacksize(&attr, 16*1024*1024); | 500 | pthread_attr_setstacksize(&attr, 16*1024*1024); |
501 | 501 | ||
502 | err = 0; | ||
502 | while (bounces--) { | 503 | while (bounces--) { |
503 | unsigned long expected_ioctls; | 504 | unsigned long expected_ioctls; |
504 | 505 | ||
@@ -579,20 +580,13 @@ static int userfaultfd_stress(void) | |||
579 | /* verification */ | 580 | /* verification */ |
580 | if (bounces & BOUNCE_VERIFY) { | 581 | if (bounces & BOUNCE_VERIFY) { |
581 | for (nr = 0; nr < nr_pages; nr++) { | 582 | for (nr = 0; nr < nr_pages; nr++) { |
582 | if (my_bcmp(area_dst, | ||
583 | area_dst + nr * page_size, | ||
584 | sizeof(pthread_mutex_t))) { | ||
585 | fprintf(stderr, | ||
586 | "error mutex 2 %lu\n", | ||
587 | nr); | ||
588 | bounces = 0; | ||
589 | } | ||
590 | if (*area_count(area_dst, nr) != count_verify[nr]) { | 583 | if (*area_count(area_dst, nr) != count_verify[nr]) { |
591 | fprintf(stderr, | 584 | fprintf(stderr, |
592 | "error area_count %Lu %Lu %lu\n", | 585 | "error area_count %Lu %Lu %lu\n", |
593 | *area_count(area_src, nr), | 586 | *area_count(area_src, nr), |
594 | count_verify[nr], | 587 | count_verify[nr], |
595 | nr); | 588 | nr); |
589 | err = 1; | ||
596 | bounces = 0; | 590 | bounces = 0; |
597 | } | 591 | } |
598 | } | 592 | } |
@@ -609,7 +603,7 @@ static int userfaultfd_stress(void) | |||
609 | printf("\n"); | 603 | printf("\n"); |
610 | } | 604 | } |
611 | 605 | ||
612 | return 0; | 606 | return err; |
613 | } | 607 | } |
614 | 608 | ||
615 | int main(int argc, char **argv) | 609 | int main(int argc, char **argv) |
@@ -618,8 +612,8 @@ int main(int argc, char **argv) | |||
618 | fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1); | 612 | fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1); |
619 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); | 613 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
620 | page_size = sysconf(_SC_PAGE_SIZE); | 614 | page_size = sysconf(_SC_PAGE_SIZE); |
621 | if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) > | 615 | if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) * 2 |
622 | page_size) | 616 | > page_size) |
623 | fprintf(stderr, "Impossible to run this test\n"), exit(2); | 617 | fprintf(stderr, "Impossible to run this test\n"), exit(2); |
624 | nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size / | 618 | nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size / |
625 | nr_cpus; | 619 | nr_cpus; |
@@ -637,3 +631,15 @@ int main(int argc, char **argv) | |||
637 | nr_pages, nr_pages_per_cpu); | 631 | nr_pages, nr_pages_per_cpu); |
638 | return userfaultfd_stress(); | 632 | return userfaultfd_stress(); |
639 | } | 633 | } |
634 | |||
635 | #else /* __NR_userfaultfd */ | ||
636 | |||
637 | #warning "missing __NR_userfaultfd definition" | ||
638 | |||
639 | int main(void) | ||
640 | { | ||
641 | printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | #endif /* __NR_userfaultfd */ | ||
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c index 9a43a59a9bb4..421c607a8856 100644 --- a/tools/testing/selftests/x86/entry_from_vm86.c +++ b/tools/testing/selftests/x86/entry_from_vm86.c | |||
@@ -116,8 +116,9 @@ static bool do_test(struct vm86plus_struct *v86, unsigned long eip, | |||
116 | v86->regs.eip = eip; | 116 | v86->regs.eip = eip; |
117 | ret = vm86(VM86_ENTER, v86); | 117 | ret = vm86(VM86_ENTER, v86); |
118 | 118 | ||
119 | if (ret == -1 && errno == ENOSYS) { | 119 | if (ret == -1 && (errno == ENOSYS || errno == EPERM)) { |
120 | printf("[SKIP]\tvm86 not supported\n"); | 120 | printf("[SKIP]\tvm86 %s\n", |
121 | errno == ENOSYS ? "not supported" : "not allowed"); | ||
121 | return false; | 122 | return false; |
122 | } | 123 | } |
123 | 124 | ||
diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh index 20de9a761269..683a292e3290 100755 --- a/tools/testing/selftests/zram/zram.sh +++ b/tools/testing/selftests/zram/zram.sh | |||
@@ -1,15 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | TCID="zram.sh" | 2 | TCID="zram.sh" |
3 | 3 | ||
4 | check_prereqs() | 4 | . ./zram_lib.sh |
5 | { | ||
6 | local msg="skip all tests:" | ||
7 | |||
8 | if [ $UID != 0 ]; then | ||
9 | echo $msg must be run as root >&2 | ||
10 | exit 0 | ||
11 | fi | ||
12 | } | ||
13 | 5 | ||
14 | run_zram () { | 6 | run_zram () { |
15 | echo "--------------------" | 7 | echo "--------------------" |
diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh index 424e68ed1487..f6a9c73e7a44 100755 --- a/tools/testing/selftests/zram/zram_lib.sh +++ b/tools/testing/selftests/zram/zram_lib.sh | |||
@@ -23,8 +23,9 @@ trap INT | |||
23 | check_prereqs() | 23 | check_prereqs() |
24 | { | 24 | { |
25 | local msg="skip all tests:" | 25 | local msg="skip all tests:" |
26 | local uid=$(id -u) | ||
26 | 27 | ||
27 | if [ $UID != 0 ]; then | 28 | if [ $uid -ne 0 ]; then |
28 | echo $msg must be run as root >&2 | 29 | echo $msg must be run as root >&2 |
29 | exit 0 | 30 | exit 0 |
30 | fi | 31 | fi |
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile index 505ad51b3b51..39c89a5ea990 100644 --- a/tools/virtio/Makefile +++ b/tools/virtio/Makefile | |||
@@ -6,7 +6,7 @@ vringh_test: vringh_test.o vringh.o virtio_ring.o | |||
6 | CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE | 6 | CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE |
7 | vpath %.c ../../drivers/virtio ../../drivers/vhost | 7 | vpath %.c ../../drivers/virtio ../../drivers/vhost |
8 | mod: | 8 | mod: |
9 | ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test | 9 | ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V} |
10 | .PHONY: all test mod clean | 10 | .PHONY: all test mod clean |
11 | clean: | 11 | clean: |
12 | ${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \ | 12 | ${RM} *.o vringh_test virtio_test vhost_test/*.o vhost_test/.*.cmd \ |
diff --git a/tools/virtio/asm/barrier.h b/tools/virtio/asm/barrier.h index aff61e13306c..26b7926bda88 100644 --- a/tools/virtio/asm/barrier.h +++ b/tools/virtio/asm/barrier.h | |||
@@ -3,6 +3,8 @@ | |||
3 | #define mb() __sync_synchronize() | 3 | #define mb() __sync_synchronize() |
4 | 4 | ||
5 | #define smp_mb() mb() | 5 | #define smp_mb() mb() |
6 | # define dma_rmb() barrier() | ||
7 | # define dma_wmb() barrier() | ||
6 | # define smp_rmb() barrier() | 8 | # define smp_rmb() barrier() |
7 | # define smp_wmb() barrier() | 9 | # define smp_wmb() barrier() |
8 | /* Weak barriers should be used. If not - it's a bug */ | 10 | /* Weak barriers should be used. If not - it's a bug */ |
diff --git a/tools/virtio/linux/export.h b/tools/virtio/linux/export.h new file mode 100644 index 000000000000..416875e29254 --- /dev/null +++ b/tools/virtio/linux/export.h | |||
@@ -0,0 +1,3 @@ | |||
1 | #define EXPORT_SYMBOL_GPL(sym) extern typeof(sym) sym | ||
2 | #define EXPORT_SYMBOL(sym) extern typeof(sym) sym | ||
3 | |||
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h index 1e8ce6979c1e..0a3da64638ce 100644 --- a/tools/virtio/linux/kernel.h +++ b/tools/virtio/linux/kernel.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | typedef unsigned long long dma_addr_t; | 23 | typedef unsigned long long dma_addr_t; |
24 | typedef size_t __kernel_size_t; | 24 | typedef size_t __kernel_size_t; |
25 | typedef unsigned int __wsum; | ||
25 | 26 | ||
26 | struct page { | 27 | struct page { |
27 | unsigned long long dummy; | 28 | unsigned long long dummy; |
@@ -47,6 +48,13 @@ static inline void *kmalloc(size_t s, gfp_t gfp) | |||
47 | return __kmalloc_fake; | 48 | return __kmalloc_fake; |
48 | return malloc(s); | 49 | return malloc(s); |
49 | } | 50 | } |
51 | static inline void *kzalloc(size_t s, gfp_t gfp) | ||
52 | { | ||
53 | void *p = kmalloc(s, gfp); | ||
54 | |||
55 | memset(p, 0, s); | ||
56 | return p; | ||
57 | } | ||
50 | 58 | ||
51 | static inline void kfree(void *p) | 59 | static inline void kfree(void *p) |
52 | { | 60 | { |