Commit 70943490 authored by Stephane Eranian's avatar Stephane Eranian Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Add optional support for libpfm4

This patch links perf with the libpfm4 library if it is available and
LIBPFM4 is passed to the build. The libpfm4 library contains hardware
event tables for all processors supported by perf_events. It is a helper
library that helps convert from a symbolic event name to the event
encoding required by the underlying kernel interface. This library is
open-source and available from: http://perfmon2.sf.net

.

With this patch, it is possible to specify full hardware events by name.
Hardware filters are also supported. Events must be specified via the
--pfm-events and not -e option. Both options are active at the same time
and it is possible to mix and match:

  $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....

One needs to explicitely ask for its inclusion by using the LIBPFM4 make
command line option, ie its opt-in rather than opt-out of feature
detection and build support.

Signed-off-by: default avatarStephane Eranian <eranian@google.com>
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Igor Lubashev <ilubashe@akamai.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Jiwei Sun <jiwei.sun@windriver.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: yuzhoujian <yuzhoujian@didichuxing.com>
Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 82352ae2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -615,6 +615,17 @@ appended unit character - B/K/M/G
	The number of threads to run when synthesizing events for existing processes.
	By default, the number of threads equals 1.

ifdef::HAVE_LIBPFM[]
--pfm-events events::
Select a PMU event using libpfm4 syntax (see http://perfmon2.sf.net)
including support for event filters. For example '--pfm-events
inst_retired:any_p:u:c=1:i'. More than one event can be passed to the
option using the comma separator. Hardware events and generic hardware
events cannot be mixed together. The latter must be used with the -e
option. The -e option and this one can be mixed and matched.  Events
can be grouped using the {} notation.
endif::HAVE_LIBPFM[]

SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1]
+10 −0
Original line number Diff line number Diff line
@@ -71,6 +71,16 @@ report::
--tid=<tid>::
        stat events on existing thread id (comma separated list)

ifdef::HAVE_LIBPFM[]
--pfm-events events::
Select a PMU event using libpfm4 syntax (see http://perfmon2.sf.net)
including support for event filters. For example '--pfm-events
inst_retired:any_p:u:c=1:i'. More than one event can be passed to the
option using the comma separator. Hardware events and generic hardware
events cannot be mixed together. The latter must be used with the -e
option. The -e option and this one can be mixed and matched.  Events
can be grouped using the {} notation.
endif::HAVE_LIBPFM[]

-a::
--all-cpus::
+11 −0
Original line number Diff line number Diff line
@@ -329,6 +329,17 @@ Default is to monitor all CPUS.
	The known limitations include exception handing such as
	setjmp/longjmp will have calls/returns not match.

ifdef::HAVE_LIBPFM[]
--pfm-events events::
Select a PMU event using libpfm4 syntax (see http://perfmon2.sf.net)
including support for event filters. For example '--pfm-events
inst_retired:any_p:u:c=1:i'. More than one event can be passed to the
option using the comma separator. Hardware events and generic hardware
events cannot be mixed together. The latter must be used with the -e
option. The -e option and this one can be mixed and matched.  Events
can be grouped using the {} notation.
endif::HAVE_LIBPFM[]

INTERACTIVE PROMPTING KEYS
--------------------------

+13 −0
Original line number Diff line number Diff line
@@ -1022,6 +1022,19 @@ ifdef LIBCLANGLLVM
  endif
endif

ifdef LIBPFM4
  $(call feature_check,libpfm4)
  ifeq ($(feature-libpfm4), 1)
    CFLAGS += -DHAVE_LIBPFM
    EXTLIBS += -lpfm
    ASCIIDOC_EXTRA = -aHAVE_LIBPFM=1
    $(call detected,CONFIG_LIBPFM4)
  else
    msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
    NO_LIBPFM4 := 1
  endif
endif

# Among the variables below, these:
#   perfexecdir
#   perf_include_dir
+3 −0
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@ include ../scripts/utilities.mak
# Define NO_SYSCALL_TABLE=1 to disable the use of syscall id to/from name tables
# generated from the kernel .tbl or unistd.h files and use, if available, libaudit
# for doing the conversions to/from strings/id.
#
# Define LIBPFM4 to enable libpfm4 events extension.
#

# As per kernel Makefile, avoid funny character set dependencies
unexport LC_ALL
Loading