aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-01 16:07:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-01 16:07:48 -0500
commit455e987c0c2eb2c9045dc854559474cf41509965 (patch)
treeed1923005053eca6f9bd06625e4d278feb6e950c /tools
parent7c17e486e865d616f0e37c7f7f0e4dcfab704cd8 (diff)
parentfd6da696f38b00ffeae1185d6f0ec5d4ab3b472d (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "This is mostly about unbreaking architectures that took the UAPI changes in the v3.7 cycle, plus misc fixes." * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf kvm: Fix building perf kvm on non x86 arches perf kvm: Rename perf_kvm to perf_kvm_stat perf: Make perf build for x86 with UAPI disintegration applied perf powerpc: Use uapi/unistd.h to fix build error tools: Pass the target in descend tools: Honour the O= flag when tool build called from a higher Makefile tools: Define a Makefile function to do subdir processing x86: Export asm/{svm.h,vmx.h,perf_regs.h} perf tools: Fix strbuf_addf() when the buffer needs to grow perf header: Fix numa topology printing perf, powerpc: Fix hw breakpoints returning -ENOSPC
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile24
-rw-r--r--tools/perf/Makefile29
-rw-r--r--tools/perf/arch/x86/include/perf_regs.h2
-rw-r--r--tools/perf/builtin-kvm.c121
-rw-r--r--tools/perf/builtin-test.c2
-rw-r--r--tools/perf/perf.h16
-rw-r--r--tools/perf/util/evsel.c4
-rw-r--r--tools/perf/util/evsel.h3
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/header.h2
-rw-r--r--tools/perf/util/parse-events-test.c2
-rw-r--r--tools/perf/util/parse-events.c2
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/pmu.h2
-rw-r--r--tools/perf/util/session.h2
-rw-r--r--tools/perf/util/strbuf.c8
-rw-r--r--tools/scripts/Makefile.include23
17 files changed, 148 insertions, 98 deletions
diff --git a/tools/Makefile b/tools/Makefile
index 3ae43947a171..1f9a529fe544 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -31,44 +31,44 @@ help:
31 @echo ' clean: a summary clean target to clean _all_ folders' 31 @echo ' clean: a summary clean target to clean _all_ folders'
32 32
33cpupower: FORCE 33cpupower: FORCE
34 $(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1) 34 $(call descend,power/$@)
35 35
36firewire lguest perf usb virtio vm: FORCE 36firewire lguest perf usb virtio vm: FORCE
37 $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1) 37 $(call descend,$@)
38 38
39selftests: FORCE 39selftests: FORCE
40 $(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1) 40 $(call descend,testing/$@)
41 41
42turbostat x86_energy_perf_policy: FORCE 42turbostat x86_energy_perf_policy: FORCE
43 $(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1) 43 $(call descend,power/x86/$@)
44 44
45cpupower_install: 45cpupower_install:
46 $(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install 46 $(call descend,power/$(@:_install=),install)
47 47
48firewire_install lguest_install perf_install usb_install virtio_install vm_install: 48firewire_install lguest_install perf_install usb_install virtio_install vm_install:
49 $(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install 49 $(call descend,$(@:_install=),install)
50 50
51selftests_install: 51selftests_install:
52 $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install 52 $(call descend,testing/$(@:_clean=),install)
53 53
54turbostat_install x86_energy_perf_policy_install: 54turbostat_install x86_energy_perf_policy_install:
55 $(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install 55 $(call descend,power/x86/$(@:_install=),install)
56 56
57install: cpupower_install firewire_install lguest_install perf_install \ 57install: cpupower_install firewire_install lguest_install perf_install \
58 selftests_install turbostat_install usb_install virtio_install \ 58 selftests_install turbostat_install usb_install virtio_install \
59 vm_install x86_energy_perf_policy_install 59 vm_install x86_energy_perf_policy_install
60 60
61cpupower_clean: 61cpupower_clean:
62 $(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean 62 $(call descend,power/cpupower,clean)
63 63
64firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean: 64firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
65 $(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean 65 $(call descend,$(@:_clean=),clean)
66 66
67selftests_clean: 67selftests_clean:
68 $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 68 $(call descend,testing/$(@:_clean=),clean)
69 69
70turbostat_clean x86_energy_perf_policy_clean: 70turbostat_clean x86_energy_perf_policy_clean:
71 $(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 71 $(call descend,power/x86/$(@:_clean=),clean)
72 72
73clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \ 73clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
74 turbostat_clean usb_clean virtio_clean vm_clean \ 74 turbostat_clean usb_clean virtio_clean vm_clean \
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 00deed4d6159..0a619af5be43 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -169,7 +169,34 @@ endif
169 169
170### --- END CONFIGURATION SECTION --- 170### --- END CONFIGURATION SECTION ---
171 171
172BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 172ifeq ($(srctree),)
173srctree := $(patsubst %/,%,$(dir $(shell pwd)))
174srctree := $(patsubst %/,%,$(dir $(srctree)))
175#$(info Determined 'srctree' to be $(srctree))
176endif
177
178ifneq ($(objtree),)
179#$(info Determined 'objtree' to be $(objtree))
180endif
181
182ifneq ($(OUTPUT),)
183#$(info Determined 'OUTPUT' to be $(OUTPUT))
184endif
185
186BASIC_CFLAGS = \
187 -Iutil/include \
188 -Iarch/$(ARCH)/include \
189 $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \
190 -I$(srctree)/arch/$(ARCH)/include/uapi \
191 -I$(srctree)/arch/$(ARCH)/include \
192 $(if $(objtree),-I$(objtree)/include/generated/uapi) \
193 -I$(srctree)/include/uapi \
194 -I$(srctree)/include \
195 -I$(OUTPUT)util \
196 -Iutil \
197 -I. \
198 -I$(TRACE_EVENT_DIR) \
199 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
173BASIC_LDFLAGS = 200BASIC_LDFLAGS =
174 201
175# Guard against environment variables 202# Guard against environment variables
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index 46fc9f15c6b3..7fcdcdbee917 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -3,7 +3,7 @@
3 3
4#include <stdlib.h> 4#include <stdlib.h>
5#include "../../util/types.h" 5#include "../../util/types.h"
6#include "../../../../../arch/x86/include/asm/perf_regs.h" 6#include <asm/perf_regs.h>
7 7
8#ifndef ARCH_X86_64 8#ifndef ARCH_X86_64
9#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) 9#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 260abc535b5b..283b4397e397 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -22,9 +22,10 @@
22#include <pthread.h> 22#include <pthread.h>
23#include <math.h> 23#include <math.h>
24 24
25#include "../../arch/x86/include/asm/svm.h" 25#if defined(__i386__) || defined(__x86_64__)
26#include "../../arch/x86/include/asm/vmx.h" 26#include <asm/svm.h>
27#include "../../arch/x86/include/asm/kvm.h" 27#include <asm/vmx.h>
28#include <asm/kvm.h>
28 29
29struct event_key { 30struct event_key {
30 #define INVALID_KEY (~0ULL) 31 #define INVALID_KEY (~0ULL)
@@ -58,7 +59,7 @@ struct kvm_event_key {
58}; 59};
59 60
60 61
61struct perf_kvm; 62struct perf_kvm_stat;
62 63
63struct kvm_events_ops { 64struct kvm_events_ops {
64 bool (*is_begin_event)(struct perf_evsel *evsel, 65 bool (*is_begin_event)(struct perf_evsel *evsel,
@@ -66,7 +67,7 @@ struct kvm_events_ops {
66 struct event_key *key); 67 struct event_key *key);
67 bool (*is_end_event)(struct perf_evsel *evsel, 68 bool (*is_end_event)(struct perf_evsel *evsel,
68 struct perf_sample *sample, struct event_key *key); 69 struct perf_sample *sample, struct event_key *key);
69 void (*decode_key)(struct perf_kvm *kvm, struct event_key *key, 70 void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
70 char decode[20]); 71 char decode[20]);
71 const char *name; 72 const char *name;
72}; 73};
@@ -79,7 +80,7 @@ struct exit_reasons_table {
79#define EVENTS_BITS 12 80#define EVENTS_BITS 12
80#define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS) 81#define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
81 82
82struct perf_kvm { 83struct perf_kvm_stat {
83 struct perf_tool tool; 84 struct perf_tool tool;
84 struct perf_session *session; 85 struct perf_session *session;
85 86
@@ -146,7 +147,7 @@ static struct exit_reasons_table svm_exit_reasons[] = {
146 SVM_EXIT_REASONS 147 SVM_EXIT_REASONS
147}; 148};
148 149
149static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code) 150static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code)
150{ 151{
151 int i = kvm->exit_reasons_size; 152 int i = kvm->exit_reasons_size;
152 struct exit_reasons_table *tbl = kvm->exit_reasons; 153 struct exit_reasons_table *tbl = kvm->exit_reasons;
@@ -162,7 +163,7 @@ static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code)
162 return "UNKNOWN"; 163 return "UNKNOWN";
163} 164}
164 165
165static void exit_event_decode_key(struct perf_kvm *kvm, 166static void exit_event_decode_key(struct perf_kvm_stat *kvm,
166 struct event_key *key, 167 struct event_key *key,
167 char decode[20]) 168 char decode[20])
168{ 169{
@@ -228,7 +229,7 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
228 return false; 229 return false;
229} 230}
230 231
231static void mmio_event_decode_key(struct perf_kvm *kvm __maybe_unused, 232static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
232 struct event_key *key, 233 struct event_key *key,
233 char decode[20]) 234 char decode[20])
234{ 235{
@@ -271,7 +272,7 @@ static bool ioport_event_end(struct perf_evsel *evsel,
271 return kvm_entry_event(evsel); 272 return kvm_entry_event(evsel);
272} 273}
273 274
274static void ioport_event_decode_key(struct perf_kvm *kvm __maybe_unused, 275static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
275 struct event_key *key, 276 struct event_key *key,
276 char decode[20]) 277 char decode[20])
277{ 278{
@@ -286,7 +287,7 @@ static struct kvm_events_ops ioport_events = {
286 .name = "IO Port Access" 287 .name = "IO Port Access"
287}; 288};
288 289
289static bool register_kvm_events_ops(struct perf_kvm *kvm) 290static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
290{ 291{
291 bool ret = true; 292 bool ret = true;
292 293
@@ -311,7 +312,7 @@ struct vcpu_event_record {
311}; 312};
312 313
313 314
314static void init_kvm_event_record(struct perf_kvm *kvm) 315static void init_kvm_event_record(struct perf_kvm_stat *kvm)
315{ 316{
316 int i; 317 int i;
317 318
@@ -360,7 +361,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
360 return event; 361 return event;
361} 362}
362 363
363static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm, 364static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm,
364 struct event_key *key) 365 struct event_key *key)
365{ 366{
366 struct kvm_event *event; 367 struct kvm_event *event;
@@ -381,7 +382,7 @@ static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm,
381 return event; 382 return event;
382} 383}
383 384
384static bool handle_begin_event(struct perf_kvm *kvm, 385static bool handle_begin_event(struct perf_kvm_stat *kvm,
385 struct vcpu_event_record *vcpu_record, 386 struct vcpu_event_record *vcpu_record,
386 struct event_key *key, u64 timestamp) 387 struct event_key *key, u64 timestamp)
387{ 388{
@@ -425,7 +426,7 @@ static bool update_kvm_event(struct kvm_event *event, int vcpu_id,
425 return true; 426 return true;
426} 427}
427 428
428static bool handle_end_event(struct perf_kvm *kvm, 429static bool handle_end_event(struct perf_kvm_stat *kvm,
429 struct vcpu_event_record *vcpu_record, 430 struct vcpu_event_record *vcpu_record,
430 struct event_key *key, 431 struct event_key *key,
431 u64 timestamp) 432 u64 timestamp)
@@ -486,7 +487,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
486 return thread->priv; 487 return thread->priv;
487} 488}
488 489
489static bool handle_kvm_event(struct perf_kvm *kvm, 490static bool handle_kvm_event(struct perf_kvm_stat *kvm,
490 struct thread *thread, 491 struct thread *thread,
491 struct perf_evsel *evsel, 492 struct perf_evsel *evsel,
492 struct perf_sample *sample) 493 struct perf_sample *sample)
@@ -541,7 +542,7 @@ static struct kvm_event_key keys[] = {
541 { NULL, NULL } 542 { NULL, NULL }
542}; 543};
543 544
544static bool select_key(struct perf_kvm *kvm) 545static bool select_key(struct perf_kvm_stat *kvm)
545{ 546{
546 int i; 547 int i;
547 548
@@ -577,7 +578,8 @@ static void insert_to_result(struct rb_root *result, struct kvm_event *event,
577 rb_insert_color(&event->rb, result); 578 rb_insert_color(&event->rb, result);
578} 579}
579 580
580static void update_total_count(struct perf_kvm *kvm, struct kvm_event *event) 581static void
582update_total_count(struct perf_kvm_stat *kvm, struct kvm_event *event)
581{ 583{
582 int vcpu = kvm->trace_vcpu; 584 int vcpu = kvm->trace_vcpu;
583 585
@@ -590,7 +592,7 @@ static bool event_is_valid(struct kvm_event *event, int vcpu)
590 return !!get_event_count(event, vcpu); 592 return !!get_event_count(event, vcpu);
591} 593}
592 594
593static void sort_result(struct perf_kvm *kvm) 595static void sort_result(struct perf_kvm_stat *kvm)
594{ 596{
595 unsigned int i; 597 unsigned int i;
596 int vcpu = kvm->trace_vcpu; 598 int vcpu = kvm->trace_vcpu;
@@ -627,7 +629,7 @@ static void print_vcpu_info(int vcpu)
627 pr_info("VCPU %d:\n\n", vcpu); 629 pr_info("VCPU %d:\n\n", vcpu);
628} 630}
629 631
630static void print_result(struct perf_kvm *kvm) 632static void print_result(struct perf_kvm_stat *kvm)
631{ 633{
632 char decode[20]; 634 char decode[20];
633 struct kvm_event *event; 635 struct kvm_event *event;
@@ -670,7 +672,8 @@ static int process_sample_event(struct perf_tool *tool,
670 struct machine *machine) 672 struct machine *machine)
671{ 673{
672 struct thread *thread = machine__findnew_thread(machine, sample->tid); 674 struct thread *thread = machine__findnew_thread(machine, sample->tid);
673 struct perf_kvm *kvm = container_of(tool, struct perf_kvm, tool); 675 struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat,
676 tool);
674 677
675 if (thread == NULL) { 678 if (thread == NULL) {
676 pr_debug("problem processing %d event, skipping it.\n", 679 pr_debug("problem processing %d event, skipping it.\n",
@@ -701,7 +704,7 @@ static int get_cpu_isa(struct perf_session *session)
701 return isa; 704 return isa;
702} 705}
703 706
704static int read_events(struct perf_kvm *kvm) 707static int read_events(struct perf_kvm_stat *kvm)
705{ 708{
706 int ret; 709 int ret;
707 710
@@ -750,7 +753,7 @@ static bool verify_vcpu(int vcpu)
750 return true; 753 return true;
751} 754}
752 755
753static int kvm_events_report_vcpu(struct perf_kvm *kvm) 756static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm)
754{ 757{
755 int ret = -EINVAL; 758 int ret = -EINVAL;
756 int vcpu = kvm->trace_vcpu; 759 int vcpu = kvm->trace_vcpu;
@@ -798,7 +801,8 @@ static const char * const record_args[] = {
798 _p; \ 801 _p; \
799 }) 802 })
800 803
801static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv) 804static int
805kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
802{ 806{
803 unsigned int rec_argc, i, j; 807 unsigned int rec_argc, i, j;
804 const char **rec_argv; 808 const char **rec_argv;
@@ -821,7 +825,8 @@ static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv)
821 return cmd_record(i, rec_argv, NULL); 825 return cmd_record(i, rec_argv, NULL);
822} 826}
823 827
824static int kvm_events_report(struct perf_kvm *kvm, int argc, const char **argv) 828static int
829kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
825{ 830{
826 const struct option kvm_events_report_options[] = { 831 const struct option kvm_events_report_options[] = {
827 OPT_STRING(0, "event", &kvm->report_event, "report event", 832 OPT_STRING(0, "event", &kvm->report_event, "report event",
@@ -864,24 +869,37 @@ static void print_kvm_stat_usage(void)
864 printf("\nOtherwise, it is the alias of 'perf stat':\n"); 869 printf("\nOtherwise, it is the alias of 'perf stat':\n");
865} 870}
866 871
867static int kvm_cmd_stat(struct perf_kvm *kvm, int argc, const char **argv) 872static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
868{ 873{
874 struct perf_kvm_stat kvm = {
875 .file_name = file_name,
876
877 .trace_vcpu = -1,
878 .report_event = "vmexit",
879 .sort_key = "sample",
880
881 .exit_reasons = svm_exit_reasons,
882 .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
883 .exit_reasons_isa = "SVM",
884 };
885
869 if (argc == 1) { 886 if (argc == 1) {
870 print_kvm_stat_usage(); 887 print_kvm_stat_usage();
871 goto perf_stat; 888 goto perf_stat;
872 } 889 }
873 890
874 if (!strncmp(argv[1], "rec", 3)) 891 if (!strncmp(argv[1], "rec", 3))
875 return kvm_events_record(kvm, argc - 1, argv + 1); 892 return kvm_events_record(&kvm, argc - 1, argv + 1);
876 893
877 if (!strncmp(argv[1], "rep", 3)) 894 if (!strncmp(argv[1], "rep", 3))
878 return kvm_events_report(kvm, argc - 1 , argv + 1); 895 return kvm_events_report(&kvm, argc - 1 , argv + 1);
879 896
880perf_stat: 897perf_stat:
881 return cmd_stat(argc, argv, NULL); 898 return cmd_stat(argc, argv, NULL);
882} 899}
900#endif
883 901
884static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv) 902static int __cmd_record(const char *file_name, int argc, const char **argv)
885{ 903{
886 int rec_argc, i = 0, j; 904 int rec_argc, i = 0, j;
887 const char **rec_argv; 905 const char **rec_argv;
@@ -890,7 +908,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
890 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 908 rec_argv = calloc(rec_argc + 1, sizeof(char *));
891 rec_argv[i++] = strdup("record"); 909 rec_argv[i++] = strdup("record");
892 rec_argv[i++] = strdup("-o"); 910 rec_argv[i++] = strdup("-o");
893 rec_argv[i++] = strdup(kvm->file_name); 911 rec_argv[i++] = strdup(file_name);
894 for (j = 1; j < argc; j++, i++) 912 for (j = 1; j < argc; j++, i++)
895 rec_argv[i] = argv[j]; 913 rec_argv[i] = argv[j];
896 914
@@ -899,7 +917,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
899 return cmd_record(i, rec_argv, NULL); 917 return cmd_record(i, rec_argv, NULL);
900} 918}
901 919
902static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv) 920static int __cmd_report(const char *file_name, int argc, const char **argv)
903{ 921{
904 int rec_argc, i = 0, j; 922 int rec_argc, i = 0, j;
905 const char **rec_argv; 923 const char **rec_argv;
@@ -908,7 +926,7 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
908 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 926 rec_argv = calloc(rec_argc + 1, sizeof(char *));
909 rec_argv[i++] = strdup("report"); 927 rec_argv[i++] = strdup("report");
910 rec_argv[i++] = strdup("-i"); 928 rec_argv[i++] = strdup("-i");
911 rec_argv[i++] = strdup(kvm->file_name); 929 rec_argv[i++] = strdup(file_name);
912 for (j = 1; j < argc; j++, i++) 930 for (j = 1; j < argc; j++, i++)
913 rec_argv[i] = argv[j]; 931 rec_argv[i] = argv[j];
914 932
@@ -917,7 +935,8 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
917 return cmd_report(i, rec_argv, NULL); 935 return cmd_report(i, rec_argv, NULL);
918} 936}
919 937
920static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv) 938static int
939__cmd_buildid_list(const char *file_name, int argc, const char **argv)
921{ 940{
922 int rec_argc, i = 0, j; 941 int rec_argc, i = 0, j;
923 const char **rec_argv; 942 const char **rec_argv;
@@ -926,7 +945,7 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
926 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 945 rec_argv = calloc(rec_argc + 1, sizeof(char *));
927 rec_argv[i++] = strdup("buildid-list"); 946 rec_argv[i++] = strdup("buildid-list");
928 rec_argv[i++] = strdup("-i"); 947 rec_argv[i++] = strdup("-i");
929 rec_argv[i++] = strdup(kvm->file_name); 948 rec_argv[i++] = strdup(file_name);
930 for (j = 1; j < argc; j++, i++) 949 for (j = 1; j < argc; j++, i++)
931 rec_argv[i] = argv[j]; 950 rec_argv[i] = argv[j];
932 951
@@ -937,20 +956,12 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
937 956
938int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) 957int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
939{ 958{
940 struct perf_kvm kvm = { 959 const char *file_name;
941 .trace_vcpu = -1,
942 .report_event = "vmexit",
943 .sort_key = "sample",
944
945 .exit_reasons = svm_exit_reasons,
946 .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
947 .exit_reasons_isa = "SVM",
948 };
949 960
950 const struct option kvm_options[] = { 961 const struct option kvm_options[] = {
951 OPT_STRING('i', "input", &kvm.file_name, "file", 962 OPT_STRING('i', "input", &file_name, "file",
952 "Input file name"), 963 "Input file name"),
953 OPT_STRING('o', "output", &kvm.file_name, "file", 964 OPT_STRING('o', "output", &file_name, "file",
954 "Output file name"), 965 "Output file name"),
955 OPT_BOOLEAN(0, "guest", &perf_guest, 966 OPT_BOOLEAN(0, "guest", &perf_guest,
956 "Collect guest os data"), 967 "Collect guest os data"),
@@ -985,32 +996,34 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
985 if (!perf_host) 996 if (!perf_host)
986 perf_guest = 1; 997 perf_guest = 1;
987 998
988 if (!kvm.file_name) { 999 if (!file_name) {
989 if (perf_host && !perf_guest) 1000 if (perf_host && !perf_guest)
990 kvm.file_name = strdup("perf.data.host"); 1001 file_name = strdup("perf.data.host");
991 else if (!perf_host && perf_guest) 1002 else if (!perf_host && perf_guest)
992 kvm.file_name = strdup("perf.data.guest"); 1003 file_name = strdup("perf.data.guest");
993 else 1004 else
994 kvm.file_name = strdup("perf.data.kvm"); 1005 file_name = strdup("perf.data.kvm");
995 1006
996 if (!kvm.file_name) { 1007 if (!file_name) {
997 pr_err("Failed to allocate memory for filename\n"); 1008 pr_err("Failed to allocate memory for filename\n");
998 return -ENOMEM; 1009 return -ENOMEM;
999 } 1010 }
1000 } 1011 }
1001 1012
1002 if (!strncmp(argv[0], "rec", 3)) 1013 if (!strncmp(argv[0], "rec", 3))
1003 return __cmd_record(&kvm, argc, argv); 1014 return __cmd_record(file_name, argc, argv);
1004 else if (!strncmp(argv[0], "rep", 3)) 1015 else if (!strncmp(argv[0], "rep", 3))
1005 return __cmd_report(&kvm, argc, argv); 1016 return __cmd_report(file_name, argc, argv);
1006 else if (!strncmp(argv[0], "diff", 4)) 1017 else if (!strncmp(argv[0], "diff", 4))
1007 return cmd_diff(argc, argv, NULL); 1018 return cmd_diff(argc, argv, NULL);
1008 else if (!strncmp(argv[0], "top", 3)) 1019 else if (!strncmp(argv[0], "top", 3))
1009 return cmd_top(argc, argv, NULL); 1020 return cmd_top(argc, argv, NULL);
1010 else if (!strncmp(argv[0], "buildid-list", 12)) 1021 else if (!strncmp(argv[0], "buildid-list", 12))
1011 return __cmd_buildid_list(&kvm, argc, argv); 1022 return __cmd_buildid_list(file_name, argc, argv);
1023#if defined(__i386__) || defined(__x86_64__)
1012 else if (!strncmp(argv[0], "stat", 4)) 1024 else if (!strncmp(argv[0], "stat", 4))
1013 return kvm_cmd_stat(&kvm, argc, argv); 1025 return kvm_cmd_stat(file_name, argc, argv);
1026#endif
1014 else 1027 else
1015 usage_with_options(kvm_usage, kvm_options); 1028 usage_with_options(kvm_usage, kvm_options);
1016 1029
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 484f26cc0c00..5acd6e8e658b 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -15,7 +15,7 @@
15#include "util/thread_map.h" 15#include "util/thread_map.h"
16#include "util/pmu.h" 16#include "util/pmu.h"
17#include "event-parse.h" 17#include "event-parse.h"
18#include "../../include/linux/hw_breakpoint.h" 18#include <linux/hw_breakpoint.h>
19 19
20#include <sys/mman.h> 20#include <sys/mman.h>
21 21
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index c50985eaec41..238f923f2218 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -5,8 +5,9 @@ struct winsize;
5 5
6void get_term_dimensions(struct winsize *ws); 6void get_term_dimensions(struct winsize *ws);
7 7
8#include <asm/unistd.h>
9
8#if defined(__i386__) 10#if defined(__i386__)
9#include "../../arch/x86/include/asm/unistd.h"
10#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 11#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
11#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 12#define cpu_relax() asm volatile("rep; nop" ::: "memory");
12#define CPUINFO_PROC "model name" 13#define CPUINFO_PROC "model name"
@@ -16,7 +17,6 @@ void get_term_dimensions(struct winsize *ws);
16#endif 17#endif
17 18
18#if defined(__x86_64__) 19#if defined(__x86_64__)
19#include "../../arch/x86/include/asm/unistd.h"
20#define rmb() asm volatile("lfence" ::: "memory") 20#define rmb() asm volatile("lfence" ::: "memory")
21#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 21#define cpu_relax() asm volatile("rep; nop" ::: "memory");
22#define CPUINFO_PROC "model name" 22#define CPUINFO_PROC "model name"
@@ -26,20 +26,17 @@ void get_term_dimensions(struct winsize *ws);
26#endif 26#endif
27 27
28#ifdef __powerpc__ 28#ifdef __powerpc__
29#include "../../arch/powerpc/include/asm/unistd.h"
30#define rmb() asm volatile ("sync" ::: "memory") 29#define rmb() asm volatile ("sync" ::: "memory")
31#define cpu_relax() asm volatile ("" ::: "memory"); 30#define cpu_relax() asm volatile ("" ::: "memory");
32#define CPUINFO_PROC "cpu" 31#define CPUINFO_PROC "cpu"
33#endif 32#endif
34 33
35#ifdef __s390__ 34#ifdef __s390__
36#include "../../arch/s390/include/asm/unistd.h"
37#define rmb() asm volatile("bcr 15,0" ::: "memory") 35#define rmb() asm volatile("bcr 15,0" ::: "memory")
38#define cpu_relax() asm volatile("" ::: "memory"); 36#define cpu_relax() asm volatile("" ::: "memory");
39#endif 37#endif
40 38
41#ifdef __sh__ 39#ifdef __sh__
42#include "../../arch/sh/include/asm/unistd.h"
43#if defined(__SH4A__) || defined(__SH5__) 40#if defined(__SH4A__) || defined(__SH5__)
44# define rmb() asm volatile("synco" ::: "memory") 41# define rmb() asm volatile("synco" ::: "memory")
45#else 42#else
@@ -50,35 +47,30 @@ void get_term_dimensions(struct winsize *ws);
50#endif 47#endif
51 48
52#ifdef __hppa__ 49#ifdef __hppa__
53#include "../../arch/parisc/include/asm/unistd.h"
54#define rmb() asm volatile("" ::: "memory") 50#define rmb() asm volatile("" ::: "memory")
55#define cpu_relax() asm volatile("" ::: "memory"); 51#define cpu_relax() asm volatile("" ::: "memory");
56#define CPUINFO_PROC "cpu" 52#define CPUINFO_PROC "cpu"
57#endif 53#endif
58 54
59#ifdef __sparc__ 55#ifdef __sparc__
60#include "../../arch/sparc/include/uapi/asm/unistd.h"
61#define rmb() asm volatile("":::"memory") 56#define rmb() asm volatile("":::"memory")
62#define cpu_relax() asm volatile("":::"memory") 57#define cpu_relax() asm volatile("":::"memory")
63#define CPUINFO_PROC "cpu" 58#define CPUINFO_PROC "cpu"
64#endif 59#endif
65 60
66#ifdef __alpha__ 61#ifdef __alpha__
67#include "../../arch/alpha/include/asm/unistd.h"
68#define rmb() asm volatile("mb" ::: "memory") 62#define rmb() asm volatile("mb" ::: "memory")
69#define cpu_relax() asm volatile("" ::: "memory") 63#define cpu_relax() asm volatile("" ::: "memory")
70#define CPUINFO_PROC "cpu model" 64#define CPUINFO_PROC "cpu model"
71#endif 65#endif
72 66
73#ifdef __ia64__ 67#ifdef __ia64__
74#include "../../arch/ia64/include/asm/unistd.h"
75#define rmb() asm volatile ("mf" ::: "memory") 68#define rmb() asm volatile ("mf" ::: "memory")
76#define cpu_relax() asm volatile ("hint @pause" ::: "memory") 69#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
77#define CPUINFO_PROC "model name" 70#define CPUINFO_PROC "model name"
78#endif 71#endif
79 72
80#ifdef __arm__ 73#ifdef __arm__
81#include "../../arch/arm/include/asm/unistd.h"
82/* 74/*
83 * Use the __kuser_memory_barrier helper in the CPU helper page. See 75 * Use the __kuser_memory_barrier helper in the CPU helper page. See
84 * arch/arm/kernel/entry-armv.S in the kernel source for details. 76 * arch/arm/kernel/entry-armv.S in the kernel source for details.
@@ -89,13 +81,11 @@ void get_term_dimensions(struct winsize *ws);
89#endif 81#endif
90 82
91#ifdef __aarch64__ 83#ifdef __aarch64__
92#include "../../arch/arm64/include/asm/unistd.h"
93#define rmb() asm volatile("dmb ld" ::: "memory") 84#define rmb() asm volatile("dmb ld" ::: "memory")
94#define cpu_relax() asm volatile("yield" ::: "memory") 85#define cpu_relax() asm volatile("yield" ::: "memory")
95#endif 86#endif
96 87
97#ifdef __mips__ 88#ifdef __mips__
98#include "../../arch/mips/include/asm/unistd.h"
99#define rmb() asm volatile( \ 89#define rmb() asm volatile( \
100 ".set mips2\n\t" \ 90 ".set mips2\n\t" \
101 "sync\n\t" \ 91 "sync\n\t" \
@@ -112,7 +102,7 @@ void get_term_dimensions(struct winsize *ws);
112#include <sys/types.h> 102#include <sys/types.h>
113#include <sys/syscall.h> 103#include <sys/syscall.h>
114 104
115#include "../../include/uapi/linux/perf_event.h" 105#include <linux/perf_event.h>
116#include "util/types.h" 106#include "util/types.h"
117#include <stdbool.h> 107#include <stdbool.h>
118 108
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 618d41140abd..d144d464ce39 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -18,8 +18,8 @@
18#include "cpumap.h" 18#include "cpumap.h"
19#include "thread_map.h" 19#include "thread_map.h"
20#include "target.h" 20#include "target.h"
21#include "../../../include/linux/hw_breakpoint.h" 21#include <linux/hw_breakpoint.h>
22#include "../../../include/uapi/linux/perf_event.h" 22#include <linux/perf_event.h>
23#include "perf_regs.h" 23#include "perf_regs.h"
24 24
25#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) 25#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6f94d6dea00f..d99b476ef37c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -3,7 +3,8 @@
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "../../../include/uapi/linux/perf_event.h" 6#include <stddef.h>
7#include <linux/perf_event.h>
7#include "types.h" 8#include "types.h"
8#include "xyarray.h" 9#include "xyarray.h"
9#include "cgroup.h" 10#include "cgroup.h"
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 7daad237dea5..566b84c695c8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1378,6 +1378,8 @@ static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused,
1378 1378
1379 str = tmp + 1; 1379 str = tmp + 1;
1380 fprintf(fp, "# node%u cpu list : %s\n", c, str); 1380 fprintf(fp, "# node%u cpu list : %s\n", c, str);
1381
1382 str += strlen(str) + 1;
1381 } 1383 }
1382 return; 1384 return;
1383error: 1385error:
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 879d215cdac9..9bc00783f24f 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -1,7 +1,7 @@
1#ifndef __PERF_HEADER_H 1#ifndef __PERF_HEADER_H
2#define __PERF_HEADER_H 2#define __PERF_HEADER_H
3 3
4#include "../../../include/uapi/linux/perf_event.h" 4#include <linux/perf_event.h>
5#include <sys/types.h> 5#include <sys/types.h>
6#include <stdbool.h> 6#include <stdbool.h>
7#include "types.h" 7#include "types.h"
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c
index 516ecd9ddd6e..6ef213b35ecd 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -3,7 +3,7 @@
3#include "evsel.h" 3#include "evsel.h"
4#include "evlist.h" 4#include "evlist.h"
5#include "sysfs.h" 5#include "sysfs.h"
6#include "../../../include/linux/hw_breakpoint.h" 6#include <linux/hw_breakpoint.h>
7 7
8#define TEST_ASSERT_VAL(text, cond) \ 8#define TEST_ASSERT_VAL(text, cond) \
9do { \ 9do { \
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75c7b0fca6d9..6b6d03e93c3d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1,4 +1,4 @@
1#include "../../../include/linux/hw_breakpoint.h" 1#include <linux/hw_breakpoint.h>
2#include "util.h" 2#include "util.h"
3#include "../perf.h" 3#include "../perf.h"
4#include "evlist.h" 4#include "evlist.h"
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 839230ceb18b..2820c407adb2 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -7,7 +7,7 @@
7#include <linux/list.h> 7#include <linux/list.h>
8#include <stdbool.h> 8#include <stdbool.h>
9#include "types.h" 9#include "types.h"
10#include "../../../include/uapi/linux/perf_event.h" 10#include <linux/perf_event.h>
11#include "types.h" 11#include "types.h"
12 12
13struct list_head; 13struct list_head;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 39f3abac7744..fdeb8ac7c5d2 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -2,7 +2,7 @@
2#define __PMU_H 2#define __PMU_H
3 3
4#include <linux/bitops.h> 4#include <linux/bitops.h>
5#include "../../../include/uapi/linux/perf_event.h" 5#include <linux/perf_event.h>
6 6
7enum { 7enum {
8 PERF_PMU_FORMAT_VALUE_CONFIG, 8 PERF_PMU_FORMAT_VALUE_CONFIG,
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd6426163ba6..0eae00ad5fe7 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -7,7 +7,7 @@
7#include "symbol.h" 7#include "symbol.h"
8#include "thread.h" 8#include "thread.h"
9#include <linux/rbtree.h> 9#include <linux/rbtree.h>
10#include "../../../include/uapi/linux/perf_event.h" 10#include <linux/perf_event.h>
11 11
12struct sample_queue; 12struct sample_queue;
13struct ip_callchain; 13struct ip_callchain;
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 2eeb51baf077..cfa906882e2c 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -90,17 +90,17 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
90 if (!strbuf_avail(sb)) 90 if (!strbuf_avail(sb))
91 strbuf_grow(sb, 64); 91 strbuf_grow(sb, 64);
92 va_start(ap, fmt); 92 va_start(ap, fmt);
93 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 93 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
94 va_end(ap); 94 va_end(ap);
95 if (len < 0) 95 if (len < 0)
96 die("your vscnprintf is broken"); 96 die("your vsnprintf is broken");
97 if (len > strbuf_avail(sb)) { 97 if (len > strbuf_avail(sb)) {
98 strbuf_grow(sb, len); 98 strbuf_grow(sb, len);
99 va_start(ap, fmt); 99 va_start(ap, fmt);
100 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 100 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
101 va_end(ap); 101 va_end(ap);
102 if (len > strbuf_avail(sb)) { 102 if (len > strbuf_avail(sb)) {
103 die("this should not happen, your snprintf is broken"); 103 die("this should not happen, your vsnprintf is broken");
104 } 104 }
105 } 105 }
106 strbuf_setlen(sb, sb->len + len); 106 strbuf_setlen(sb, sb->len + len);
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 96ce80a3743b..2964b96aa55f 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,8 +1,11 @@
1ifeq ("$(origin O)", "command line") 1ifeq ($(origin O), command line)
2 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) 2 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
3 ABSOLUTE_O := $(shell cd $(O) ; pwd) 3 ABSOLUTE_O := $(shell cd $(O) ; pwd)
4 OUTPUT := $(ABSOLUTE_O)/ 4 OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
5 COMMAND_O := O=$(ABSOLUTE_O) 5 COMMAND_O := O=$(ABSOLUTE_O)
6ifeq ($(objtree),)
7 objtree := $(O)
8endif
6endif 9endif
7 10
8ifneq ($(OUTPUT),) 11ifneq ($(OUTPUT),)
@@ -41,7 +44,16 @@ else
41NO_SUBDIR = : 44NO_SUBDIR = :
42endif 45endif
43 46
44QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 47#
48# Define a callable command for descending to a new directory
49#
50# Call by doing: $(call descend,directory[,target])
51#
52descend = \
53 +mkdir -p $(OUTPUT)$(1) && \
54 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
55
56QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
45QUIET_SUBDIR1 = 57QUIET_SUBDIR1 =
46 58
47ifneq ($(findstring $(MAKEFLAGS),s),s) 59ifneq ($(findstring $(MAKEFLAGS),s),s)
@@ -56,5 +68,10 @@ ifndef V
56 $(MAKE) $(PRINT_DIR) -C $$subdir 68 $(MAKE) $(PRINT_DIR) -C $$subdir
57 QUIET_FLEX = @echo ' ' FLEX $@; 69 QUIET_FLEX = @echo ' ' FLEX $@;
58 QUIET_BISON = @echo ' ' BISON $@; 70 QUIET_BISON = @echo ' ' BISON $@;
71
72 descend = \
73 @echo ' ' DESCEND $(1); \
74 mkdir -p $(OUTPUT)$(1) && \
75 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
59endif 76endif
60endif 77endif