Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/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: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Sep 18, 2015
2 parents a7d5c18 + bf64456 commit a6f83f0
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 12 deletions.
8 changes: 6 additions & 2 deletions tools/build/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ FEATURE_TESTS ?= \
libelf-getphdrnum \
libelf-mmap \
libnuma \
numa_num_possible_cpus \
libperl \
libpython \
libpython-version \
Expand All @@ -51,7 +52,8 @@ FEATURE_TESTS ?= \
timerfd \
libdw-dwarf-unwind \
zlib \
lzma
lzma \
get_cpuid

FEATURE_DISPLAY ?= \
dwarf \
Expand All @@ -61,13 +63,15 @@ FEATURE_DISPLAY ?= \
libbfd \
libelf \
libnuma \
numa_num_possible_cpus \
libperl \
libpython \
libslang \
libunwind \
libdw-dwarf-unwind \
zlib \
lzma
lzma \
get_cpuid

# 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
Expand Down
10 changes: 9 additions & 1 deletion tools/build/feature/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FILES= \
test-libelf-getphdrnum.bin \
test-libelf-mmap.bin \
test-libnuma.bin \
test-numa_num_possible_cpus.bin \
test-libperl.bin \
test-libpython.bin \
test-libpython-version.bin \
Expand All @@ -34,7 +35,8 @@ FILES= \
test-compile-x32.bin \
test-zlib.bin \
test-lzma.bin \
test-bpf.bin
test-bpf.bin \
test-get_cpuid.bin

CC := $(CROSS_COMPILE)gcc -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
Expand Down Expand Up @@ -87,6 +89,9 @@ test-libelf-getphdrnum.bin:
test-libnuma.bin:
$(BUILD) -lnuma

test-numa_num_possible_cpus.bin:
$(BUILD) -lnuma

test-libunwind.bin:
$(BUILD) -lelf

Expand Down Expand Up @@ -162,6 +167,9 @@ test-zlib.bin:
test-lzma.bin:
$(BUILD) -llzma

test-get_cpuid.bin:
$(BUILD)

test-bpf.bin:
$(BUILD)

Expand Down
10 changes: 10 additions & 0 deletions tools/build/feature/test-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
# include "test-libnuma.c"
#undef main

#define main main_test_numa_num_possible_cpus
# include "test-numa_num_possible_cpus.c"
#undef main

#define main main_test_timerfd
# include "test-timerfd.c"
#undef main
Expand Down Expand Up @@ -117,6 +121,10 @@
# include "test-lzma.c"
#undef main

#define main main_test_get_cpuid
# include "test-get_cpuid.c"
#undef main

int main(int argc, char *argv[])
{
main_test_libpython();
Expand All @@ -136,13 +144,15 @@ int main(int argc, char *argv[])
main_test_libbfd();
main_test_backtrace();
main_test_libnuma();
main_test_numa_num_possible_cpus();
main_test_timerfd();
main_test_stackprotector_all();
main_test_libdw_dwarf_unwind();
main_test_sync_compare_and_swap(argc, argv);
main_test_zlib();
main_test_pthread_attr_setaffinity_np();
main_test_lzma();
main_test_get_cpuid();

return 0;
}
7 changes: 7 additions & 0 deletions tools/build/feature/test-get_cpuid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <cpuid.h>

int main(void)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
return __get_cpuid(0x15, &eax, &ebx, &ecx, &edx);
}
6 changes: 6 additions & 0 deletions tools/build/feature/test-numa_num_possible_cpus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <numa.h>

int main(void)
{
return numa_num_possible_cpus();
}
20 changes: 15 additions & 5 deletions tools/perf/config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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);
NO_LIBNUMA := 1
else
CFLAGS += -DHAVE_LIBNUMA_SUPPORT
EXTLIBS += -lnuma
$(call detected,CONFIG_NUMA)
ifeq ($(feature-numa_num_possible_cpus), 0)
msg := $(warning Old numa library found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev >= 2.0.8);
NO_LIBNUMA := 1
else
CFLAGS += -DHAVE_LIBNUMA_SUPPORT
EXTLIBS += -lnuma
$(call detected,CONFIG_NUMA)
endif
endif
endif

Expand Down Expand Up @@ -621,8 +626,13 @@ ifdef LIBBABELTRACE
endif

ifndef NO_AUXTRACE
$(call detected,CONFIG_AUXTRACE)
CFLAGS += -DHAVE_AUXTRACE_SUPPORT
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);
NO_AUXTRACE := 1
else
$(call detected,CONFIG_AUXTRACE)
CFLAGS += -DHAVE_AUXTRACE_SUPPORT
endif
endif

# Among the variables below, these:
Expand Down
16 changes: 14 additions & 2 deletions tools/perf/util/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ static void zero_per_pkg(struct perf_evsel *counter)
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;
struct cpu_map *cpus = perf_evsel__cpus(counter);
Expand All @@ -218,6 +219,17 @@ static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip)
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);
if (s < 0)
return -1;
Expand All @@ -235,7 +247,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel
static struct perf_counts_values zero;
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");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/symbol-elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static inline char *bfd_demangle(void __maybe_unused *v,
#endif

#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 *ehdr;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ bool find_process(const char *name)

dir = opendir(procfs__mountpoint());
if (!dir)
return -1;
return false;

/* Walk through the directory. */
while (ret && (d = readdir(dir)) != NULL) {
Expand Down

0 comments on commit a6f83f0

Please sign in to comment.