Commit 531c221d authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-urgent-for-mingo-4.12-20170616' of...

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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 63f700aa 9126cbba
...@@ -19,18 +19,18 @@ CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) ...@@ -19,18 +19,18 @@ CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
include $(srctree)/tools/scripts/Makefile.arch include $(srctree)/tools/scripts/Makefile.arch
$(call detected_var,ARCH) $(call detected_var,SRCARCH)
NO_PERF_REGS := 1 NO_PERF_REGS := 1
# Additional ARCH settings for ppc # Additional ARCH settings for ppc
ifeq ($(ARCH),powerpc) ifeq ($(SRCARCH),powerpc)
NO_PERF_REGS := 0 NO_PERF_REGS := 0
LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
endif endif
# Additional ARCH settings for x86 # Additional ARCH settings for x86
ifeq ($(ARCH),x86) ifeq ($(SRCARCH),x86)
$(call detected,CONFIG_X86) $(call detected,CONFIG_X86)
ifeq (${IS_64_BIT}, 1) ifeq (${IS_64_BIT}, 1)
CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE -I$(OUTPUT)arch/x86/include/generated
...@@ -43,12 +43,12 @@ ifeq ($(ARCH),x86) ...@@ -43,12 +43,12 @@ ifeq ($(ARCH),x86)
NO_PERF_REGS := 0 NO_PERF_REGS := 0
endif endif
ifeq ($(ARCH),arm) ifeq ($(SRCARCH),arm)
NO_PERF_REGS := 0 NO_PERF_REGS := 0
LIBUNWIND_LIBS = -lunwind -lunwind-arm LIBUNWIND_LIBS = -lunwind -lunwind-arm
endif endif
ifeq ($(ARCH),arm64) ifeq ($(SRCARCH),arm64)
NO_PERF_REGS := 0 NO_PERF_REGS := 0
LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
endif endif
...@@ -61,7 +61,7 @@ endif ...@@ -61,7 +61,7 @@ endif
# Disable it on all other architectures in case libdw unwind # Disable it on all other architectures in case libdw unwind
# support is detected in system. Add supported architectures # support is detected in system. Add supported architectures
# to the check. # to the check.
ifneq ($(ARCH),$(filter $(ARCH),x86 arm)) ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm))
NO_LIBDW_DWARF_UNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1
endif endif
...@@ -115,9 +115,9 @@ endif ...@@ -115,9 +115,9 @@ endif
FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
# include ARCH specific config # include ARCH specific config
-include $(src-perf)/arch/$(ARCH)/Makefile -include $(src-perf)/arch/$(SRCARCH)/Makefile
ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
...@@ -228,12 +228,12 @@ ifeq ($(DEBUG),0) ...@@ -228,12 +228,12 @@ ifeq ($(DEBUG),0)
endif endif
INC_FLAGS += -I$(src-perf)/util/include INC_FLAGS += -I$(src-perf)/util/include
INC_FLAGS += -I$(src-perf)/arch/$(ARCH)/include INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
INC_FLAGS += -I$(srctree)/tools/include/uapi INC_FLAGS += -I$(srctree)/tools/include/uapi
INC_FLAGS += -I$(srctree)/tools/include/ INC_FLAGS += -I$(srctree)/tools/include/
INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
INC_FLAGS += -I$(srctree)/tools/arch/$(ARCH)/ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
# $(obj-perf) for generated common-cmds.h # $(obj-perf) for generated common-cmds.h
# $(obj-perf)/util for generated bison/flex headers # $(obj-perf)/util for generated bison/flex headers
...@@ -355,7 +355,7 @@ ifndef NO_LIBELF ...@@ -355,7 +355,7 @@ ifndef NO_LIBELF
ifndef NO_DWARF ifndef NO_DWARF
ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); msg := $(warning DWARF register mappings have not been defined for architecture $(SRCARCH), DWARF support disabled);
NO_DWARF := 1 NO_DWARF := 1
else else
CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS) CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
...@@ -380,7 +380,7 @@ ifndef NO_LIBELF ...@@ -380,7 +380,7 @@ ifndef NO_LIBELF
CFLAGS += -DHAVE_BPF_PROLOGUE CFLAGS += -DHAVE_BPF_PROLOGUE
$(call detected,CONFIG_BPF_PROLOGUE) $(call detected,CONFIG_BPF_PROLOGUE)
else else
msg := $(warning BPF prologue is not supported by architecture $(ARCH), missing regs_query_register_offset()); msg := $(warning BPF prologue is not supported by architecture $(SRCARCH), missing regs_query_register_offset());
endif endif
else else
msg := $(warning DWARF support is off, BPF prologue is disabled); msg := $(warning DWARF support is off, BPF prologue is disabled);
...@@ -406,7 +406,7 @@ ifdef PERF_HAVE_JITDUMP ...@@ -406,7 +406,7 @@ ifdef PERF_HAVE_JITDUMP
endif endif
endif endif
ifeq ($(ARCH),powerpc) ifeq ($(SRCARCH),powerpc)
ifndef NO_DWARF ifndef NO_DWARF
CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
endif endif
...@@ -487,7 +487,7 @@ else ...@@ -487,7 +487,7 @@ else
endif endif
ifndef NO_LOCAL_LIBUNWIND ifndef NO_LOCAL_LIBUNWIND
ifeq ($(ARCH),$(filter $(ARCH),arm arm64)) ifeq ($(SRCARCH),$(filter $(SRCARCH),arm arm64))
$(call feature_check,libunwind-debug-frame) $(call feature_check,libunwind-debug-frame)
ifneq ($(feature-libunwind-debug-frame), 1) ifneq ($(feature-libunwind-debug-frame), 1)
msg := $(warning No debug_frame support found in libunwind); msg := $(warning No debug_frame support found in libunwind);
...@@ -740,7 +740,7 @@ ifeq (${IS_64_BIT}, 1) ...@@ -740,7 +740,7 @@ ifeq (${IS_64_BIT}, 1)
NO_PERF_READ_VDSO32 := 1 NO_PERF_READ_VDSO32 := 1
endif endif
endif endif
ifneq ($(ARCH), x86) ifneq ($(SRCARCH), x86)
NO_PERF_READ_VDSOX32 := 1 NO_PERF_READ_VDSOX32 := 1
endif endif
ifndef NO_PERF_READ_VDSOX32 ifndef NO_PERF_READ_VDSOX32
...@@ -769,7 +769,7 @@ ifdef LIBBABELTRACE ...@@ -769,7 +769,7 @@ ifdef LIBBABELTRACE
endif endif
ifndef NO_AUXTRACE ifndef NO_AUXTRACE
ifeq ($(ARCH),x86) ifeq ($(SRCARCH),x86)
ifeq ($(feature-get_cpuid), 0) ifeq ($(feature-get_cpuid), 0)
msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
NO_AUXTRACE := 1 NO_AUXTRACE := 1
...@@ -872,7 +872,7 @@ sysconfdir = $(prefix)/etc ...@@ -872,7 +872,7 @@ sysconfdir = $(prefix)/etc
ETC_PERFCONFIG = etc/perfconfig ETC_PERFCONFIG = etc/perfconfig
endif endif
ifndef lib ifndef lib
ifeq ($(ARCH)$(IS_64_BIT), x861) ifeq ($(SRCARCH)$(IS_64_BIT), x861)
lib = lib64 lib = lib64
else else
lib = lib lib = lib
......
...@@ -226,7 +226,7 @@ endif ...@@ -226,7 +226,7 @@ endif
ifeq ($(config),0) ifeq ($(config),0)
include $(srctree)/tools/scripts/Makefile.arch include $(srctree)/tools/scripts/Makefile.arch
-include arch/$(ARCH)/Makefile -include arch/$(SRCARCH)/Makefile
endif endif
# The FEATURE_DUMP_EXPORT holds location of the actual # The FEATURE_DUMP_EXPORT holds location of the actual
......
libperf-y += common.o libperf-y += common.o
libperf-y += $(ARCH)/ libperf-y += $(SRCARCH)/
...@@ -2,7 +2,7 @@ hostprogs := jevents ...@@ -2,7 +2,7 @@ hostprogs := jevents
jevents-y += json.o jsmn.o jevents.o jevents-y += json.o jsmn.o jevents.o
pmu-events-y += pmu-events.o pmu-events-y += pmu-events.o
JDIR = pmu-events/arch/$(ARCH) JDIR = pmu-events/arch/$(SRCARCH)
JSON = $(shell [ -d $(JDIR) ] && \ JSON = $(shell [ -d $(JDIR) ] && \
find $(JDIR) -name '*.json' -o -name 'mapfile.csv') find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
# #
...@@ -10,4 +10,4 @@ JSON = $(shell [ -d $(JDIR) ] && \ ...@@ -10,4 +10,4 @@ JSON = $(shell [ -d $(JDIR) ] && \
# directory and create tables in pmu-events.c. # directory and create tables in pmu-events.c.
# #
$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS) $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
$(Q)$(call echo-cmd,gen)$(JEVENTS) $(ARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V) $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
...@@ -75,7 +75,7 @@ $(OUTPUT)tests/llvm-src-relocation.c: tests/bpf-script-test-relocation.c tests/B ...@@ -75,7 +75,7 @@ $(OUTPUT)tests/llvm-src-relocation.c: tests/bpf-script-test-relocation.c tests/B
$(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@ $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@
$(Q)echo ';' >> $@ $(Q)echo ';' >> $@
ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64 powerpc)) ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc))
perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
endif endif
......
...@@ -83,7 +83,7 @@ int test__task_exit(int subtest __maybe_unused) ...@@ -83,7 +83,7 @@ int test__task_exit(int subtest __maybe_unused)
evsel = perf_evlist__first(evlist); evsel = perf_evlist__first(evlist);
evsel->attr.task = 1; evsel->attr.task = 1;
evsel->attr.sample_freq = 0; evsel->attr.sample_freq = 1;
evsel->attr.inherit = 0; evsel->attr.inherit = 0;
evsel->attr.watermark = 0; evsel->attr.watermark = 0;
evsel->attr.wakeup_events = 1; evsel->attr.wakeup_events = 1;
......
...@@ -273,8 +273,20 @@ struct perf_evsel *perf_evsel__new_cycles(void) ...@@ -273,8 +273,20 @@ struct perf_evsel *perf_evsel__new_cycles(void)
struct perf_evsel *evsel; struct perf_evsel *evsel;
event_attr_init(&attr); event_attr_init(&attr);
/*
* Unnamed union member, not supported as struct member named
* initializer in older compilers such as gcc 4.4.7
*
* Just for probing the precise_ip:
*/
attr.sample_period = 1;
perf_event_attr__set_max_precise_ip(&attr); perf_event_attr__set_max_precise_ip(&attr);
/*
* Now let the usual logic to set up the perf_event_attr defaults
* to kick in when we return and before perf_evsel__open() is called.
*/
attr.sample_period = 0;
evsel = perf_evsel__new(&attr); evsel = perf_evsel__new(&attr);
if (evsel == NULL) if (evsel == NULL)
......
...@@ -841,7 +841,7 @@ static int write_group_desc(int fd, struct perf_header *h __maybe_unused, ...@@ -841,7 +841,7 @@ static int write_group_desc(int fd, struct perf_header *h __maybe_unused,
/* /*
* default get_cpuid(): nothing gets recorded * default get_cpuid(): nothing gets recorded
* actual implementation must be in arch/$(ARCH)/util/header.c * actual implementation must be in arch/$(SRCARCH)/util/header.c
*/ */
int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused) int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused)
{ {
......
...@@ -178,6 +178,14 @@ frame_callback(Dwfl_Frame *state, void *arg) ...@@ -178,6 +178,14 @@ frame_callback(Dwfl_Frame *state, void *arg)
Dwarf_Addr pc; Dwarf_Addr pc;
bool isactivation; bool isactivation;
if (!dwfl_frame_pc(state, &pc, NULL)) {
pr_err("%s", dwfl_errmsg(-1));
return DWARF_CB_ABORT;
}
// report the module before we query for isactivation
report_module(pc, ui);
if (!dwfl_frame_pc(state, &pc, &isactivation)) { if (!dwfl_frame_pc(state, &pc, &isactivation)) {
pr_err("%s", dwfl_errmsg(-1)); pr_err("%s", dwfl_errmsg(-1));
return DWARF_CB_ABORT; return DWARF_CB_ABORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment