perf tools fixes for v6.2: 2nd batch
- Make 'perf kmem' cope with the removal of some kmem:kmem_cache_alloc_node and kmem:kmalloc_node in the 11e9734bcb6a7361 ("mm/slab_common: unify NUMA and UMA version of tracepoints") commit, making sure it works with Linux >= 6.2 as well as with older kernels where those tracepoints are present. - Also make it handle the new "node" kmem:kmalloc and kmem:kmem_cache_alloc tracepoint field introduced in that same commit. - Fix hardware tracing PMU address filter duplicate symbol selection, that was preventing to match with static functions with the same name present in different object files. - Fix regression on what linux/types.h file gets used to build the "BPF prologue" 'perf test' entry, the system one lacks the fmode_t definition used in this test, so provide that type in the test itself. - Avoid build breakage with libbpf < 0.8.0 + LIBBPF_DYNAMIC=1. If the user asks for linking with the libbpf package provided by the distro, then it has to be >= 0.8.0. Using the libbpf supplied with the kernel would be a fallback in that case. - Fix the build when libbpf isn't available or explicitly disabled via NO_LIBBPF=1. - Don't try to install libtraceevent plugins as its not anymore in the kernel sources and will thus always fail. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQR2GiIUctdOfX2qHhGyPKLppCJ+JwUCY77xBAAKCRCyPKLppCJ+ J9B5AQCjCu18vsulBd0nRcfBZDGdw2P53OJl10slaAdU4t6RLgD/fwhRZ5PlmDiY TD+rARyZYsOsZ+9bVpJTZKh3nuCnewo= =T8iN -----END PGP SIGNATURE----- Merge tag 'perf-tools-fixes-for-v6.2-2-2023-01-11' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux Pull perf tools fixes from Arnaldo Carvalho de Melo: - Make 'perf kmem' cope with the removal of some kmem:kmem_cache_alloc_node and kmem:kmalloc_node in the 11e9734bcb6a7361 ("mm/slab_common: unify NUMA and UMA version of tracepoints") commit, making sure it works with Linux >= 6.2 as well as with older kernels where those tracepoints are present. - Also make it handle the new "node" kmem:kmalloc and kmem:kmem_cache_alloc tracepoint field introduced in that same commit. - Fix hardware tracing PMU address filter duplicate symbol selection, that was preventing to match with static functions with the same name present in different object files. - Fix regression on what linux/types.h file gets used to build the "BPF prologue" 'perf test' entry, the system one lacks the fmode_t definition used in this test, so provide that type in the test itself. - Avoid build breakage with libbpf < 0.8.0 + LIBBPF_DYNAMIC=1. If the user asks for linking with the libbpf package provided by the distro, then it has to be >= 0.8.0. Using the libbpf supplied with the kernel would be a fallback in that case. - Fix the build when libbpf isn't available or explicitly disabled via NO_LIBBPF=1. - Don't try to install libtraceevent plugins as its not anymore in the kernel sources and will thus always fail. * tag 'perf-tools-fixes-for-v6.2-2-2023-01-11' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf auxtrace: Fix address filter duplicate symbol selection perf bpf: Avoid build breakage with libbpf < 0.8.0 + LIBBPF_DYNAMIC=1 perf build: Fix build error when NO_LIBBPF=1 perf tools: Don't install libtraceevent plugins as its not anymore in the kernel sources perf kmem: Support field "node" in evsel__process_alloc_event() coping with recent tracepoint restructuring perf kmem: Support legacy tracepoints perf build: Properly guard libbpf includes perf tests bpf prologue: Fix bpf-script-test-prologue test compile issue with clang
This commit is contained in:
commit
e8f60cd7db
@ -589,6 +589,8 @@ ifndef NO_LIBELF
|
||||
$(call feature_check,libbpf-bpf_program__set_insns)
|
||||
ifeq ($(feature-libbpf-bpf_program__set_insns), 1)
|
||||
CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
|
||||
else
|
||||
dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
|
||||
endif
|
||||
$(call feature_check,libbpf-btf__raw_data)
|
||||
ifeq ($(feature-libbpf-btf__raw_data), 1)
|
||||
@ -602,6 +604,8 @@ ifndef NO_LIBELF
|
||||
dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
|
||||
endif
|
||||
else
|
||||
# Libbpf will be built as a static library from tools/lib/bpf.
|
||||
LIBBPF_STATIC := 1
|
||||
CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
|
||||
CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
|
||||
CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
|
||||
@ -1314,14 +1318,6 @@ tip_instdir_SQ = $(subst ','\'',$(tip_instdir))
|
||||
|
||||
export perfexec_instdir_SQ
|
||||
|
||||
# If we install to $(HOME) we keep the traceevent default:
|
||||
# $(HOME)/.traceevent/plugins
|
||||
# Otherwise we install plugins into the global $(libdir).
|
||||
ifdef DESTDIR
|
||||
plugindir=$(libdir)/traceevent/plugins
|
||||
plugindir_SQ= $(subst ','\'',$(plugindir))
|
||||
endif
|
||||
|
||||
print_var = $(eval $(print_var_code)) $(info $(MSG))
|
||||
define print_var_code
|
||||
MSG = $(shell printf '...%40s: %s' $(1) $($(1)))
|
||||
|
@ -303,10 +303,12 @@ ifneq ($(OUTPUT),)
|
||||
else
|
||||
LIBBPF_OUTPUT = $(CURDIR)/libbpf
|
||||
endif
|
||||
LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
|
||||
LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
|
||||
LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a
|
||||
CFLAGS += -I$(LIBBPF_OUTPUT)/include
|
||||
ifdef LIBBPF_STATIC
|
||||
LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
|
||||
LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
|
||||
LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a
|
||||
CFLAGS += -I$(LIBBPF_OUTPUT)/include
|
||||
endif
|
||||
|
||||
ifneq ($(OUTPUT),)
|
||||
LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd
|
||||
@ -393,10 +395,8 @@ endif
|
||||
export PERL_PATH
|
||||
|
||||
PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL)
|
||||
ifndef NO_LIBBPF
|
||||
ifndef LIBBPF_DYNAMIC
|
||||
PERFLIBS += $(LIBBPF)
|
||||
endif
|
||||
ifdef LIBBPF_STATIC
|
||||
PERFLIBS += $(LIBBPF)
|
||||
endif
|
||||
|
||||
# We choose to avoid "if .. else if .. else .. endif endif"
|
||||
@ -756,12 +756,15 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
|
||||
$(arch_errno_name_array) \
|
||||
$(sync_file_range_arrays) \
|
||||
$(LIBAPI) \
|
||||
$(LIBBPF) \
|
||||
$(LIBPERF) \
|
||||
$(LIBSUBCMD) \
|
||||
$(LIBSYMBOL) \
|
||||
bpf-skel
|
||||
|
||||
ifdef LIBBPF_STATIC
|
||||
prepare: $(LIBBPF)
|
||||
endif
|
||||
|
||||
$(OUTPUT)%.o: %.c prepare FORCE
|
||||
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "util/string2.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/numa.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/zalloc.h>
|
||||
@ -185,22 +186,33 @@ static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sample *s
|
||||
total_allocated += bytes_alloc;
|
||||
|
||||
nr_allocs++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int evsel__process_alloc_node_event(struct evsel *evsel, struct perf_sample *sample)
|
||||
{
|
||||
int ret = evsel__process_alloc_event(evsel, sample);
|
||||
/*
|
||||
* Commit 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA
|
||||
* version of tracepoints") adds the field "node" into the
|
||||
* tracepoints 'kmalloc' and 'kmem_cache_alloc'.
|
||||
*
|
||||
* The legacy tracepoints 'kmalloc_node' and 'kmem_cache_alloc_node'
|
||||
* also contain the field "node".
|
||||
*
|
||||
* If the tracepoint contains the field "node" the tool stats the
|
||||
* cross allocation.
|
||||
*/
|
||||
if (evsel__field(evsel, "node")) {
|
||||
int node1, node2;
|
||||
|
||||
if (!ret) {
|
||||
int node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu}),
|
||||
node2 = evsel__intval(evsel, sample, "node");
|
||||
node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu});
|
||||
node2 = evsel__intval(evsel, sample, "node");
|
||||
|
||||
if (node1 != node2)
|
||||
/*
|
||||
* If the field "node" is NUMA_NO_NODE (-1), we don't take it
|
||||
* as a cross allocation.
|
||||
*/
|
||||
if ((node2 != NUMA_NO_NODE) && (node1 != node2))
|
||||
nr_cross_allocs++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ptr_cmp(void *, void *);
|
||||
@ -1369,8 +1381,8 @@ static int __cmd_kmem(struct perf_session *session)
|
||||
/* slab allocator */
|
||||
{ "kmem:kmalloc", evsel__process_alloc_event, },
|
||||
{ "kmem:kmem_cache_alloc", evsel__process_alloc_event, },
|
||||
{ "kmem:kmalloc_node", evsel__process_alloc_node_event, },
|
||||
{ "kmem:kmem_cache_alloc_node", evsel__process_alloc_node_event, },
|
||||
{ "kmem:kmalloc_node", evsel__process_alloc_event, },
|
||||
{ "kmem:kmem_cache_alloc_node", evsel__process_alloc_event, },
|
||||
{ "kmem:kfree", evsel__process_free_event, },
|
||||
{ "kmem:kmem_cache_free", evsel__process_free_event, },
|
||||
/* page allocator */
|
||||
@ -1824,6 +1836,19 @@ static int parse_line_opt(const struct option *opt __maybe_unused,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool slab_legacy_tp_is_exposed(void)
|
||||
{
|
||||
/*
|
||||
* The tracepoints "kmem:kmalloc_node" and
|
||||
* "kmem:kmem_cache_alloc_node" have been removed on the latest
|
||||
* kernel, if the tracepoint "kmem:kmalloc_node" is existed it
|
||||
* means the tool is running on an old kernel, we need to
|
||||
* rollback to support these legacy tracepoints.
|
||||
*/
|
||||
return IS_ERR(trace_event__tp_format("kmem", "kmalloc_node")) ?
|
||||
false : true;
|
||||
}
|
||||
|
||||
static int __cmd_record(int argc, const char **argv)
|
||||
{
|
||||
const char * const record_args[] = {
|
||||
@ -1831,22 +1856,28 @@ static int __cmd_record(int argc, const char **argv)
|
||||
};
|
||||
const char * const slab_events[] = {
|
||||
"-e", "kmem:kmalloc",
|
||||
"-e", "kmem:kmalloc_node",
|
||||
"-e", "kmem:kfree",
|
||||
"-e", "kmem:kmem_cache_alloc",
|
||||
"-e", "kmem:kmem_cache_alloc_node",
|
||||
"-e", "kmem:kmem_cache_free",
|
||||
};
|
||||
const char * const slab_legacy_events[] = {
|
||||
"-e", "kmem:kmalloc_node",
|
||||
"-e", "kmem:kmem_cache_alloc_node",
|
||||
};
|
||||
const char * const page_events[] = {
|
||||
"-e", "kmem:mm_page_alloc",
|
||||
"-e", "kmem:mm_page_free",
|
||||
};
|
||||
unsigned int rec_argc, i, j;
|
||||
const char **rec_argv;
|
||||
unsigned int slab_legacy_tp_exposed = slab_legacy_tp_is_exposed();
|
||||
|
||||
rec_argc = ARRAY_SIZE(record_args) + argc - 1;
|
||||
if (kmem_slab)
|
||||
if (kmem_slab) {
|
||||
rec_argc += ARRAY_SIZE(slab_events);
|
||||
if (slab_legacy_tp_exposed)
|
||||
rec_argc += ARRAY_SIZE(slab_legacy_events);
|
||||
}
|
||||
if (kmem_page)
|
||||
rec_argc += ARRAY_SIZE(page_events) + 1; /* for -g */
|
||||
|
||||
@ -1861,6 +1892,10 @@ static int __cmd_record(int argc, const char **argv)
|
||||
if (kmem_slab) {
|
||||
for (j = 0; j < ARRAY_SIZE(slab_events); j++, i++)
|
||||
rec_argv[i] = strdup(slab_events[j]);
|
||||
if (slab_legacy_tp_exposed) {
|
||||
for (j = 0; j < ARRAY_SIZE(slab_legacy_events); j++, i++)
|
||||
rec_argv[i] = strdup(slab_legacy_events[j]);
|
||||
}
|
||||
}
|
||||
if (kmem_page) {
|
||||
rec_argv[i++] = strdup("-g");
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
#include "util/record.h"
|
||||
#include <api/fs/tracing_path.h>
|
||||
#ifdef HAVE_LIBBPF_SUPPORT
|
||||
#include <bpf/bpf.h>
|
||||
#endif
|
||||
#include "util/bpf_map.h"
|
||||
#include "util/rlimit.h"
|
||||
#include "builtin.h"
|
||||
|
@ -20,6 +20,8 @@
|
||||
# undef if
|
||||
#endif
|
||||
|
||||
typedef unsigned int __bitwise fmode_t;
|
||||
|
||||
#define FMODE_READ 0x1
|
||||
#define FMODE_WRITE 0x2
|
||||
|
||||
|
@ -222,19 +222,7 @@ installed_files_bin := bin/perf
|
||||
installed_files_bin += etc/bash_completion.d/perf
|
||||
installed_files_bin += libexec/perf-core/perf-archive
|
||||
|
||||
installed_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
|
||||
installed_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
|
||||
|
||||
installed_files_all := $(installed_files_bin)
|
||||
installed_files_all += $(installed_files_plugins)
|
||||
|
||||
test_make_install := $(call test_dest_files,$(installed_files_all))
|
||||
test_make_install_O := $(call test_dest_files,$(installed_files_all))
|
||||
|
@ -2611,7 +2611,7 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
|
||||
*size = sym->start - *start;
|
||||
if (idx > 0) {
|
||||
if (*size)
|
||||
return 1;
|
||||
return 0;
|
||||
} else if (dso_sym_match(sym, sym_name, &cnt, idx)) {
|
||||
print_duplicate_syms(dso, sym_name);
|
||||
return -EINVAL;
|
||||
|
@ -4,9 +4,12 @@
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#ifdef HAVE_LIBBPF_SUPPORT
|
||||
#include <bpf/bpf.h>
|
||||
#include <bpf/btf.h>
|
||||
#include <bpf/libbpf.h>
|
||||
#endif
|
||||
|
||||
struct evsel;
|
||||
struct target;
|
||||
@ -87,6 +90,8 @@ static inline void set_max_rlimit(void)
|
||||
setrlimit(RLIMIT_MEMLOCK, &rinf);
|
||||
}
|
||||
|
||||
#ifdef HAVE_BPF_SKEL
|
||||
|
||||
static inline __u32 bpf_link_get_id(int fd)
|
||||
{
|
||||
struct bpf_link_info link_info = { .id = 0, };
|
||||
@ -127,5 +132,6 @@ static inline int bperf_trigger_reading(int prog_fd, int cpu)
|
||||
|
||||
return bpf_prog_test_run_opts(prog_fd, &opts);
|
||||
}
|
||||
#endif /* HAVE_BPF_SKEL */
|
||||
|
||||
#endif /* __PERF_BPF_COUNTER_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user