Merge tag 'perf-urgent-for-mingo-4.12-20170616' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

- Fix probing of precise_ip level for default cycles event, that
got broken recently on x86_64 when its arch code started
considering invalid requesting precise samples when not sampling
(i.e. when attr.sample_period == 0).

This also fixes another problem in s/390 where the precision
probing with sample_period == 0 returned precise_ip > 0, that
then, when setting up the real cycles event (not probing) would
return EOPNOTSUPP for precise_ip > 0 (as determined previously
by probing) and sample_period > 0.

These problems resulted in attr_precise not being set to the
highest precision available on x86.64 when no event was specified,
i.e. the canonical:

perf record ./workload

would end up using attr.precise_ip = 0. As a workaround this would
need to be done:

perf record -e cycles:P ./workload

And on s/390 it would plain not work, requiring using:

perf record -e cycles ./workload

as a workaround. (Arnaldo Carvalho de Melo)

- Fix perf build with ARCH=x86_64, when ARCH should be transformed
into ARCH=x86, just like with the main kernel Makefile and
tools/objtool's, i.e. use SRCARCH. (Jiada Wang)

- Avoid accessing uninitialized data structures when unwinding with
elfutils's libdw, making it more closely mimic libunwind's unwinder.
(Milian Wolff)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+46 -26
+19 -19
tools/perf/Makefile.config
··· 19 19 20 20 include $(srctree)/tools/scripts/Makefile.arch 21 21 22 - $(call detected_var,ARCH) 22 + $(call detected_var,SRCARCH) 23 23 24 24 NO_PERF_REGS := 1 25 25 26 26 # Additional ARCH settings for ppc 27 - ifeq ($(ARCH),powerpc) 27 + ifeq ($(SRCARCH),powerpc) 28 28 NO_PERF_REGS := 0 29 29 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 30 30 endif 31 31 32 32 # Additional ARCH settings for x86 33 - ifeq ($(ARCH),x86) 33 + ifeq ($(SRCARCH),x86) 34 34 $(call detected,CONFIG_X86) 35 35 ifeq (${IS_64_BIT}, 1) 36 36 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated ··· 43 43 NO_PERF_REGS := 0 44 44 endif 45 45 46 - ifeq ($(ARCH),arm) 46 + ifeq ($(SRCARCH),arm) 47 47 NO_PERF_REGS := 0 48 48 LIBUNWIND_LIBS = -lunwind -lunwind-arm 49 49 endif 50 50 51 - ifeq ($(ARCH),arm64) 51 + ifeq ($(SRCARCH),arm64) 52 52 NO_PERF_REGS := 0 53 53 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 54 54 endif ··· 61 61 # Disable it on all other architectures in case libdw unwind 62 62 # support is detected in system. Add supported architectures 63 63 # to the check. 64 - ifneq ($(ARCH),$(filter $(ARCH),x86 arm)) 64 + ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm)) 65 65 NO_LIBDW_DWARF_UNWIND := 1 66 66 endif 67 67 ··· 115 115 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) 116 116 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf 117 117 118 - FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi 118 + FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi 119 119 # include ARCH specific config 120 - -include $(src-perf)/arch/$(ARCH)/Makefile 120 + -include $(src-perf)/arch/$(SRCARCH)/Makefile 121 121 122 122 ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 123 123 CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET ··· 228 228 endif 229 229 230 230 INC_FLAGS += -I$(src-perf)/util/include 231 - INC_FLAGS += -I$(src-perf)/arch/$(ARCH)/include 231 + INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include 232 232 INC_FLAGS += -I$(srctree)/tools/include/uapi 233 233 INC_FLAGS += -I$(srctree)/tools/include/ 234 - INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi 235 - INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/ 236 - INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/ 234 + INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi 235 + INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/ 236 + INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ 237 237 238 238 # $(obj-perf) for generated common-cmds.h 239 239 # $(obj-perf)/util for generated bison/flex headers ··· 355 355 356 356 ifndef NO_DWARF 357 357 ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) 358 - msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); 358 + msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled); 359 359 NO_DWARF := 1 360 360 else 361 361 CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) ··· 380 380 CFLAGS += -DHAVE_BPF_PROLOGUE 381 381 $(call detected,CONFIG_BPF_PROLOGUE) 382 382 else 383 - msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset()); 383 + msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset()); 384 384 endif 385 385 else 386 386 msg := $(warning DWARF support is off, BPF prologue is disabled); ··· 406 406 endif 407 407 endif 408 408 409 - ifeq ($(ARCH),powerpc) 409 + ifeq ($(SRCARCH),powerpc) 410 410 ifndef NO_DWARF 411 411 CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX 412 412 endif ··· 487 487 endif 488 488 489 489 ifndef NO_LOCAL_LIBUNWIND 490 - ifeq ($(ARCH),$(filter $(ARCH),arm arm64)) 490 + ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64)) 491 491 $(call feature_check,libunwind-debug-frame) 492 492 ifneq ($(feature-libunwind-debug-frame), 1) 493 493 msg := $(warning No debug_frame support found in libunwind); ··· 740 740 NO_PERF_READ_VDSO32 := 1 741 741 endif 742 742 endif 743 - ifneq ($(ARCH), x86) 743 + ifneq ($(SRCARCH), x86) 744 744 NO_PERF_READ_VDSOX32 := 1 745 745 endif 746 746 ifndef NO_PERF_READ_VDSOX32 ··· 769 769 endif 770 770 771 771 ifndef NO_AUXTRACE 772 - ifeq ($(ARCH),x86) 772 + ifeq ($(SRCARCH),x86) 773 773 ifeq ($(feature-get_cpuid), 0) 774 774 msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); 775 775 NO_AUXTRACE := 1 ··· 872 872 ETC_PERFCONFIG = etc/perfconfig 873 873 endif 874 874 ifndef lib 875 - ifeq ($(ARCH)$(IS_64_BIT), x861) 875 + ifeq ($(SRCARCH)$(IS_64_BIT), x861) 876 876 lib = lib64 877 877 else 878 878 lib = lib
+1 -1
tools/perf/Makefile.perf
··· 226 226 227 227 ifeq ($(config),0) 228 228 include $(srctree)/tools/scripts/Makefile.arch 229 - -include arch/$(ARCH)/Makefile 229 + -include arch/$(SRCARCH)/Makefile 230 230 endif 231 231 232 232 # The FEATURE_DUMP_EXPORT holds location of the actual
+1 -1
tools/perf/arch/Build
··· 1 1 libperf-y += common.o 2 - libperf-y += $(ARCH)/ 2 + libperf-y += $(SRCARCH)/
+2 -2
tools/perf/pmu-events/Build
··· 2 2 3 3 jevents-y += json.o jsmn.o jevents.o 4 4 pmu-events-y += pmu-events.o 5 - JDIR = pmu-events/arch/$(ARCH) 5 + JDIR = pmu-events/arch/$(SRCARCH) 6 6 JSON = $(shell [ -d $(JDIR) ] && \ 7 7 find $(JDIR) -name '*.json' -o -name 'mapfile.csv') 8 8 # ··· 10 10 # directory and create tables in pmu-events.c. 11 11 # 12 12 $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS) 13 - $(Q)$(call echo-cmd,gen)$(JEVENTS) $(ARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V) 13 + $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
+1 -1
tools/perf/tests/Build
··· 75 75 $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@ 76 76 $(Q)echo ';' >> $@ 77 77 78 - ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64 powerpc)) 78 + ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc)) 79 79 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o 80 80 endif 81 81
+1 -1
tools/perf/tests/task-exit.c
··· 83 83 84 84 evsel = perf_evlist__first(evlist); 85 85 evsel->attr.task = 1; 86 - evsel->attr.sample_freq = 0; 86 + evsel->attr.sample_freq = 1; 87 87 evsel->attr.inherit = 0; 88 88 evsel->attr.watermark = 0; 89 89 evsel->attr.wakeup_events = 1;
+12
tools/perf/util/evsel.c
··· 273 273 struct perf_evsel *evsel; 274 274 275 275 event_attr_init(&attr); 276 + /* 277 + * Unnamed union member, not supported as struct member named 278 + * initializer in older compilers such as gcc 4.4.7 279 + * 280 + * Just for probing the precise_ip: 281 + */ 282 + attr.sample_period = 1; 276 283 277 284 perf_event_attr__set_max_precise_ip(&attr); 285 + /* 286 + * Now let the usual logic to set up the perf_event_attr defaults 287 + * to kick in when we return and before perf_evsel__open() is called. 288 + */ 289 + attr.sample_period = 0; 278 290 279 291 evsel = perf_evsel__new(&attr); 280 292 if (evsel == NULL)
+1 -1
tools/perf/util/header.c
··· 841 841 842 842 /* 843 843 * default get_cpuid(): nothing gets recorded 844 - * actual implementation must be in arch/$(ARCH)/util/header.c 844 + * actual implementation must be in arch/$(SRCARCH)/util/header.c 845 845 */ 846 846 int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused) 847 847 {
+8
tools/perf/util/unwind-libdw.c
··· 178 178 Dwarf_Addr pc; 179 179 bool isactivation; 180 180 181 + if (!dwfl_frame_pc(state, &pc, NULL)) { 182 + pr_err("%s", dwfl_errmsg(-1)); 183 + return DWARF_CB_ABORT; 184 + } 185 + 186 + // report the module before we query for isactivation 187 + report_module(pc, ui); 188 + 181 189 if (!dwfl_frame_pc(state, &pc, &isactivation)) { 182 190 pr_err("%s", dwfl_errmsg(-1)); 183 191 return DWARF_CB_ABORT;