Commit 2a987e65 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of...

Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix SMT detection fast read path on sysfs.

 - Fix memory leaks when processing feature headers in perf.data files.

 - Fix 'Simple expression parser' 'perf test' on arch without CPU die
   topology info, such as s/390.

 - Fix building perf with BUILD_BPF_SKEL=1.

 - Fix 'perf bench' by reverting "perf bench: Fix two memory leaks
   detected with ASan".

 - Fix itrace space allowed for new attributes in 'perf script'.

 - Fix the build feature detection fast path, that was always failing on
   systems with python3 development packages, speeding up the build.

 - Reset shadow counts before loading, fixing metrics using
   duration_time.

 - Sync more kernel headers changed by the new futex_waitv syscall: s390
   and powerpc.

* tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf bpf_skel: Do not use typedef to avoid error on old clang
  perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros
  perf header: Fix memory leaks when processing feature headers
  perf test: Reset shadow counts before loading
  perf test: Fix 'Simple expression parser' test on arch without CPU die topology info
  tools build: Remove needless libpython-version feature check that breaks test-all fast path
  perf tools: Fix SMT detection fast read path
  tools headers UAPI: Sync powerpc syscall table file changed by new futex_waitv syscall
  perf inject: Fix itrace space allowed for new attributes
  tools headers UAPI: Sync s390 syscall table file changed by new futex_waitv syscall
  Revert "perf bench: Fix two memory leaks detected with ASan"
