Commit a6f83f00 authored by Ingo Molnar's avatar Ingo Molnar

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

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

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - When handling perf_event_open() returning EBUSY and not being able to opendir
    the procfs mount point we would tell the user that the oprofile daemon was
    found by returning -1 on as the return for a bool function, oops, fix it,
    found with Coccinelle. (Peter Senna Tschudin).

  - Fix per-pkg event reporting bug in 'perf stat'. (Stephane Eranian)

Developer visible changes:

  - Fix missing prototype for function provided when it isn't present in the
    libelf present, fixing the build on RHEL/CentOS 5.1 systems, for instance.
    (Arnaldo Carvalho de Melo)

  - Detect if the gcc and libnuma have the features needed to avoid requiring
    the use of NO_LIBNUMA and/or NO_AUXTRACE to build on older systems.
    (Arnaldo Carvalho de Melo)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents a7d5c189 bf644563
...@@ -41,6 +41,7 @@ FEATURE_TESTS ?= \ ...@@ -41,6 +41,7 @@ FEATURE_TESTS ?= \
libelf-getphdrnum \ libelf-getphdrnum \
libelf-mmap \ libelf-mmap \
libnuma \ libnuma \
numa_num_possible_cpus \
libperl \ libperl \
libpython \ libpython \
libpython-version \ libpython-version \
...@@ -51,7 +52,8 @@ FEATURE_TESTS ?= \ ...@@ -51,7 +52,8 @@ FEATURE_TESTS ?= \
timerfd \ timerfd \
libdw-dwarf-unwind \ libdw-dwarf-unwind \
zlib \ zlib \
lzma lzma \
get_cpuid
FEATURE_DISPLAY ?= \ FEATURE_DISPLAY ?= \
dwarf \ dwarf \
...@@ -61,13 +63,15 @@ FEATURE_DISPLAY ?= \ ...@@ -61,13 +63,15 @@ FEATURE_DISPLAY ?= \
libbfd \ libbfd \
libelf \ libelf \
libnuma \ libnuma \
numa_num_possible_cpus \
libperl \ libperl \
libpython \ libpython \
libslang \ libslang \
libunwind \ libunwind \
libdw-dwarf-unwind \ libdw-dwarf-unwind \
zlib \ zlib \
lzma lzma \
get_cpuid
# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
# If in the future we need per-feature checks/flags for features not # If in the future we need per-feature checks/flags for features not
......
...@@ -19,6 +19,7 @@ FILES= \ ...@@ -19,6 +19,7 @@ FILES= \
test-libelf-getphdrnum.bin \ test-libelf-getphdrnum.bin \
test-libelf-mmap.bin \ test-libelf-mmap.bin \
test-libnuma.bin \ test-libnuma.bin \
test-numa_num_possible_cpus.bin \
test-libperl.bin \ test-libperl.bin \
test-libpython.bin \ test-libpython.bin \
test-libpython-version.bin \ test-libpython-version.bin \
...@@ -34,7 +35,8 @@ FILES= \ ...@@ -34,7 +35,8 @@ FILES= \
test-compile-x32.bin \ test-compile-x32.bin \
test-zlib.bin \ test-zlib.bin \
test-lzma.bin \ test-lzma.bin \
test-bpf.bin test-bpf.bin \
test-get_cpuid.bin
CC := $(CROSS_COMPILE)gcc -MD CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config PKG_CONFIG := $(CROSS_COMPILE)pkg-config
...@@ -87,6 +89,9 @@ test-libelf-getphdrnum.bin: ...@@ -87,6 +89,9 @@ test-libelf-getphdrnum.bin:
test-libnuma.bin: test-libnuma.bin:
$(BUILD) -lnuma $(BUILD) -lnuma
test-numa_num_possible_cpus.bin:
$(BUILD) -lnuma
test-libunwind.bin: test-libunwind.bin:
$(BUILD) -lelf $(BUILD) -lelf
...@@ -162,6 +167,9 @@ test-zlib.bin: ...@@ -162,6 +167,9 @@ test-zlib.bin:
test-lzma.bin: test-lzma.bin:
$(BUILD) -llzma $(BUILD) -llzma
test-get_cpuid.bin:
$(BUILD)
test-bpf.bin: test-bpf.bin:
$(BUILD) $(BUILD)
......
...@@ -77,6 +77,10 @@ ...@@ -77,6 +77,10 @@
# include "test-libnuma.c" # include "test-libnuma.c"
#undef main #undef main
#define main main_test_numa_num_possible_cpus
# include "test-numa_num_possible_cpus.c"
#undef main
#define main main_test_timerfd #define main main_test_timerfd
# include "test-timerfd.c" # include "test-timerfd.c"
#undef main #undef main
...@@ -117,6 +121,10 @@ ...@@ -117,6 +121,10 @@
# include "test-lzma.c" # include "test-lzma.c"
#undef main #undef main
#define main main_test_get_cpuid
# include "test-get_cpuid.c"
#undef main
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
main_test_libpython(); main_test_libpython();
...@@ -136,6 +144,7 @@ int main(int argc, char *argv[]) ...@@ -136,6 +144,7 @@ int main(int argc, char *argv[])
main_test_libbfd(); main_test_libbfd();
main_test_backtrace(); main_test_backtrace();
main_test_libnuma(); main_test_libnuma();
main_test_numa_num_possible_cpus();
main_test_timerfd(); main_test_timerfd();
main_test_stackprotector_all(); main_test_stackprotector_all();
main_test_libdw_dwarf_unwind(); main_test_libdw_dwarf_unwind();
...@@ -143,6 +152,7 @@ int main(int argc, char *argv[]) ...@@ -143,6 +152,7 @@ int main(int argc, char *argv[])
main_test_zlib(); main_test_zlib();
main_test_pthread_attr_setaffinity_np(); main_test_pthread_attr_setaffinity_np();
main_test_lzma(); main_test_lzma();
main_test_get_cpuid();
return 0; return 0;
} }
#include <cpuid.h>
int main(void)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
return __get_cpuid(0x15, &eax, &ebx, &ecx, &edx);
}
#include <numa.h>
int main(void)
{
return numa_num_possible_cpus();
}
...@@ -573,9 +573,14 @@ ifndef NO_LIBNUMA ...@@ -573,9 +573,14 @@ ifndef NO_LIBNUMA
msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev); msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev);
NO_LIBNUMA := 1 NO_LIBNUMA := 1
else else
CFLAGS += -DHAVE_LIBNUMA_SUPPORT ifeq ($(feature-numa_num_possible_cpus), 0)
EXTLIBS += -lnuma msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
$(call detected,CONFIG_NUMA) NO_LIBNUMA := 1
else
CFLAGS += -DHAVE_LIBNUMA_SUPPORT
EXTLIBS += -lnuma
$(call detected,CONFIG_NUMA)
endif
endif endif
endif endif
...@@ -621,8 +626,13 @@ ifdef LIBBABELTRACE ...@@ -621,8 +626,13 @@ ifdef LIBBABELTRACE
endif endif
ifndef NO_AUXTRACE ifndef NO_AUXTRACE
$(call detected,CONFIG_AUXTRACE) ifeq ($(feature-get_cpuid), 0)
CFLAGS += -DHAVE_AUXTRACE_SUPPORT msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc);
NO_AUXTRACE := 1
else
$(call detected,CONFIG_AUXTRACE)
CFLAGS += -DHAVE_AUXTRACE_SUPPORT
endif
endif endif
# Among the variables below, these: # Among the variables below, these:
......
...@@ -196,7 +196,8 @@ static void zero_per_pkg(struct perf_evsel *counter) ...@@ -196,7 +196,8 @@ static void zero_per_pkg(struct perf_evsel *counter)
memset(counter->per_pkg_mask, 0, MAX_NR_CPUS); memset(counter->per_pkg_mask, 0, MAX_NR_CPUS);
} }
static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip) static int check_per_pkg(struct perf_evsel *counter,
struct perf_counts_values *vals, int cpu, bool *skip)
{ {
unsigned long *mask = counter->per_pkg_mask; unsigned long *mask = counter->per_pkg_mask;
struct cpu_map *cpus = perf_evsel__cpus(counter); 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,6 +219,17 @@ static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip)
counter->per_pkg_mask = mask; counter->per_pkg_mask = mask;
} }
/*
* we do not consider an event that has not run as a good
* instance to mark a package as used (skip=1). Otherwise
* we may run into a situation where the first CPU in a package
* is not running anything, yet the second is, and this function
* would mark the package as used after the first CPU and would
* not read the values from the second CPU.
*/
if (!(vals->run && vals->ena))
return 0;
s = cpu_map__get_socket(cpus, cpu); s = cpu_map__get_socket(cpus, cpu);
if (s < 0) if (s < 0)
return -1; return -1;
...@@ -235,7 +247,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel ...@@ -235,7 +247,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel
static struct perf_counts_values zero; static struct perf_counts_values zero;
bool skip = false; bool skip = false;
if (check_per_pkg(evsel, cpu, &skip)) { if (check_per_pkg(evsel, count, cpu, &skip)) {
pr_err("failed to read per-pkg counter\n"); pr_err("failed to read per-pkg counter\n");
return -1; return -1;
} }
......
...@@ -38,7 +38,7 @@ static inline char *bfd_demangle(void __maybe_unused *v, ...@@ -38,7 +38,7 @@ static inline char *bfd_demangle(void __maybe_unused *v,
#endif #endif
#ifndef HAVE_ELF_GETPHDRNUM_SUPPORT #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
int elf_getphdrnum(Elf *elf, size_t *dst) static int elf_getphdrnum(Elf *elf, size_t *dst)
{ {
GElf_Ehdr gehdr; GElf_Ehdr gehdr;
GElf_Ehdr *ehdr; GElf_Ehdr *ehdr;
......
...@@ -709,7 +709,7 @@ bool find_process(const char *name) ...@@ -709,7 +709,7 @@ bool find_process(const char *name)
dir = opendir(procfs__mountpoint()); dir = opendir(procfs__mountpoint());
if (!dir) if (!dir)
return -1; return false;
/* Walk through the directory. */ /* Walk through the directory. */
while (ret && (d = readdir(dir)) != NULL) { while (ret && (d = readdir(dir)) != NULL) {
......
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