Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+194 -135
+4 -2
Makefile
··· 1321 1321 1322 1322 # Clear a bunch of variables before executing the submake 1323 1323 tools/: FORCE 1324 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ 1324 + $(Q)mkdir -p $(objtree)/tools 1325 + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ 1325 1326 1326 1327 tools/%: FORCE 1327 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $* 1328 + $(Q)mkdir -p $(objtree)/tools 1329 + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $* 1328 1330 1329 1331 # Single targets 1330 1332 # ---------------------------------------------------------------------------
+3
arch/x86/include/asm/Kbuild
··· 12 12 header-y += msr-index.h 13 13 header-y += msr.h 14 14 header-y += mtrr.h 15 + header-y += perf_regs.h 15 16 header-y += posix_types_32.h 16 17 header-y += posix_types_64.h 17 18 header-y += posix_types_x32.h ··· 20 19 header-y += processor-flags.h 21 20 header-y += ptrace-abi.h 22 21 header-y += sigcontext32.h 22 + header-y += svm.h 23 23 header-y += ucontext.h 24 24 header-y += vm86.h 25 + header-y += vmx.h 25 26 header-y += vsyscall.h 26 27 27 28 genhdr-y += unistd_32.h
+1 -30
include/linux/hw_breakpoint.h
··· 1 1 #ifndef _LINUX_HW_BREAKPOINT_H 2 2 #define _LINUX_HW_BREAKPOINT_H 3 3 4 - enum { 5 - HW_BREAKPOINT_LEN_1 = 1, 6 - HW_BREAKPOINT_LEN_2 = 2, 7 - HW_BREAKPOINT_LEN_4 = 4, 8 - HW_BREAKPOINT_LEN_8 = 8, 9 - }; 10 - 11 - enum { 12 - HW_BREAKPOINT_EMPTY = 0, 13 - HW_BREAKPOINT_R = 1, 14 - HW_BREAKPOINT_W = 2, 15 - HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W, 16 - HW_BREAKPOINT_X = 4, 17 - HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X, 18 - }; 19 - 20 - enum bp_type_idx { 21 - TYPE_INST = 0, 22 - #ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS 23 - TYPE_DATA = 0, 24 - #else 25 - TYPE_DATA = 1, 26 - #endif 27 - TYPE_MAX 28 - }; 29 - 30 - #ifdef __KERNEL__ 31 - 32 4 #include <linux/perf_event.h> 5 + #include <uapi/linux/hw_breakpoint.h> 33 6 34 7 #ifdef CONFIG_HAVE_HW_BREAKPOINT 35 8 ··· 124 151 } 125 152 126 153 #endif /* CONFIG_HAVE_HW_BREAKPOINT */ 127 - #endif /* __KERNEL__ */ 128 - 129 154 #endif /* _LINUX_HW_BREAKPOINT_H */
+1
include/uapi/linux/Kbuild
··· 415 415 header-y += x25.h 416 416 header-y += xattr.h 417 417 header-y += xfrm.h 418 + header-y += hw_breakpoint.h
+30
include/uapi/linux/hw_breakpoint.h
··· 1 + #ifndef _UAPI_LINUX_HW_BREAKPOINT_H 2 + #define _UAPI_LINUX_HW_BREAKPOINT_H 3 + 4 + enum { 5 + HW_BREAKPOINT_LEN_1 = 1, 6 + HW_BREAKPOINT_LEN_2 = 2, 7 + HW_BREAKPOINT_LEN_4 = 4, 8 + HW_BREAKPOINT_LEN_8 = 8, 9 + }; 10 + 11 + enum { 12 + HW_BREAKPOINT_EMPTY = 0, 13 + HW_BREAKPOINT_R = 1, 14 + HW_BREAKPOINT_W = 2, 15 + HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W, 16 + HW_BREAKPOINT_X = 4, 17 + HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X, 18 + }; 19 + 20 + enum bp_type_idx { 21 + TYPE_INST = 0, 22 + #ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS 23 + TYPE_DATA = 0, 24 + #else 25 + TYPE_DATA = 1, 26 + #endif 27 + TYPE_MAX 28 + }; 29 + 30 + #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
+7 -5
kernel/events/hw_breakpoint.c
··· 111 111 * Count the number of breakpoints of the same type and same task. 112 112 * The given event must be not on the list. 113 113 */ 114 - static int task_bp_pinned(struct perf_event *bp, enum bp_type_idx type) 114 + static int task_bp_pinned(int cpu, struct perf_event *bp, enum bp_type_idx type) 115 115 { 116 116 struct task_struct *tsk = bp->hw.bp_target; 117 117 struct perf_event *iter; 118 118 int count = 0; 119 119 120 120 list_for_each_entry(iter, &bp_task_head, hw.bp_list) { 121 - if (iter->hw.bp_target == tsk && find_slot_idx(iter) == type) 121 + if (iter->hw.bp_target == tsk && 122 + find_slot_idx(iter) == type && 123 + cpu == iter->cpu) 122 124 count += hw_breakpoint_weight(iter); 123 125 } 124 126 ··· 143 141 if (!tsk) 144 142 slots->pinned += max_task_bp_pinned(cpu, type); 145 143 else 146 - slots->pinned += task_bp_pinned(bp, type); 144 + slots->pinned += task_bp_pinned(cpu, bp, type); 147 145 slots->flexible = per_cpu(nr_bp_flexible[type], cpu); 148 146 149 147 return; ··· 156 154 if (!tsk) 157 155 nr += max_task_bp_pinned(cpu, type); 158 156 else 159 - nr += task_bp_pinned(bp, type); 157 + nr += task_bp_pinned(cpu, bp, type); 160 158 161 159 if (nr > slots->pinned) 162 160 slots->pinned = nr; ··· 190 188 int old_idx = 0; 191 189 int idx = 0; 192 190 193 - old_count = task_bp_pinned(bp, type); 191 + old_count = task_bp_pinned(cpu, bp, type); 194 192 old_idx = old_count - 1; 195 193 idx = old_idx + weight; 196 194
+12 -12
tools/Makefile
··· 31 31 @echo ' clean: a summary clean target to clean _all_ folders' 32 32 33 33 cpupower: FORCE 34 - $(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1) 34 + $(call descend,power/$@) 35 35 36 36 firewire lguest perf usb virtio vm: FORCE 37 - $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1) 37 + $(call descend,$@) 38 38 39 39 selftests: FORCE 40 - $(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1) 40 + $(call descend,testing/$@) 41 41 42 42 turbostat x86_energy_perf_policy: FORCE 43 - $(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1) 43 + $(call descend,power/x86/$@) 44 44 45 45 cpupower_install: 46 - $(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install 46 + $(call descend,power/$(@:_install=),install) 47 47 48 48 firewire_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 51 51 selftests_install: 52 - $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install 52 + $(call descend,testing/$(@:_clean=),install) 53 53 54 54 turbostat_install x86_energy_perf_policy_install: 55 - $(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install 55 + $(call descend,power/x86/$(@:_install=),install) 56 56 57 57 install: cpupower_install firewire_install lguest_install perf_install \ 58 58 selftests_install turbostat_install usb_install virtio_install \ 59 59 vm_install x86_energy_perf_policy_install 60 60 61 61 cpupower_clean: 62 - $(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean 62 + $(call descend,power/cpupower,clean) 63 63 64 64 firewire_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 67 67 selftests_clean: 68 - $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 68 + $(call descend,testing/$(@:_clean=),clean) 69 69 70 70 turbostat_clean x86_energy_perf_policy_clean: 71 - $(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 71 + $(call descend,power/x86/$(@:_clean=),clean) 72 72 73 73 clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \ 74 74 turbostat_clean usb_clean virtio_clean vm_clean \
+28 -1
tools/perf/Makefile
··· 169 169 170 170 ### --- END CONFIGURATION SECTION --- 171 171 172 - BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 172 + ifeq ($(srctree),) 173 + srctree := $(patsubst %/,%,$(dir $(shell pwd))) 174 + srctree := $(patsubst %/,%,$(dir $(srctree))) 175 + #$(info Determined 'srctree' to be $(srctree)) 176 + endif 177 + 178 + ifneq ($(objtree),) 179 + #$(info Determined 'objtree' to be $(objtree)) 180 + endif 181 + 182 + ifneq ($(OUTPUT),) 183 + #$(info Determined 'OUTPUT' to be $(OUTPUT)) 184 + endif 185 + 186 + BASIC_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 173 200 BASIC_LDFLAGS = 174 201 175 202 # Guard against environment variables
+1 -1
tools/perf/arch/x86/include/perf_regs.h
··· 3 3 4 4 #include <stdlib.h> 5 5 #include "../../util/types.h" 6 - #include "../../../../../arch/x86/include/asm/perf_regs.h" 6 + #include <asm/perf_regs.h> 7 7 8 8 #ifndef ARCH_X86_64 9 9 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
+67 -54
tools/perf/builtin-kvm.c
··· 22 22 #include <pthread.h> 23 23 #include <math.h> 24 24 25 - #include "../../arch/x86/include/asm/svm.h" 26 - #include "../../arch/x86/include/asm/vmx.h" 27 - #include "../../arch/x86/include/asm/kvm.h" 25 + #if defined(__i386__) || defined(__x86_64__) 26 + #include <asm/svm.h> 27 + #include <asm/vmx.h> 28 + #include <asm/kvm.h> 28 29 29 30 struct event_key { 30 31 #define INVALID_KEY (~0ULL) ··· 59 58 }; 60 59 61 60 62 - struct perf_kvm; 61 + struct perf_kvm_stat; 63 62 64 63 struct kvm_events_ops { 65 64 bool (*is_begin_event)(struct perf_evsel *evsel, ··· 67 66 struct event_key *key); 68 67 bool (*is_end_event)(struct perf_evsel *evsel, 69 68 struct perf_sample *sample, struct event_key *key); 70 - void (*decode_key)(struct perf_kvm *kvm, struct event_key *key, 69 + void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key, 71 70 char decode[20]); 72 71 const char *name; 73 72 }; ··· 80 79 #define EVENTS_BITS 12 81 80 #define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS) 82 81 83 - struct perf_kvm { 82 + struct perf_kvm_stat { 84 83 struct perf_tool tool; 85 84 struct perf_session *session; 86 85 ··· 147 146 SVM_EXIT_REASONS 148 147 }; 149 148 150 - static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code) 149 + static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code) 151 150 { 152 151 int i = kvm->exit_reasons_size; 153 152 struct exit_reasons_table *tbl = kvm->exit_reasons; ··· 163 162 return "UNKNOWN"; 164 163 } 165 164 166 - static void exit_event_decode_key(struct perf_kvm *kvm, 165 + static void exit_event_decode_key(struct perf_kvm_stat *kvm, 167 166 struct event_key *key, 168 167 char decode[20]) 169 168 { ··· 229 228 return false; 230 229 } 231 230 232 - static void mmio_event_decode_key(struct perf_kvm *kvm __maybe_unused, 231 + static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, 233 232 struct event_key *key, 234 233 char decode[20]) 235 234 { ··· 272 271 return kvm_entry_event(evsel); 273 272 } 274 273 275 - static void ioport_event_decode_key(struct perf_kvm *kvm __maybe_unused, 274 + static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, 276 275 struct event_key *key, 277 276 char decode[20]) 278 277 { ··· 287 286 .name = "IO Port Access" 288 287 }; 289 288 290 - static bool register_kvm_events_ops(struct perf_kvm *kvm) 289 + static bool register_kvm_events_ops(struct perf_kvm_stat *kvm) 291 290 { 292 291 bool ret = true; 293 292 ··· 312 311 }; 313 312 314 313 315 - static void init_kvm_event_record(struct perf_kvm *kvm) 314 + static void init_kvm_event_record(struct perf_kvm_stat *kvm) 316 315 { 317 316 int i; 318 317 ··· 361 360 return event; 362 361 } 363 362 364 - static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm, 363 + static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm, 365 364 struct event_key *key) 366 365 { 367 366 struct kvm_event *event; ··· 382 381 return event; 383 382 } 384 383 385 - static bool handle_begin_event(struct perf_kvm *kvm, 384 + static bool handle_begin_event(struct perf_kvm_stat *kvm, 386 385 struct vcpu_event_record *vcpu_record, 387 386 struct event_key *key, u64 timestamp) 388 387 { ··· 426 425 return true; 427 426 } 428 427 429 - static bool handle_end_event(struct perf_kvm *kvm, 428 + static bool handle_end_event(struct perf_kvm_stat *kvm, 430 429 struct vcpu_event_record *vcpu_record, 431 430 struct event_key *key, 432 431 u64 timestamp) ··· 487 486 return thread->priv; 488 487 } 489 488 490 - static bool handle_kvm_event(struct perf_kvm *kvm, 489 + static bool handle_kvm_event(struct perf_kvm_stat *kvm, 491 490 struct thread *thread, 492 491 struct perf_evsel *evsel, 493 492 struct perf_sample *sample) ··· 542 541 { NULL, NULL } 543 542 }; 544 543 545 - static bool select_key(struct perf_kvm *kvm) 544 + static bool select_key(struct perf_kvm_stat *kvm) 546 545 { 547 546 int i; 548 547 ··· 578 577 rb_insert_color(&event->rb, result); 579 578 } 580 579 581 - static void update_total_count(struct perf_kvm *kvm, struct kvm_event *event) 580 + static void 581 + update_total_count(struct perf_kvm_stat *kvm, struct kvm_event *event) 582 582 { 583 583 int vcpu = kvm->trace_vcpu; 584 584 ··· 592 590 return !!get_event_count(event, vcpu); 593 591 } 594 592 595 - static void sort_result(struct perf_kvm *kvm) 593 + static void sort_result(struct perf_kvm_stat *kvm) 596 594 { 597 595 unsigned int i; 598 596 int vcpu = kvm->trace_vcpu; ··· 629 627 pr_info("VCPU %d:\n\n", vcpu); 630 628 } 631 629 632 - static void print_result(struct perf_kvm *kvm) 630 + static void print_result(struct perf_kvm_stat *kvm) 633 631 { 634 632 char decode[20]; 635 633 struct kvm_event *event; ··· 672 670 struct machine *machine) 673 671 { 674 672 struct thread *thread = machine__findnew_thread(machine, sample->tid); 675 - struct perf_kvm *kvm = container_of(tool, struct perf_kvm, tool); 673 + struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat, 674 + tool); 676 675 677 676 if (thread == NULL) { 678 677 pr_debug("problem processing %d event, skipping it.\n", ··· 704 701 return isa; 705 702 } 706 703 707 - static int read_events(struct perf_kvm *kvm) 704 + static int read_events(struct perf_kvm_stat *kvm) 708 705 { 709 706 int ret; 710 707 ··· 753 750 return true; 754 751 } 755 752 756 - static int kvm_events_report_vcpu(struct perf_kvm *kvm) 753 + static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm) 757 754 { 758 755 int ret = -EINVAL; 759 756 int vcpu = kvm->trace_vcpu; ··· 801 798 _p; \ 802 799 }) 803 800 804 - static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv) 801 + static int 802 + kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv) 805 803 { 806 804 unsigned int rec_argc, i, j; 807 805 const char **rec_argv; ··· 825 821 return cmd_record(i, rec_argv, NULL); 826 822 } 827 823 828 - static int kvm_events_report(struct perf_kvm *kvm, int argc, const char **argv) 824 + static int 825 + kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv) 829 826 { 830 827 const struct option kvm_events_report_options[] = { 831 828 OPT_STRING(0, "event", &kvm->report_event, "report event", ··· 869 864 printf("\nOtherwise, it is the alias of 'perf stat':\n"); 870 865 } 871 866 872 - static int kvm_cmd_stat(struct perf_kvm *kvm, int argc, const char **argv) 867 + static int kvm_cmd_stat(const char *file_name, int argc, const char **argv) 873 868 { 869 + struct perf_kvm_stat kvm = { 870 + .file_name = file_name, 871 + 872 + .trace_vcpu = -1, 873 + .report_event = "vmexit", 874 + .sort_key = "sample", 875 + 876 + .exit_reasons = svm_exit_reasons, 877 + .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons), 878 + .exit_reasons_isa = "SVM", 879 + }; 880 + 874 881 if (argc == 1) { 875 882 print_kvm_stat_usage(); 876 883 goto perf_stat; 877 884 } 878 885 879 886 if (!strncmp(argv[1], "rec", 3)) 880 - return kvm_events_record(kvm, argc - 1, argv + 1); 887 + return kvm_events_record(&kvm, argc - 1, argv + 1); 881 888 882 889 if (!strncmp(argv[1], "rep", 3)) 883 - return kvm_events_report(kvm, argc - 1 , argv + 1); 890 + return kvm_events_report(&kvm, argc - 1 , argv + 1); 884 891 885 892 perf_stat: 886 893 return cmd_stat(argc, argv, NULL); 887 894 } 895 + #endif 888 896 889 - static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv) 897 + static int __cmd_record(const char *file_name, int argc, const char **argv) 890 898 { 891 899 int rec_argc, i = 0, j; 892 900 const char **rec_argv; ··· 908 890 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 909 891 rec_argv[i++] = strdup("record"); 910 892 rec_argv[i++] = strdup("-o"); 911 - rec_argv[i++] = strdup(kvm->file_name); 893 + rec_argv[i++] = strdup(file_name); 912 894 for (j = 1; j < argc; j++, i++) 913 895 rec_argv[i] = argv[j]; 914 896 ··· 917 899 return cmd_record(i, rec_argv, NULL); 918 900 } 919 901 920 - static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv) 902 + static int __cmd_report(const char *file_name, int argc, const char **argv) 921 903 { 922 904 int rec_argc, i = 0, j; 923 905 const char **rec_argv; ··· 926 908 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 927 909 rec_argv[i++] = strdup("report"); 928 910 rec_argv[i++] = strdup("-i"); 929 - rec_argv[i++] = strdup(kvm->file_name); 911 + rec_argv[i++] = strdup(file_name); 930 912 for (j = 1; j < argc; j++, i++) 931 913 rec_argv[i] = argv[j]; 932 914 ··· 935 917 return cmd_report(i, rec_argv, NULL); 936 918 } 937 919 938 - static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv) 920 + static int 921 + __cmd_buildid_list(const char *file_name, int argc, const char **argv) 939 922 { 940 923 int rec_argc, i = 0, j; 941 924 const char **rec_argv; ··· 945 926 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 946 927 rec_argv[i++] = strdup("buildid-list"); 947 928 rec_argv[i++] = strdup("-i"); 948 - rec_argv[i++] = strdup(kvm->file_name); 929 + rec_argv[i++] = strdup(file_name); 949 930 for (j = 1; j < argc; j++, i++) 950 931 rec_argv[i] = argv[j]; 951 932 ··· 956 937 957 938 int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) 958 939 { 959 - struct perf_kvm kvm = { 960 - .trace_vcpu = -1, 961 - .report_event = "vmexit", 962 - .sort_key = "sample", 963 - 964 - .exit_reasons = svm_exit_reasons, 965 - .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons), 966 - .exit_reasons_isa = "SVM", 967 - }; 940 + const char *file_name; 968 941 969 942 const struct option kvm_options[] = { 970 - OPT_STRING('i', "input", &kvm.file_name, "file", 943 + OPT_STRING('i', "input", &file_name, "file", 971 944 "Input file name"), 972 - OPT_STRING('o', "output", &kvm.file_name, "file", 945 + OPT_STRING('o', "output", &file_name, "file", 973 946 "Output file name"), 974 947 OPT_BOOLEAN(0, "guest", &perf_guest, 975 948 "Collect guest os data"), ··· 996 985 if (!perf_host) 997 986 perf_guest = 1; 998 987 999 - if (!kvm.file_name) { 988 + if (!file_name) { 1000 989 if (perf_host && !perf_guest) 1001 - kvm.file_name = strdup("perf.data.host"); 990 + file_name = strdup("perf.data.host"); 1002 991 else if (!perf_host && perf_guest) 1003 - kvm.file_name = strdup("perf.data.guest"); 992 + file_name = strdup("perf.data.guest"); 1004 993 else 1005 - kvm.file_name = strdup("perf.data.kvm"); 994 + file_name = strdup("perf.data.kvm"); 1006 995 1007 - if (!kvm.file_name) { 996 + if (!file_name) { 1008 997 pr_err("Failed to allocate memory for filename\n"); 1009 998 return -ENOMEM; 1010 999 } 1011 1000 } 1012 1001 1013 1002 if (!strncmp(argv[0], "rec", 3)) 1014 - return __cmd_record(&kvm, argc, argv); 1003 + return __cmd_record(file_name, argc, argv); 1015 1004 else if (!strncmp(argv[0], "rep", 3)) 1016 - return __cmd_report(&kvm, argc, argv); 1005 + return __cmd_report(file_name, argc, argv); 1017 1006 else if (!strncmp(argv[0], "diff", 4)) 1018 1007 return cmd_diff(argc, argv, NULL); 1019 1008 else if (!strncmp(argv[0], "top", 3)) 1020 1009 return cmd_top(argc, argv, NULL); 1021 1010 else if (!strncmp(argv[0], "buildid-list", 12)) 1022 - return __cmd_buildid_list(&kvm, argc, argv); 1011 + return __cmd_buildid_list(file_name, argc, argv); 1012 + #if defined(__i386__) || defined(__x86_64__) 1023 1013 else if (!strncmp(argv[0], "stat", 4)) 1024 - return kvm_cmd_stat(&kvm, argc, argv); 1014 + return kvm_cmd_stat(file_name, argc, argv); 1015 + #endif 1025 1016 else 1026 1017 usage_with_options(kvm_usage, kvm_options); 1027 1018
+1 -1
tools/perf/builtin-test.c
··· 15 15 #include "util/thread_map.h" 16 16 #include "util/pmu.h" 17 17 #include "event-parse.h" 18 - #include "../../include/linux/hw_breakpoint.h" 18 + #include <linux/hw_breakpoint.h> 19 19 20 20 #include <sys/mman.h> 21 21
+3 -13
tools/perf/perf.h
··· 5 5 6 6 void get_term_dimensions(struct winsize *ws); 7 7 8 + #include <asm/unistd.h> 9 + 8 10 #if defined(__i386__) 9 - #include "../../arch/x86/include/asm/unistd.h" 10 11 #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 11 12 #define cpu_relax() asm volatile("rep; nop" ::: "memory"); 12 13 #define CPUINFO_PROC "model name" ··· 17 16 #endif 18 17 19 18 #if defined(__x86_64__) 20 - #include "../../arch/x86/include/asm/unistd.h" 21 19 #define rmb() asm volatile("lfence" ::: "memory") 22 20 #define cpu_relax() asm volatile("rep; nop" ::: "memory"); 23 21 #define CPUINFO_PROC "model name" ··· 26 26 #endif 27 27 28 28 #ifdef __powerpc__ 29 - #include "../../arch/powerpc/include/asm/unistd.h" 30 29 #define rmb() asm volatile ("sync" ::: "memory") 31 30 #define cpu_relax() asm volatile ("" ::: "memory"); 32 31 #define CPUINFO_PROC "cpu" 33 32 #endif 34 33 35 34 #ifdef __s390__ 36 - #include "../../arch/s390/include/asm/unistd.h" 37 35 #define rmb() asm volatile("bcr 15,0" ::: "memory") 38 36 #define cpu_relax() asm volatile("" ::: "memory"); 39 37 #endif 40 38 41 39 #ifdef __sh__ 42 - #include "../../arch/sh/include/asm/unistd.h" 43 40 #if defined(__SH4A__) || defined(__SH5__) 44 41 # define rmb() asm volatile("synco" ::: "memory") 45 42 #else ··· 47 50 #endif 48 51 49 52 #ifdef __hppa__ 50 - #include "../../arch/parisc/include/asm/unistd.h" 51 53 #define rmb() asm volatile("" ::: "memory") 52 54 #define cpu_relax() asm volatile("" ::: "memory"); 53 55 #define CPUINFO_PROC "cpu" 54 56 #endif 55 57 56 58 #ifdef __sparc__ 57 - #include "../../arch/sparc/include/uapi/asm/unistd.h" 58 59 #define rmb() asm volatile("":::"memory") 59 60 #define cpu_relax() asm volatile("":::"memory") 60 61 #define CPUINFO_PROC "cpu" 61 62 #endif 62 63 63 64 #ifdef __alpha__ 64 - #include "../../arch/alpha/include/asm/unistd.h" 65 65 #define rmb() asm volatile("mb" ::: "memory") 66 66 #define cpu_relax() asm volatile("" ::: "memory") 67 67 #define CPUINFO_PROC "cpu model" 68 68 #endif 69 69 70 70 #ifdef __ia64__ 71 - #include "../../arch/ia64/include/asm/unistd.h" 72 71 #define rmb() asm volatile ("mf" ::: "memory") 73 72 #define cpu_relax() asm volatile ("hint @pause" ::: "memory") 74 73 #define CPUINFO_PROC "model name" 75 74 #endif 76 75 77 76 #ifdef __arm__ 78 - #include "../../arch/arm/include/asm/unistd.h" 79 77 /* 80 78 * Use the __kuser_memory_barrier helper in the CPU helper page. See 81 79 * arch/arm/kernel/entry-armv.S in the kernel source for details. ··· 81 89 #endif 82 90 83 91 #ifdef __aarch64__ 84 - #include "../../arch/arm64/include/asm/unistd.h" 85 92 #define rmb() asm volatile("dmb ld" ::: "memory") 86 93 #define cpu_relax() asm volatile("yield" ::: "memory") 87 94 #endif 88 95 89 96 #ifdef __mips__ 90 - #include "../../arch/mips/include/asm/unistd.h" 91 97 #define rmb() asm volatile( \ 92 98 ".set mips2\n\t" \ 93 99 "sync\n\t" \ ··· 102 112 #include <sys/types.h> 103 113 #include <sys/syscall.h> 104 114 105 - #include "../../include/uapi/linux/perf_event.h" 115 + #include <linux/perf_event.h> 106 116 #include "util/types.h" 107 117 #include <stdbool.h> 108 118
+2 -2
tools/perf/util/evsel.c
··· 18 18 #include "cpumap.h" 19 19 #include "thread_map.h" 20 20 #include "target.h" 21 - #include "../../../include/linux/hw_breakpoint.h" 22 - #include "../../../include/uapi/linux/perf_event.h" 21 + #include <linux/hw_breakpoint.h> 22 + #include <linux/perf_event.h> 23 23 #include "perf_regs.h" 24 24 25 25 #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
+2 -1
tools/perf/util/evsel.h
··· 3 3 4 4 #include <linux/list.h> 5 5 #include <stdbool.h> 6 - #include "../../../include/uapi/linux/perf_event.h" 6 + #include <stddef.h> 7 + #include <linux/perf_event.h> 7 8 #include "types.h" 8 9 #include "xyarray.h" 9 10 #include "cgroup.h"
+2
tools/perf/util/header.c
··· 1378 1378 1379 1379 str = tmp + 1; 1380 1380 fprintf(fp, "# node%u cpu list : %s\n", c, str); 1381 + 1382 + str += strlen(str) + 1; 1381 1383 } 1382 1384 return; 1383 1385 error:
+1 -1
tools/perf/util/header.h
··· 1 1 #ifndef __PERF_HEADER_H 2 2 #define __PERF_HEADER_H 3 3 4 - #include "../../../include/uapi/linux/perf_event.h" 4 + #include <linux/perf_event.h> 5 5 #include <sys/types.h> 6 6 #include <stdbool.h> 7 7 #include "types.h"
+1 -1
tools/perf/util/parse-events-test.c
··· 3 3 #include "evsel.h" 4 4 #include "evlist.h" 5 5 #include "sysfs.h" 6 - #include "../../../include/linux/hw_breakpoint.h" 6 + #include <linux/hw_breakpoint.h> 7 7 8 8 #define TEST_ASSERT_VAL(text, cond) \ 9 9 do { \
+1 -1
tools/perf/util/parse-events.c
··· 1 - #include "../../../include/linux/hw_breakpoint.h" 1 + #include <linux/hw_breakpoint.h> 2 2 #include "util.h" 3 3 #include "../perf.h" 4 4 #include "evlist.h"
+1 -1
tools/perf/util/parse-events.h
··· 7 7 #include <linux/list.h> 8 8 #include <stdbool.h> 9 9 #include "types.h" 10 - #include "../../../include/uapi/linux/perf_event.h" 10 + #include <linux/perf_event.h> 11 11 #include "types.h" 12 12 13 13 struct list_head;
+1 -1
tools/perf/util/pmu.h
··· 2 2 #define __PMU_H 3 3 4 4 #include <linux/bitops.h> 5 - #include "../../../include/uapi/linux/perf_event.h" 5 + #include <linux/perf_event.h> 6 6 7 7 enum { 8 8 PERF_PMU_FORMAT_VALUE_CONFIG,
+1 -1
tools/perf/util/session.h
··· 7 7 #include "symbol.h" 8 8 #include "thread.h" 9 9 #include <linux/rbtree.h> 10 - #include "../../../include/uapi/linux/perf_event.h" 10 + #include <linux/perf_event.h> 11 11 12 12 struct sample_queue; 13 13 struct ip_callchain;
+4 -4
tools/perf/util/strbuf.c
··· 90 90 if (!strbuf_avail(sb)) 91 91 strbuf_grow(sb, 64); 92 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 94 va_end(ap); 95 95 if (len < 0) 96 - die("your vscnprintf is broken"); 96 + die("your vsnprintf is broken"); 97 97 if (len > strbuf_avail(sb)) { 98 98 strbuf_grow(sb, len); 99 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 101 va_end(ap); 102 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 106 strbuf_setlen(sb, sb->len + len);
+20 -3
tools/scripts/Makefile.include
··· 1 - ifeq ("$(origin O)", "command line") 1 + ifeq ($(origin O), command line) 2 2 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) 3 3 ABSOLUTE_O := $(shell cd $(O) ; pwd) 4 - OUTPUT := $(ABSOLUTE_O)/ 4 + OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/) 5 5 COMMAND_O := O=$(ABSOLUTE_O) 6 + ifeq ($(objtree),) 7 + objtree := $(O) 8 + endif 6 9 endif 7 10 8 11 ifneq ($(OUTPUT),) ··· 44 41 NO_SUBDIR = : 45 42 endif 46 43 47 - QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 44 + # 45 + # Define a callable command for descending to a new directory 46 + # 47 + # Call by doing: $(call descend,directory[,target]) 48 + # 49 + descend = \ 50 + +mkdir -p $(OUTPUT)$(1) && \ 51 + $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2) 52 + 53 + QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir 48 54 QUIET_SUBDIR1 = 49 55 50 56 ifneq ($(findstring $(MAKEFLAGS),s),s) ··· 68 56 $(MAKE) $(PRINT_DIR) -C $$subdir 69 57 QUIET_FLEX = @echo ' ' FLEX $@; 70 58 QUIET_BISON = @echo ' ' BISON $@; 59 + 60 + descend = \ 61 + @echo ' ' DESCEND $(1); \ 62 + mkdir -p $(OUTPUT)$(1) && \ 63 + $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2) 71 64 endif 72 65 endif