parents 95723243 5a897531
...@@ -48,7 +48,6 @@ FEATURE_TESTS_BASIC := \ ...@@ -48,7 +48,6 @@ FEATURE_TESTS_BASIC := \
numa_num_possible_cpus \ numa_num_possible_cpus \
libperl \ libperl \
libpython \ libpython \
libpython-version \
libslang \ libslang \
libslang-include-subdir \ libslang-include-subdir \
libtraceevent \ libtraceevent \
......
...@@ -32,7 +32,6 @@ FILES= \ ...@@ -32,7 +32,6 @@ FILES= \
test-numa_num_possible_cpus.bin \ test-numa_num_possible_cpus.bin \
test-libperl.bin \ test-libperl.bin \
test-libpython.bin \ test-libpython.bin \
test-libpython-version.bin \
test-libslang.bin \ test-libslang.bin \
test-libslang-include-subdir.bin \ test-libslang-include-subdir.bin \
test-libtraceevent.bin \ test-libtraceevent.bin \
...@@ -227,9 +226,6 @@ $(OUTPUT)test-libperl.bin: ...@@ -227,9 +226,6 @@ $(OUTPUT)test-libperl.bin:
$(OUTPUT)test-libpython.bin: $(OUTPUT)test-libpython.bin:
$(BUILD) $(FLAGS_PYTHON_EMBED) $(BUILD) $(FLAGS_PYTHON_EMBED)
$(OUTPUT)test-libpython-version.bin:
$(BUILD)
$(OUTPUT)test-libbfd.bin: $(OUTPUT)test-libbfd.bin:
$(BUILD) -DPACKAGE='"perf"' -lbfd -ldl $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
# include "test-libpython.c" # include "test-libpython.c"
#undef main #undef main
#define main main_test_libpython_version
# include "test-libpython-version.c"
#undef main
#define main main_test_libperl #define main main_test_libperl
# include "test-libperl.c" # include "test-libperl.c"
#undef main #undef main
...@@ -177,7 +173,6 @@ ...@@ -177,7 +173,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
main_test_libpython(); main_test_libpython();
main_test_libpython_version();
main_test_libperl(); main_test_libperl();
main_test_hello(); main_test_hello();
main_test_libelf(); main_test_libelf();
......
// SPDX-License-Identifier: GPL-2.0
#include <Python.h>
#if PY_VERSION_HEX >= 0x03000000
#error
#endif
int main(void)
{
return 0;
}
...@@ -271,8 +271,6 @@ endif ...@@ -271,8 +271,6 @@ endif
FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
FEATURE_CHECK_LDFLAGS-libaio = -lrt FEATURE_CHECK_LDFLAGS-libaio = -lrt
......
...@@ -528,3 +528,4 @@ ...@@ -528,3 +528,4 @@
446 common landlock_restrict_self sys_landlock_restrict_self 446 common landlock_restrict_self sys_landlock_restrict_self
# 447 reserved for memfd_secret # 447 reserved for memfd_secret
448 common process_mrelease sys_process_mrelease 448 common process_mrelease sys_process_mrelease
449 common futex_waitv sys_futex_waitv
...@@ -451,3 +451,4 @@ ...@@ -451,3 +451,4 @@
446 common landlock_restrict_self sys_landlock_restrict_self sys_landlock_restrict_self 446 common landlock_restrict_self sys_landlock_restrict_self sys_landlock_restrict_self
# 447 reserved for memfd_secret # 447 reserved for memfd_secret
448 common process_mrelease sys_process_mrelease sys_process_mrelease 448 common process_mrelease sys_process_mrelease sys_process_mrelease
449 common futex_waitv sys_futex_waitv sys_futex_waitv
...@@ -223,8 +223,6 @@ static unsigned int group(pthread_t *pth, ...@@ -223,8 +223,6 @@ static unsigned int group(pthread_t *pth,
snd_ctx->out_fds[i] = fds[1]; snd_ctx->out_fds[i] = fds[1];
if (!thread_mode) if (!thread_mode)
close(fds[0]); close(fds[0]);
free(ctx);
} }
/* Now we have all the fds, fork the senders */ /* Now we have all the fds, fork the senders */
...@@ -241,8 +239,6 @@ static unsigned int group(pthread_t *pth, ...@@ -241,8 +239,6 @@ static unsigned int group(pthread_t *pth,
for (i = 0; i < num_fds; i++) for (i = 0; i < num_fds; i++)
close(snd_ctx->out_fds[i]); close(snd_ctx->out_fds[i]);
free(snd_ctx);
/* Return number of children to reap */ /* Return number of children to reap */
return num_fds * 2; return num_fds * 2;
} }
......
...@@ -820,7 +820,7 @@ static int __cmd_inject(struct perf_inject *inject) ...@@ -820,7 +820,7 @@ static int __cmd_inject(struct perf_inject *inject)
inject->tool.ordered_events = true; inject->tool.ordered_events = true;
inject->tool.ordering_requires_timestamps = true; inject->tool.ordering_requires_timestamps = true;
/* Allow space in the header for new attributes */ /* Allow space in the header for new attributes */
output_data_offset = 4096; output_data_offset = roundup(8192 + session->header.data_offset, 4096);
if (inject->strip) if (inject->strip)
strip_init(inject); strip_init(inject);
} }
......
...@@ -169,6 +169,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u ...@@ -169,6 +169,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
TEST_ASSERT_VAL("#num_dies", expr__parse(&num_dies, ctx, "#num_dies") == 0); TEST_ASSERT_VAL("#num_dies", expr__parse(&num_dies, ctx, "#num_dies") == 0);
TEST_ASSERT_VAL("#num_cores >= #num_dies", num_cores >= num_dies); TEST_ASSERT_VAL("#num_cores >= #num_dies", num_cores >= num_dies);
TEST_ASSERT_VAL("#num_packages", expr__parse(&num_packages, ctx, "#num_packages") == 0); TEST_ASSERT_VAL("#num_packages", expr__parse(&num_packages, ctx, "#num_packages") == 0);
if (num_dies) // Some platforms do not have CPU die support, for example s390
TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages); TEST_ASSERT_VAL("#num_dies >= #num_packages", num_dies >= num_packages);
/* /*
......
...@@ -109,6 +109,7 @@ static void load_runtime_stat(struct runtime_stat *st, struct evlist *evlist, ...@@ -109,6 +109,7 @@ static void load_runtime_stat(struct runtime_stat *st, struct evlist *evlist,
struct evsel *evsel; struct evsel *evsel;
u64 count; u64 count;
perf_stat__reset_shadow_stats();
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
count = find_value(evsel->name, vals); count = find_value(evsel->name, vals);
perf_stat__update_shadow_stats(evsel, count, 0, st); perf_stat__update_shadow_stats(evsel, count, 0, st);
......
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
// Copyright (c) 2021 Facebook
#ifndef __BPERF_STAT_H
#define __BPERF_STAT_H
typedef struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct bpf_perf_event_value));
__uint(max_entries, 1);
} reading_map;
#endif /* __BPERF_STAT_H */
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
// Copyright (c) 2021 Facebook // Copyright (c) 2021 Facebook
#include <linux/bpf.h> #include "vmlinux.h"
#include <linux/perf_event.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h> #include <bpf/bpf_tracing.h>
#include "bperf.h"
#include "bperf_u.h" #include "bperf_u.h"
reading_map diff_readings SEC(".maps"); struct {
reading_map accum_readings SEC(".maps"); __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct bpf_perf_event_value));
__uint(max_entries, 1);
} diff_readings SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct bpf_perf_event_value));
__uint(max_entries, 1);
} accum_readings SEC(".maps");
struct { struct {
__uint(type, BPF_MAP_TYPE_HASH); __uint(type, BPF_MAP_TYPE_HASH);
......
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
// Copyright (c) 2021 Facebook // Copyright (c) 2021 Facebook
#include <linux/bpf.h> #include "vmlinux.h"
#include <linux/perf_event.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h> #include <bpf/bpf_tracing.h>
#include "bperf.h"
struct { struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
...@@ -13,8 +11,19 @@ struct { ...@@ -13,8 +11,19 @@ struct {
__uint(map_flags, BPF_F_PRESERVE_ELEMS); __uint(map_flags, BPF_F_PRESERVE_ELEMS);
} events SEC(".maps"); } events SEC(".maps");
reading_map prev_readings SEC(".maps"); struct {
reading_map diff_readings SEC(".maps"); __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct bpf_perf_event_value));
__uint(max_entries, 1);
} prev_readings SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(struct bpf_perf_event_value));
__uint(max_entries, 1);
} diff_readings SEC(".maps");
SEC("raw_tp/sched_switch") SEC("raw_tp/sched_switch")
int BPF_PROG(on_switch) int BPF_PROG(on_switch)
......
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
// Copyright (c) 2020 Facebook // Copyright (c) 2020 Facebook
#include <linux/bpf.h> #include "vmlinux.h"
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h> #include <bpf/bpf_tracing.h>
......
...@@ -2321,6 +2321,7 @@ static int perf_header__read_build_ids(struct perf_header *header, ...@@ -2321,6 +2321,7 @@ static int perf_header__read_build_ids(struct perf_header *header,
#define FEAT_PROCESS_STR_FUN(__feat, __feat_env) \ #define FEAT_PROCESS_STR_FUN(__feat, __feat_env) \
static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \ static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \
{\ {\
free(ff->ph->env.__feat_env); \
ff->ph->env.__feat_env = do_read_string(ff); \ ff->ph->env.__feat_env = do_read_string(ff); \
return ff->ph->env.__feat_env ? 0 : -ENOMEM; \ return ff->ph->env.__feat_env ? 0 : -ENOMEM; \
} }
...@@ -4124,6 +4125,7 @@ int perf_event__process_feature(struct perf_session *session, ...@@ -4124,6 +4125,7 @@ int perf_event__process_feature(struct perf_session *session,
struct perf_record_header_feature *fe = (struct perf_record_header_feature *)event; struct perf_record_header_feature *fe = (struct perf_record_header_feature *)event;
int type = fe->header.type; int type = fe->header.type;
u64 feat = fe->feat_id; u64 feat = fe->feat_id;
int ret = 0;
if (type < 0 || type >= PERF_RECORD_HEADER_MAX) { if (type < 0 || type >= PERF_RECORD_HEADER_MAX) {
pr_warning("invalid record type %d in pipe-mode\n", type); pr_warning("invalid record type %d in pipe-mode\n", type);
...@@ -4141,11 +4143,13 @@ int perf_event__process_feature(struct perf_session *session, ...@@ -4141,11 +4143,13 @@ int perf_event__process_feature(struct perf_session *session,
ff.size = event->header.size - sizeof(*fe); ff.size = event->header.size - sizeof(*fe);
ff.ph = &session->header; ff.ph = &session->header;
if (feat_ops[feat].process(&ff, NULL)) if (feat_ops[feat].process(&ff, NULL)) {
return -1; ret = -1;
goto out;
}
if (!feat_ops[feat].print || !tool->show_feat_hdr) if (!feat_ops[feat].print || !tool->show_feat_hdr)
return 0; goto out;
if (!feat_ops[feat].full_only || if (!feat_ops[feat].full_only ||
tool->show_feat_hdr >= SHOW_FEAT_HEADER_FULL_INFO) { tool->show_feat_hdr >= SHOW_FEAT_HEADER_FULL_INFO) {
...@@ -4154,8 +4158,9 @@ int perf_event__process_feature(struct perf_session *session, ...@@ -4154,8 +4158,9 @@ int perf_event__process_feature(struct perf_session *session,
fprintf(stdout, "# %s info available, use -I to display\n", fprintf(stdout, "# %s info available, use -I to display\n",
feat_ops[feat].name); feat_ops[feat].name);
} }
out:
return 0; free_event_desc(ff.events);
return ret;
} }
size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp) size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp)
......
...@@ -15,7 +15,7 @@ int smt_on(void) ...@@ -15,7 +15,7 @@ int smt_on(void)
if (cached) if (cached)
return cached_result; return cached_result;
if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) > 0) if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) >= 0)
goto done; goto done;
ncpu = sysconf(_SC_NPROCESSORS_CONF); ncpu = sysconf(_SC_NPROCESSORS_CONF);
......
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