perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider applying,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit 07590a7d4030c159b9a0d7171f81049a9ce23245:
Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-04-20 10:07:18 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.12-20170424
for you to fetch changes up to 9d43f5e8df6804ae271407500af9062e9278167a:
perf tools: Fix the code to strip command name (2017-04-24 13:43:37 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Fix display of data source snoop indication in 'perf mem' (Andi Kleen)
- Fix the code to strip command name from /proc/PID/stat (Jiri Olsa)
Infrastructure:
- Continue the disentanglement of headers, specially util.h (Arnaldo Carvalho de Melo)
- Synchronize some header files with the kernel (Arnaldo Carvalho de Melo)
----------------------------------------------------------------
Andi Kleen (1):
perf mem: Fix display of data source snoop indication
Arnaldo Carvalho de Melo (20):
perf unwind: Provide only forward declarations for pointer types perf tools: Add signal.h to places using its definitions
perf tools: Move units conversion/formatting routines to separate object perf tools: Move timestamp routines from util.h to time-utils.h perf kvm: Make function only used by 'perf kvm' static
perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h perf tools: Add compress.h for the *_decompress_to_file() headers perf callchain: Move callchain specific routines from util.[ch] perf tools: Include sys/param.h where needed
perf tools: Remove a few more needless includes from util.h perf tools: Remove sys/ioctl.h from util.h
perf tools: Remove string.h from util.h
perf tools: Remove stale prototypes from builtin.h
perf tools: Remove string.h, unistd.h and sys/stat.h from util.h perf tools: Remove poll.h and wait.h from util.h
perf tools: Add the right header to obtain PERF_ALIGN()
perf tools: Use just forward declarations for struct thread where possible
tools: Update asm-generic/mman-common.h copy from the kernel tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel tools arch x86: Sync cpufeatures.h
Jiri Olsa (1):
perf tools: Fix the code to strip command name
tools/arch/x86/include/asm/cpufeatures.h | 1 + tools/arch/x86/lib/memcpy_64.S | 2 +- tools/include/uapi/linux/stat.h | 5 +- tools/lib/subcmd/help.h | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm/util/unwind-libdw.c | 1 + tools/perf/arch/arm64/util/dwarf-regs.c | 1 + tools/perf/arch/x86/tests/intel-cqm.c | 2 + tools/perf/arch/x86/util/unwind-libdw.c | 1 + tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-c2c.c | 2 + tools/perf/builtin-ftrace.c | 1 + tools/perf/builtin-help.c | 4 + tools/perf/builtin-inject.c | 2 + tools/perf/builtin-kvm.c | 17 +++ tools/perf/builtin-mem.c | 4 + tools/perf/builtin-record.c | 5 + tools/perf/builtin-report.c | 5 + tools/perf/builtin-script.c | 5 + tools/perf/builtin-stat.c | 5 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 2 + tools/perf/builtin-version.c | 3 +- tools/perf/builtin.h | 4 - tools/perf/perf.c | 6 +- tools/perf/tests/attr.c | 4 + tools/perf/tests/bpf.c | 2 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/tests/parse-events.c | 3 + tools/perf/tests/unit_number__scnprintf.c | 2 +- tools/perf/trace/beauty/signum.c | 1 + tools/perf/ui/browsers/hists.c | 2 + tools/perf/ui/gtk/annotate.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/build-id.c | 3 + tools/perf/util/callchain.c | 103 +++++++++++++++ tools/perf/util/color.h | 2 + tools/perf/util/comm.c | 1 + tools/perf/util/compress.h | 12 ++ tools/perf/util/config.c | 4 + tools/perf/util/debug.c | 33 ++++- tools/perf/util/debug.h | 3 + tools/perf/util/dso.c | 4 + tools/perf/util/event.c | 12 +- tools/perf/util/event.h | 2 +- tools/perf/util/evlist.c | 3 + tools/perf/util/evlist.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/header.c | 4 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/hist.c | 2 + tools/perf/util/llvm-utils.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/machine.c | 3 + tools/perf/util/mem-events.c | 2 +- tools/perf/util/namespaces.c | 1 + tools/perf/util/parse-events.c | 2 + tools/perf/util/pmu.c | 1 + tools/perf/util/probe-file.c | 3 + tools/perf/util/python-ext-sources | 1 + tools/perf/util/python.c | 13 ++ tools/perf/util/session.c | 1 + tools/perf/util/session.h | 3 +- tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 3 +- tools/perf/util/strlist.c | 1 + tools/perf/util/time-utils.c | 25 ++++ tools/perf/util/time-utils.h | 7 + tools/perf/util/top.h | 2 +- tools/perf/util/units.c | 39 ++++++ tools/perf/util/units.h | 10 ++ tools/perf/util/unwind-libdw.h | 6 +- tools/perf/util/unwind.h | 9 +- tools/perf/util/util.c | 211 +----------------------------- tools/perf/util/util.h | 38 ------ tools/perf/util/xyarray.c | 2 + tools/perf/util/zlib.c | 1 + 82 files changed, 412 insertions(+), 270 deletions(-) create mode 100644 tools/perf/util/compress.h create mode 100644 tools/perf/util/units.c create mode 100644 tools/perf/util/units.h
Test results:
The first ones are container (docker) based builds of tools/perf with and without libelf support, objtool where it is supported and samples/bpf/, ditto. Where clang is available, it is also used to build perf with/without libelf.
Several are cross builds, the ones with -x-ARCH, and the android one, and those may not have all the features built, due to lack of multi-arch devel packages, available and being used so far on just a few, like debian:experimental-x-{arm64,mipsel}.
The 'perf test' one will perform a variety of tests exercising tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands with a variety of command line event specifications to then intercept the sys_perf_event syscall to check that the perf_event_attr fields are set up as expected, among a variety of other unit tests.
Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/ with a variety of feature sets, exercising the build with an incomplete set of features as well as with a complete one. It is planned to have it run on each of the containers mentioned above, using some container orchestration infrastructure. Get in contact if interested in helping having this in place.
# dm 1 alpine:3.4: Ok 2 alpine:3.5: Ok 3 alpine:edge: Ok 4 android-ndk:r12b-arm: Ok 5 archlinux:latest: Ok 6 centos:5: Ok 7 centos:6: Ok 8 centos:7: Ok 9 debian:7: Ok 10 debian:8: Ok 11 debian:9: Ok 12 debian:experimental: Ok 13 debian:experimental-x-arm64: Ok 14 debian:experimental-x-mips: Ok 15 debian:experimental-x-mips64: Ok 16 debian:experimental-x-mipsel: Ok 17 fedora:20: Ok 18 fedora:21: Ok 19 fedora:22: Ok 20 fedora:23: Ok 21 fedora:24: Ok 22 fedora:24-x-ARC-uClibc: Ok 23 fedora:25: Ok 24 fedora:rawhide: Ok 25 mageia:5: Ok 26 opensuse:13.2: Ok 27 opensuse:42.1: Ok 28 opensuse:tumbleweed: Ok 29 ubuntu:12.04.5: Ok 30 ubuntu:14.04.4: Ok 31 ubuntu:14.04.4-x-linaro-arm64: Ok 32 ubuntu:15.10: Ok 33 ubuntu:16.04: Ok 34 ubuntu:16.04-x-arm: Ok 35 ubuntu:16.04-x-arm64: Ok 36 ubuntu:16.04-x-powerpc: Ok 37 ubuntu:16.04-x-powerpc64: Ok 38 ubuntu:16.04-x-s390: Ok 39 ubuntu:16.10: Ok 40 ubuntu:17.04: Ok #
# perf test
1: vmlinux symtab matches kallsyms : Ok
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Parse event definition strings : Ok
6: Simple expression parser : Ok
7: PERF_RECORD_* events & perf_sample fields : Ok
8: Parse perf pmu format : Ok
9: DSO data read : Ok
10: DSO data cache : Ok
11: DSO data reopen : Ok
12: Roundtrip evsel->name : Ok
13: Parse sched tracepoints fields : Ok
14: syscalls:sys_enter_openat event fields : Ok
15: Setup struct perf_event_attr : Ok
16: Match and link multiple hists : Ok
17: 'import perf' in python : Ok
18: Breakpoint overflow signal handler : Ok
19: Breakpoint overflow sampling : Ok
20: Number of exit events of a simple workload : Ok
21: Software clock events period values : Ok
22: Object code reading : Ok
23: Sample parsing : Ok
24: Use a dummy software event to keep tracking: Ok
25: Parse with no sample_id_all bit set : Ok
26: Filter hist entries : Ok
27: Lookup mmap thread : Ok
28: Share thread mg : Ok
29: Sort output of hist entries : Ok
30: Cumulate child hist entries : Ok
31: Track with sched_switch : Ok
32: Filter fds with revents mask in a fdarray : Ok
33: Add fd to a fdarray, making it autogrow : Ok
34: kmod_path__parse : Ok
35: Thread map : Ok
36: LLVM search and compile :
36.1: Basic BPF llvm compile : Ok
36.2: kbuild searching : Ok
36.3: Compile source for BPF prologue generation: Ok
36.4: Compile source for BPF relocation : Ok
37: Session topology : Ok
38: BPF filter :
38.1: Basic BPF filtering : Ok
38.2: BPF pinning : Ok
38.3: BPF prologue generation : Ok
38.4: BPF relocation checker : Ok
39: Synthesize thread map : Ok
40: Remove thread map : Ok
41: Synthesize cpu map : Ok
42: Synthesize stat config : Ok
43: Synthesize stat : Ok
44: Synthesize stat round : Ok
45: Synthesize attr update : Ok
46: Event times : Ok
47: Read backward ring buffer : Ok
48: Print cpu map : Ok
49: Probe SDT events : Ok
50: is_printable_array : Ok
51: Print bitmap : Ok
52: perf hooks : Ok
53: builtin clang support : Skip (not compiled in)
54: unit_number__scnprintf : Ok
55: x86 rdpmc : Ok
56: Convert perf time to TSC : Ok
57: DWARF unwind : Ok
58: x86 instruction decoder - new instructions : Ok
59: Intel cqm nmi context read : Skip
#
$ make -C tools/perf build-test
make: Entering directory '/home/acme/git/linux/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
cd . && make FEATURE_DUMP_COPY=/home/acme/git/linux/tools/perf/BUILD_TEST_FEATURE_DUMP feature-dump
make_doc_O: && make doc
make_install_prefix_O: && make install prefix=/tmp/krava
make_no_libaudit_O: && make NO_LIBAUDIT=1
make_util_map_o_O: && make util/map.o
make_no_libelf_O: && make NO_LIBELF=1
make_no_scripts_O: && make NO_LIBPYTHON=1 NO_LIBPERL=1
make_no_gtk2_O: && make NO_GTK2=1
make_no_backtrace_O: && make NO_BACKTRACE=1
make_minimal_O: && make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
make_no_ui_O: && make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_auxtrace_O: && make NO_AUXTRACE=1
make_perf_o_O: && make perf.o
make_install_prefix_slash_O: && make install prefix=/tmp/krava/
make_with_babeltrace_O: && make LIBBABELTRACE=1
make_no_newt_O: && make NO_NEWT=1
make_no_libperl_O: && make NO_LIBPERL=1
make_no_demangle_O: && make NO_DEMANGLE=1
make_debug_O: && make DEBUG=1
make_no_libunwind_O: && make NO_LIBUNWIND=1
make_tags_O: && make tags
make_install_bin_O: && make install-bin
make_no_libbpf_O: && make NO_LIBBPF=1
make_help_O: && make help
make_pure_O: && make
make_static_O: && make LDFLAGS=-static
make_with_clangllvm_O: && make LIBCLANGLLVM=1
make_util_pmu_bison_o_O: && make util/pmu-bison.o
make_no_libbionic_O: && make NO_LIBBIONIC=1
make_no_slang_O: && make NO_SLANG=1
make_no_libpython_O: && make NO_LIBPYTHON=1
make_clean_all_O: && make clean all
make_no_libdw_dwarf_unwind_O: && make NO_LIBDW_DWARF_UNWIND=1
make_no_libnuma_O: && make NO_LIBNUMA=1
make_install_O: && make install
OK
make: Leaving directory '/home/acme/git/linux/tools/perf'
$Arnaldo Carvalho de Melo
maintainerPATCH 1/22 perf unwind: Provide only forward declarations for pointer types
From: Arnaldo Carvalho de Melo <[email protected]>
No need to drag the headers, helps in untangling them and reducing build time.
--- tools/perf/util/unwind.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/util/unwind.h +6 -3
@@ -1,10 +1,13 @@ #ifndef __UNWIND_H #define __UNWIND_H +#include <linux/compiler.h> #include <linux/types.h> -#include "event.h" -#include "symbol.h" -#include "thread.h" + +struct map; +struct perf_sample; +struct symbol; +struct thread; struct unwind_entry { struct map *map;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 2/22 perf tools: Add signal.h to places using its definitions
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
And remove it from util.h, disentangling it a bit more.
--- tools/perf/arch/x86/tests/intel-cqm.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 1 + tools/perf/trace/beauty/signum.c | 1 + tools/perf/ui/gtk/annotate.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/evlist.h | 1 + tools/perf/util/util.c | 1 + tools/perf/util/util.h | 1 - 17 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/arch/x86/tests/intel-cqm.c +1 -0
@@ -6,6 +6,7 @@#include "evsel.h" #include "arch-tests.h" +#include <signal.h> #include <sys/mman.h> #include <errno.h> #include <string.h>
tools/perf/builtin-inject.c +1 -0
@@ -23,6 +23,7 @@#include <linux/list.h> #include <errno.h> +#include <signal.h> struct perf_inject {struct perf_tool tool;
tools/perf/builtin-kvm.c +1 -0
@@ -31,6 +31,7 @@#include <inttypes.h> #include <termios.h> #include <semaphore.h> +#include <signal.h> #include <pthread.h> #include <math.h>
tools/perf/builtin-record.c +1 -0
@@ -44,6 +44,7 @@#include <inttypes.h> #include <unistd.h> #include <sched.h> +#include <signal.h> #include <sys/mman.h> #include <asm/bug.h> #include <linux/time64.h>
tools/perf/builtin-report.c +1 -0
@@ -42,6 +42,7 @@#include <errno.h> #include <inttypes.h> #include <regex.h> +#include <signal.h> #include <linux/bitmap.h> #include <linux/stringify.h>
tools/perf/builtin-script.c +1 -0
@@ -35,6 +35,7 @@#include <dirent.h> #include <errno.h> #include <inttypes.h> +#include <signal.h> #include "sane_ctype.h"
tools/perf/builtin-stat.c +1 -0
@@ -70,6 +70,7 @@#include <linux/time64.h> #include <api/fs/fs.h> #include <errno.h> +#include <signal.h> #include <stdlib.h> #include <sys/prctl.h> #include <inttypes.h>
tools/perf/builtin-top.c +1 -0
@@ -59,6 +59,7 @@#include <errno.h> #include <time.h> #include <sched.h> +#include <signal.h> #include <sys/syscall.h> #include <sys/ioctl.h>
tools/perf/builtin-trace.c +1 -0
@@ -45,6 +45,7 @@#include <errno.h> #include <inttypes.h> #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ +#include <signal.h> #include <stdlib.h> #include <string.h> #include <linux/err.h>
tools/perf/perf.c +1 -0
@@ -21,6 +21,7 @@#include <api/fs/tracing_path.h> #include <errno.h> #include <pthread.h> +#include <signal.h> #include <stdlib.h> #include <time.h> #include <linux/kernel.h>
tools/perf/trace/beauty/signum.c +1 -0
@@ -1,3 +1,4 @@ +#include <signal.h> static size_t syscall_arg__scnprintf_signum (char *bf,size_t size,struct syscall_arg *arg) {
tools/perf/ui/gtk/annotate.c +1 -0
@@ -4,6 +4,7 @@#include "util/evsel.h" #include "ui/helpline.h" #include <inttypes.h> +#include <signal.h> enum {ANN_COL__PERCENT ,
tools/perf/ui/gtk/hists.c +1 -0
@@ -6,6 +6,7 @@#include "../helpline.h" #include "../string2.h" #include "gtk.h" +#include <signal.h> #define MAX_COLUMNS 32
tools/perf/util/evlist.c +1 -0
@@ -18,6 +18,7 @@#include "evsel.h" #include "debug.h" #include "asm/bug.h" +#include <signal.h> #include <unistd.h> #include "parse-events.h"
tools/perf/util/evlist.h +1 -0
@@ -11,6 +11,7 @@#include "evsel.h" #include "util.h" #include "auxtrace.h" +#include <signal.h> #include <unistd.h> struct pollfd ;
tools/perf/util/util.c +1 -0
@@ -9,6 +9,7 @@#endif #include <dirent.h> #include <inttypes.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
tools/perf/util/util.h +0 -1
@@ -22,7 +22,6 @@#include <sys/types.h> #include <sys/time.h> #include <time.h> -#include <signal.h> #include <assert.h> #include <utime.h> #include <sys/wait.h>
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 3/22 perf tools: Move units conversion/formatting routines to separate object
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Out of util.h, to disentangle it a bit more.
--- tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/tests/unit_number__scnprintf.c | 2 +- tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/python-ext-sources | 1 + tools/perf/util/units.c | 39 +++++++++++++++++++++++++++++++ tools/perf/util/units.h | 10 ++++++++ tools/perf/util/util.c | 35 --------------------------- tools/perf/util/util.h | 3 --- 11 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 tools/perf/util/units.c create mode 100644 tools/perf/util/units.h
tools/perf/builtin-record.c +1 -0
@@ -38,6 +38,7 @@#include "util/bpf-loader.h" #include "util/trigger.h" #include "util/perf-hooks.h" +#include "util/units.h" #include "asm/bug.h" #include <errno.h>
tools/perf/builtin-report.c +1 -0
@@ -37,6 +37,7 @@#include "arch/common.h" #include "util/time-utils.h" #include "util/auxtrace.h" +#include "util/units.h" #include <dlfcn.h> #include <errno.h>
tools/perf/tests/unit_number__scnprintf.c +1 -1
@@ -2,7 +2,7 @@#include <linux/compiler.h> #include <linux/types.h> #include "tests.h" -#include "util.h" +#include "units.h" #include "debug.h" int test__unit_number__scnprint (int subtest__maybe_unused )
tools/perf/ui/browsers/hists.c +1 -0
@@ -24,6 +24,7 @@#include "annotate.h" #include "srcline.h" #include "string2.h" +#include "units.h" #include "sane_ctype.h"
tools/perf/util/Build +1 -0
@@ -89,6 +89,7 @@ libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o libperf-y += drv_configs.o +libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o
tools/perf/util/evlist.c +1 -0
@@ -17,6 +17,7 @@#include "evlist.h" #include "evsel.h" #include "debug.h" +#include "units.h" #include "asm/bug.h" #include <signal.h> #include <unistd.h>
tools/perf/util/python-ext-sources +1 -0
@@ -27,3 +27,4 @@ util/trace-event.c ../lib/rbtree.c util/string.c util/symbol_fprintf.c +util/units.c
tools/perf/util/units.c new file +39 -0
@@ -0,0 +1,39 @@ +#include "units.h" +#include <inttypes.h> +#include <linux/kernel.h> +#include <linux/time64.h> + +unsigned long convert_unit (unsigned long value,char *unit) +{ + *unit =' ' ; + +if (value >1000 ) { + value /=1000 ; + *unit ='K' ; + } + +if (value >1000 ) { + value /=1000 ; + *unit ='M' ; + } + +if (value >1000 ) { + value /=1000 ; + *unit ='G' ; + } + +return value; +} + +int unit_number__scnprintf (char *buf,size_t size,u64 n) +{ +char unit[4 ] ="BKMG" ; +int i =0 ; + +while (((n /1024 ) >1 ) && (i <3 )) { + n /=1024 ; + i++; + } + +return scnprintf (buf, size,"%" PRIu64"%c" , n, unit[i]); +}
tools/perf/util/units.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef PERF_UNIT_H +#define PERF_UNIT_H + +#include <stddef.h> +#include <linux/types.h> + +unsigned long convert_unit (unsigned long value,char *unit); +int unit_number__scnprintf (char *buf,size_t size,u64 n); + +#endif /* PERF_UNIT_H */
tools/perf/util/util.c +0 -35
@@ -272,28 +272,6 @@ int copyfile(const char *from, const char *to)return copyfile_mode (from, to,0755 ); } -unsigned long convert_unit (unsigned long value,char *unit) -{ - *unit =' ' ; - -if (value >1000 ) { - value /=1000 ; - *unit ='K' ; - } - -if (value >1000 ) { - value /=1000 ; - *unit ='M' ; - } - -if (value >1000 ) { - value /=1000 ; - *unit ='G' ; - } - -return value; -} -static ssize_t ion (bool is_read,int fd,void *buf,size_t n) {void *buf_start = buf;
@@ -731,16 +709,3 @@ int fetch_current_timestamp(char *buf, size_t sz)return 0 ; } - -int unit_number__scnprintf (char *buf,size_t size,u64 n) -{ -char unit[4 ] ="BKMG" ; -int i =0 ; - -while (((n /1024 ) >1 ) && (i <3 )) { - n /=1024 ; - i++; - } - -return scnprintf (buf, size,"%" PRIu64"%c" , n, unit[i]); -}
tools/perf/util/util.h +0 -3
@@ -73,7 +73,6 @@ int copyfile(const char *from, const char *to);int copyfile_mode (const char *from,const char *to,mode_t mode);int copyfile_offset (int fromfd,loff_t from_ofs,int tofd,loff_t to_ofs,u64 size); -unsigned long convert_unit (unsigned long value,char *unit);ssize_t readn (int fd,void *buf,size_t n);ssize_t writen (int fd,void *buf,size_t n);
@@ -134,6 +133,4 @@ int sched_getcpu(void);int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz); -int unit_number__scnprintf (char *buf,size_t size,u64 n); -#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 4/22 perf tools: Move timestamp routines from util.h to time-utils.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We already have a header for time utilities, so use it.
--- tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/util/time-utils.c | 25 +++++++++++++++++++++++++ tools/perf/util/time-utils.h | 7 +++++++ tools/perf/util/util.c | 25 ------------------------- tools/perf/util/util.h | 6 ------ 7 files changed, 35 insertions(+), 31 deletions(-)
tools/perf/builtin-buildid-cache.c +1 -0
@@ -22,6 +22,7 @@#include "util/build-id.h" #include "util/session.h" #include "util/symbol.h" +#include "util/time-utils.h" static int build_id_cache__kcore_buildid (const char *proc_dir,char *sbuildid) {
tools/perf/builtin-kvm.c +1 -0
@@ -24,6 +24,7 @@#ifdef HAVE_TIMERFD_SUPPORT #include <sys/timerfd.h> #endif +#include <sys/time.h> #include <linux/kernel.h> #include <linux/time64.h>
tools/perf/builtin-record.c +1 -0
@@ -38,6 +38,7 @@#include "util/bpf-loader.h" #include "util/trigger.h" #include "util/perf-hooks.h" +#include "util/time-utils.h" #include "util/units.h" #include "asm/bug.h"
tools/perf/util/time-utils.c +25 -0
@@ -117,3 +117,28 @@ bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp)return false; } + +int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz) +{ +u64 sec = timestamp /NSEC_PER_SEC ; +u64 usec = (timestamp %NSEC_PER_SEC ) /NSEC_PER_USEC ; + +return scnprintf (buf, sz,"%" PRIu64".%06" PRIu64, sec, usec); +} + +int fetch_current_timestamp (char *buf,size_t sz) +{ +struct timeval tv; +struct tm tm; +char dt[32 ]; + +if (gettimeofday (&tv,NULL ) || !localtime_r (&tv.tv_sec, &tm)) +return -1 ; + +if (!strftime (dt,sizeof (dt),"%Y%m%d%H%M%S" , &tm)) +return -1 ; + +scnprintf (buf, sz,"%s%02u" , dt, (unsigned )tv.tv_usec /10000 ); + +return 0 ; +}
tools/perf/util/time-utils.h +7 -0
@@ -1,6 +1,9 @@#ifndef _TIME_UTILS_H_#define _TIME_UTILS_H_ +#include <stddef.h> +#include <linux/types.h> +struct perf_time_interval {u64 start, end; };
@@ -11,4 +14,8 @@ int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr);bool perf_time__skip_sample (struct perf_time_interval *ptime,u64 timestamp); +int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz); + +int fetch_current_timestamp (char *buf,size_t sz); +#endif
tools/perf/util/util.c +0 -25
@@ -381,14 +381,6 @@ void sighandler_dump_stack(int sig)raise (sig); } -int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz) -{ -u64 sec = timestamp /NSEC_PER_SEC ; -u64 usec = (timestamp %NSEC_PER_SEC ) /NSEC_PER_USEC ; - -return scnprintf (buf, sz,"%" PRIu64".%06" PRIu64, sec, usec); -} -unsigned long parse_tag_value (const char *str,struct parse_tag *tags) {struct parse_tag *i = tags;
@@ -692,20 +684,3 @@ const char *perf_tip(const char *dirpath)return tip; } - -int fetch_current_timestamp (char *buf,size_t sz) -{ -struct timeval tv; -struct tm tm; -char dt[32 ]; - -if (gettimeofday (&tv,NULL ) || !localtime_r (&tv.tv_sec, &tm)) -return -1 ; - -if (!strftime (dt,sizeof (dt),"%Y%m%d%H%M%S" , &tm)) -return -1 ; - -scnprintf (buf, sz,"%s%02u" , dt, (unsigned )tv.tv_usec /10000 ); - -return 0 ; -}
tools/perf/util/util.h +0 -6
@@ -20,10 +20,7 @@#include <limits.h> #include <sys/param.h> #include <sys/types.h> -#include <sys/time.h> -#include <time.h> #include <assert.h> -#include <utime.h> #include <sys/wait.h> #include <poll.h> #include <sys/socket.h>
@@ -125,12 +122,9 @@ int fetch_kernel_version(unsigned int *puint,#define KVER_PARAM (x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)const char *perf_tip (const char *dirpath); -int fetch_current_timestamp (char *buf,size_t sz);#ifndef HAVE_SCHED_GETCPU_SUPPORT int sched_getcpu (void );#endif -int timestamp__scnprintf_usec (u64 timestamp,char *buf,size_t sz); -#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 5/22 perf kvm: Make function only used by 'perf kvm' static
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
No need to have this polluting util.h, it was polluted enough already.
--- tools/perf/builtin-kvm.c | 14 ++++++++++++++ tools/perf/util/util.c | 14 -------------- tools/perf/util/util.h | 1 - 3 files changed, 14 insertions(+), 15 deletions(-)
tools/perf/builtin-kvm.c +14 -0
@@ -36,6 +36,20 @@#include <pthread.h> #include <math.h> +static const char *get_filename_for_perf_kvm (void ) +{ +const char *filename; + +if (perf_host && !perf_guest) + filename =strdup ("perf.data.host" ); +else if (!perf_host && perf_guest) + filename =strdup ("perf.data.guest" ); +else + filename =strdup ("perf.data.kvm" ); + +return filename; +} +#ifdef HAVE_KVM_STAT_SUPPORT #include "util/kvm-stat.h"
tools/perf/util/util.c +0 -14
@@ -496,20 +496,6 @@ int parse_callchain_record(const char *arg, struct callchain_param *param)return ret; } -const char *get_filename_for_perf_kvm (void ) -{ -const char *filename; - -if (perf_host && !perf_guest) - filename =strdup ("perf.data.host" ); -else if (!perf_host && perf_guest) - filename =strdup ("perf.data.guest" ); -else - filename =strdup ("perf.data.kvm" ); - -return filename; -} -int perf_event_paranoid (void ) {int value;
tools/perf/util/util.h +0 -1
@@ -100,7 +100,6 @@ int perf_event_paranoid(void);void mem_bswap_64 (void *src,int byte_size);void mem_bswap_32 (void *src,int byte_size); -const char *get_filename_for_perf_kvm (void );bool find_process (const char *name);#ifdef HAVE_ZLIB_SUPPORT
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 6/22 perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Two more out of util.h.
--- tools/perf/util/debug.c | 32 +++++++++++++++++++++++++++++++- tools/perf/util/debug.h | 3 +++ tools/perf/util/util.c | 31 ------------------------------- tools/perf/util/util.h | 3 --- 4 files changed, 34 insertions(+), 35 deletions(-)
tools/perf/util/debug.c +31 -1
@@ -8,7 +8,9 @@#include <stdio.h> #include <api/debug.h> #include <linux/time64.h> - +#ifdef HAVE_BACKTRACE_SUPPORT +#include <execinfo.h> +#endif #include "cache.h" #include "color.h" #include "event.h"
@@ -248,3 +250,31 @@ void perf_debug_setup(void) {libapi_set_print (pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper); } + +/* Obtain a backtrace and print it to stdout. */ +#ifdef HAVE_BACKTRACE_SUPPORT +void dump_stack (void ) +{ +void *array[16 ]; +size_t size =backtrace (array,ARRAY_SIZE (array)); +char **strings =backtrace_symbols (array, size); +size_t i; + +printf ("Obtained %zd stack frames.\n" , size); + +for (i =0 ; i < size; i++) +printf ("%s\n" , strings[i]); + +free (strings); +} +#else +void dump_stack (void ) {} +#endif + +void sighandler_dump_stack (int sig) +{ +psignal (sig,"perf" ); +dump_stack (); +signal (sig,SIG_DFL ); +raise (sig); +}
tools/perf/util/debug.h +3 -0
@@ -56,4 +56,7 @@ int perf_debug_option(const char *str);void perf_debug_setup (void );int perf_quiet_option (void ); +void dump_stack (void ); +void sighandler_dump_stack (int sig); +#endif /* __PERF_DEBUG_H */
tools/perf/util/util.c +0 -31
@@ -4,9 +4,6 @@#include <api/fs/fs.h> #include <sys/mman.h> #include <sys/utsname.h> -#ifdef HAVE_BACKTRACE_SUPPORT -#include <execinfo.h> -#endif #include <dirent.h> #include <inttypes.h> #include <signal.h>
@@ -353,34 +350,6 @@ int hex2u64(const char *ptr, u64 *long_val)return p - ptr; } -/* Obtain a backtrace and print it to stdout. */ -#ifdef HAVE_BACKTRACE_SUPPORT -void dump_stack (void ) -{ -void *array[16 ]; -size_t size =backtrace (array,ARRAY_SIZE (array)); -char **strings =backtrace_symbols (array, size); -size_t i; - -printf ("Obtained %zd stack frames.\n" , size); - -for (i =0 ; i < size; i++) -printf ("%s\n" , strings[i]); - -free (strings); -} -#else -void dump_stack (void ) {} -#endif - -void sighandler_dump_stack (int sig) -{ -psignal (sig,"perf" ); -dump_stack (); -signal (sig,SIG_DFL ); -raise (sig); -} -unsigned long parse_tag_value (const char *str,struct parse_tag *tags) {struct parse_tag *i = tags;
tools/perf/util/util.h +0 -3
@@ -80,9 +80,6 @@ void event_attr_init(struct perf_event_attr *attr);size_t hex_width (u64 v);int hex2u64 (const char *ptr,u64 *val); -void dump_stack (void ); -void sighandler_dump_stack (int sig); -extern unsigned int page_size;extern int cacheline_size;extern int sysctl_perf_event_max_stack;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 7/22 perf mem: Fix display of data source snoop indication
In reply to Arnaldo Carvalho de MeloFrom: Andi Kleen <[email protected]>
'perf mem report' doesn't display the data source snoop indication correctly.
In the kernel API the definition is:
#define PERF_MEM_SNOOP_NONE 0x02 /* no snoop */ #define PERF_MEM_SNOOP_HIT 0x04 /* snoop hit */ #define PERF_MEM_SNOOP_MISS 0x08 /* snoop miss */
but the table used by the perf tools exchanged "Hit" and "Miss":
"None",
"Miss",
"Hit",Fix the table in perf.
--- tools/perf/util/mem-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/mem-events.c +1 -1
@@ -206,8 +206,8 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)static const char *const snoop_access[] = {"N/A" ,"None" , -"Miss" ,"Hit" , +"Miss" ,"HitM" , };
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 8/22 perf tools: Add compress.h for the *_decompress_to_file() headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Out of util.h, the implementations were already in separate files, that are built conditionally.
--- tools/perf/util/compress.h | 12 ++++++++++++ tools/perf/util/dso.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/util.h | 8 -------- tools/perf/util/zlib.c | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 tools/perf/util/compress.h
tools/perf/util/compress.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef PERF_COMPRESS_H +#define PERF_COMPRESS_H + +#ifdef HAVE_ZLIB_SUPPORT +int gzip_decompress_to_file (const char *input,int output_fd); +#endif + +#ifdef HAVE_LZMA_SUPPORT +int lzma_decompress_to_file (const char *input,int output_fd); +#endif + +#endif /* PERF_COMPRESS_H */
tools/perf/util/dso.c +1 -0
@@ -3,6 +3,7 @@#include <sys/time.h> #include <sys/resource.h> #include <errno.h> +#include "compress.h" #include "path.h" #include "symbol.h" #include "dso.h"
tools/perf/util/lzma.c +1 -0
@@ -2,6 +2,7 @@#include <lzma.h> #include <stdio.h> #include <linux/compiler.h> +#include "compress.h" #include "util.h" #include "debug.h"
tools/perf/util/util.h +0 -8
@@ -99,14 +99,6 @@ void mem_bswap_32(void *src, int byte_size);bool find_process (const char *name); -#ifdef HAVE_ZLIB_SUPPORT -int gzip_decompress_to_file (const char *input,int output_fd); -#endif - -#ifdef HAVE_LZMA_SUPPORT -int lzma_decompress_to_file (const char *input,int output_fd); -#endif -int get_stack_size (const char *str,unsigned long *_size); int fetch_kernel_version(unsigned int *puint,
tools/perf/util/zlib.c +1 -0
@@ -4,6 +4,7 @@#include <sys/mman.h> #include <zlib.h> +#include "util/compress.h" #include "util/util.h" #include "util/debug.h"
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 9/22 perf callchain: Move callchain specific routines from util.[ch]
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Where they belong, no point in leaving those in the generic "util" files.
--- tools/perf/util/callchain.c | 103 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/python.c | 13 ++++++ tools/perf/util/util.c | 104 -------------------------------------------- tools/perf/util/util.h | 4 -- 4 files changed, 116 insertions(+), 108 deletions(-)
tools/perf/util/callchain.c +103 -0
@@ -24,6 +24,21 @@#include "machine.h" #include "callchain.h" +#define CALLCHAIN_PARAM_DEFAULT \ + .mode = CHAIN_GRAPH_ABS, \ + .min_percent = 0.5, \ + .order = ORDER_CALLEE, \ + .key = CCKEY_FUNCTION, \ + .value = CCVAL_PERCENT, \ + +struct callchain_param callchain_param = { +CALLCHAIN_PARAM_DEFAULT +}; + +struct callchain_param callchain_param_default = { +CALLCHAIN_PARAM_DEFAULT +}; + __threadstruct callchain_cursor callchain_cursor;int parse_callchain_record_opt (const char *arg,struct callchain_param *param)
@@ -113,6 +128,32 @@ static int parse_callchain_value(const char *value)return -1 ; } +static int get_stack_size (const char *str,unsigned long *_size) +{ +char *endptr; +unsigned long size; +unsigned long max_size =round_down (USHRT_MAX ,sizeof (u64)); + + size =strtoul (str, &endptr,0 ); + +do { +if (*endptr) +break ; + + size =round_up (size,sizeof (u64)); +if (!size || size > max_size) +break ; + + *_size = size; +return 0 ; + + }while (0 ); + +pr_err ("callchain: Incorrect stack dump size (max %ld): %s\n" , + max_size, str); +return -1 ; +} +static int __parse_callchain_report_opt (const char *arg,bool allow_record_opt) {
@@ -196,6 +237,68 @@ int parse_callchain_top_opt(const char *arg)return __parse_callchain_report_opt (arg, true); } +int parse_callchain_record (const char *arg,struct callchain_param *param) +{ +char *tok, *name, *saveptr =NULL ; +char *buf; +int ret =-1 ; + +/* We need buffer that we know we can write to. */ + buf =malloc (strlen (arg) +1 ); +if (!buf) +return -ENOMEM ; + +strcpy (buf, arg); + + tok =strtok_r ((char *)buf,"," , &saveptr); + name = tok ? : (char *)buf; + +do { +/* Framepointer style */ +if (!strncmp (name,"fp" ,sizeof ("fp" ))) { +if (!strtok_r (NULL ,"," , &saveptr)) { + param->record_mode =CALLCHAIN_FP ; + ret =0 ; + }else +pr_err ("callchain: No more arguments " +"needed for --call-graph fp\n" ); +break ; + +/* Dwarf style */ + }else if (!strncmp (name,"dwarf" ,sizeof ("dwarf" ))) { +const unsigned long default_stack_dump_size =8192 ; + + ret =0 ; + param->record_mode =CALLCHAIN_DWARF ; + param->dump_size = default_stack_dump_size; + + tok =strtok_r (NULL ,"," , &saveptr); +if (tok) { +unsigned long size =0 ; + + ret =get_stack_size (tok, &size); + param->dump_size = size; + } + }else if (!strncmp (name,"lbr" ,sizeof ("lbr" ))) { +if (!strtok_r (NULL ,"," , &saveptr)) { + param->record_mode =CALLCHAIN_LBR ; + ret =0 ; + }else +pr_err ("callchain: No more arguments " +"needed for --call-graph lbr\n" ); +break ; + }else { +pr_err ("callchain: Unknown --call-graph option " +"value: %s\n" , arg); +break ; + } + + }while (0 ); + +free (buf); +return ret; +} +int perf_callchain_config (const char *var,const char *value) {char *endptr;
tools/perf/util/python.c +13 -0
@@ -4,6 +4,7 @@#include <poll.h> #include <linux/err.h> #include "evlist.h" +#include "callchain.h" #include "evsel.h" #include "event.h" #include "cpumap.h"
@@ -11,6 +12,18 @@#include "thread_map.h" /* +* Provide these two so that we don't have to link against callchain.c and +* start dragging hist.c, etc. +*/ +struct callchain_param callchain_param; + +int parse_callchain_record (const char *arg__maybe_unused , +struct callchain_param *param__maybe_unused ) +{ +return 0 ; +} + +/* * Support debug printing even though util/debug.c is not linked. That means * implementing 'verbose' and 'eprintf'. */
tools/perf/util/util.c +0 -104
118 lines not on this page · raw message
tools/perf/util/util.h +0 -4
@@ -17,7 +17,6 @@#include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <limits.h> #include <sys/param.h> #include <sys/types.h> #include <assert.h>
@@ -25,7 +24,6 @@#include <poll.h> #include <sys/socket.h> #include <sys/ioctl.h> -#include <linux/kernel.h> #include <linux/types.h> extern char buildid_dir[];
@@ -99,8 +97,6 @@ void mem_bswap_32(void *src, int byte_size);bool find_process (const char *name); -int get_stack_size (const char *str,unsigned long *_size); -int fetch_kernel_version (unsigned int *puint,char *str,size_t str_sz);#define KVER_VERSION (x) (((x) >> 16) & 0xff)
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 10/22 perf tools: Include sys/param.h where needed
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As it is going away from util.h, where it is not needed.
This is mostly for things like MAXPATHLEN, MAX() and MIN(), these later two probably should go away in favor of its kernel sources replacements.
--- tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/tests/attr.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/util/config.c | 1 + tools/perf/util/header.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/util.h | 1 - 9 files changed, 8 insertions(+), 1 deletion(-)
tools/perf/builtin-c2c.c +1 -0
@@ -15,6 +15,7 @@#include <linux/kernel.h> #include <linux/stringify.h> #include <asm/bug.h> +#include <sys/param.h> #include "util.h" #include "debug.h" #include "builtin.h"
tools/perf/builtin-script.c +1 -0
@@ -36,6 +36,7 @@#include <errno.h> #include <inttypes.h> #include <signal.h> +#include <sys/param.h> #include "sane_ctype.h"
tools/perf/tests/attr.c +1 -0
@@ -24,6 +24,7 @@#include <stdio.h> #include <linux/types.h> #include <linux/kernel.h> +#include <sys/param.h> #include "../perf.h" #include "util.h" #include <subcmd/exec-cmd.h>
tools/perf/tests/code-reading.c +1 -0
@@ -6,6 +6,7 @@#include <unistd.h> #include <stdio.h> #include <string.h> +#include <sys/param.h> #include "parse-events.h" #include "evlist.h"
tools/perf/util/config.c +1 -0
@@ -9,6 +9,7 @@* */ #include <errno.h> +#include <sys/param.h> #include "util.h" #include "cache.h" #include <subcmd/exec-cmd.h>
tools/perf/util/header.c +1 -0
@@ -2,6 +2,7 @@#include <inttypes.h> #include "util.h" #include "string2.h" +#include <sys/param.h> #include <sys/types.h> #include <byteswap.h> #include <unistd.h>
tools/perf/util/hist.c +1 -0
@@ -12,6 +12,7 @@#include "ui/progress.h" #include <errno.h> #include <math.h> +#include <sys/param.h> static bool hists__filter_entry_by_dso (struct hists *hists,struct hist_entry *he);
tools/perf/util/parse-events.c +1 -0
@@ -2,6 +2,7 @@#include <linux/err.h> #include <dirent.h> #include <errno.h> +#include <sys/param.h> #include "term.h" #include "../perf.h" #include "evlist.h"
tools/perf/util/util.h +0 -1
@@ -17,7 +17,6 @@#include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <sys/param.h> #include <sys/types.h> #include <assert.h> #include <sys/wait.h>
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 11/22 perf tools: Remove a few more needless includes from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/util.h | 4 ---- 1 file changed, 4 deletions(-)
tools/perf/util/util.h +0 -4
@@ -10,18 +10,14 @@#include <unistd.h> #include <stdio.h> #include <sys/stat.h> -#include <sys/statfs.h> #include <fcntl.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <sys/types.h> -#include <assert.h> #include <sys/wait.h> #include <poll.h> -#include <sys/socket.h> #include <sys/ioctl.h> #include <linux/types.h>
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 12/22 perf tools: Remove sys/ioctl.h from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Not needed in this header, added to the places that need 'struct winsize' and the ioctl defines.
--- tools/perf/util/evlist.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/top.h | 2 +- tools/perf/util/util.h | 1 - 5 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/evlist.c +1 -0
@@ -25,6 +25,7 @@#include "parse-events.h" #include <subcmd/parse-options.h> +#include <sys/ioctl.h> #include <sys/mman.h> #include <linux/bitops.h>
tools/perf/util/evsel.c +1 -0
@@ -16,6 +16,7 @@#include <linux/hw_breakpoint.h> #include <linux/perf_event.h> #include <linux/err.h> +#include <sys/ioctl.h> #include <sys/resource.h> #include "asm/bug.h" #include "callchain.h"
tools/perf/util/parse-events.c +1 -0
@@ -2,6 +2,7 @@#include <linux/err.h> #include <dirent.h> #include <errno.h> +#include <sys/ioctl.h> #include <sys/param.h> #include "term.h" #include "../perf.h"
tools/perf/util/top.h +1 -1
@@ -5,7 +5,7 @@#include <linux/types.h> #include <stddef.h> #include <stdbool.h> -#include <termios.h> +#include <sys/ioctl.h> struct perf_evlist ;struct perf_evsel ;
tools/perf/util/util.h +0 -1
@@ -18,7 +18,6 @@#include <string.h> #include <sys/wait.h> #include <poll.h> -#include <sys/ioctl.h> #include <linux/types.h> extern char buildid_dir[];
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 13/22 perf tools: Remove string.h from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Not needed in this header, added to the places that need strdup, strcmp and a few other prototypes.
--- tools/perf/util/comm.c | 1 + tools/perf/util/namespaces.c | 1 + tools/perf/util/util.h | 1 - tools/perf/util/xyarray.c | 2 ++ 4 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/comm.c +1 -0
@@ -3,6 +3,7 @@#include <errno.h> #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <linux/refcount.h> struct comm_str {
tools/perf/util/namespaces.c +1 -0
@@ -11,6 +11,7 @@#include "event.h" #include <stdlib.h> #include <stdio.h> +#include <string.h> struct namespaces *namespaces__new (struct namespaces_event *event) {
tools/perf/util/util.h +0 -1
@@ -15,7 +15,6 @@#include <stddef.h> #include <stdlib.h> #include <stdarg.h> -#include <string.h> #include <sys/wait.h> #include <poll.h> #include <linux/types.h>
tools/perf/util/xyarray.c +2 -0
@@ -1,5 +1,7 @@#include "xyarray.h" #include "util.h" +#include <stdlib.h> +#include <string.h> struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size) {
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 14/22 perf tools: Remove stale prototypes from builtin.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Some, like prune_packed_objects() are clearly git specific, others don't have implementations and some are used in just one place, make them static.
--- tools/perf/builtin.h | 4 ---- tools/perf/perf.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)
tools/perf/builtin.h +0 -4
@@ -2,16 +2,12 @@#define BUILTIN_H #include "util/util.h" -#include "util/strbuf.h" extern const char perf_usage_string[];extern const char perf_more_info_string[];void list_common_cmds_help (void );const char *help_unknown_cmd (const char *cmd); -void prune_packed_objects (int ); -int read_line_with_nul (char *buf,int size,FILE *file); -int check_pager_config (const char *cmd);int cmd_annotate (int argc,const char **argv);int cmd_bench (int argc,const char **argv);
tools/perf/perf.c +1 -1
@@ -91,7 +91,7 @@ static int pager_command_config(const char *var, const char *value, void *data) }/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ -int check_pager_config (const char *cmd) +static int check_pager_config (const char *cmd) {int err;struct pager_config c;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 15/22 perf tools: Remove string.h, unistd.h and sys/stat.h from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Not needed in this header, added to the places that need FILE, putchar(), access() and a few other prototypes.
--- tools/lib/subcmd/help.h | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm64/util/dwarf-regs.c | 1 + tools/perf/builtin-help.c | 4 ++++ tools/perf/builtin-mem.c | 3 +++ tools/perf/builtin-report.c | 3 +++ tools/perf/builtin-script.c | 3 +++ tools/perf/builtin-stat.c | 3 +++ tools/perf/builtin-version.c | 3 ++- tools/perf/perf.c | 3 +++ tools/perf/tests/attr.c | 3 +++ tools/perf/tests/bpf.c | 2 ++ tools/perf/tests/parse-events.c | 3 +++ tools/perf/util/build-id.c | 2 ++ tools/perf/util/color.h | 2 ++ tools/perf/util/config.c | 3 +++ tools/perf/util/dso.c | 3 +++ tools/perf/util/event.c | 3 +++ tools/perf/util/header.c | 3 +++ tools/perf/util/machine.c | 3 +++ tools/perf/util/pmu.c | 1 + tools/perf/util/probe-file.c | 3 +++ tools/perf/util/strlist.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/util.h | 3 --- 25 files changed, 57 insertions(+), 4 deletions(-)
tools/lib/subcmd/help.h +1 -0
@@ -2,6 +2,7 @@#define __SUBCMD_HELP_H#include <sys/types.h> +#include <stdio.h> struct cmdnames {size_t alloc;
tools/perf/arch/arm/util/cs-etm.c +1 -0
@@ -33,6 +33,7 @@#include "../../util/cs-etm.h" #include <stdlib.h> +#include <sys/stat.h> #define ENABLE_SINK_MAX 128#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/"
tools/perf/arch/arm64/util/dwarf-regs.c +1 -0
@@ -10,6 +10,7 @@#include <errno.h> #include <stddef.h> +#include <string.h> #include <dwarf-regs.h> #include <linux/ptrace.h> /* for struct user_pt_regs */ #include <linux/stringify.h>
tools/perf/builtin-help.c +4 -0
@@ -14,6 +14,10 @@#include "util/debug.h" #include <linux/kernel.h> #include <errno.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> static struct man_viewer_list { struct man_viewer_list *next;
tools/perf/builtin-mem.c +3 -0
@@ -1,4 +1,7 @@#include <inttypes.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "builtin.h" #include "perf.h"
tools/perf/builtin-report.c +3 -0
@@ -46,6 +46,9 @@#include <signal.h> #include <linux/bitmap.h> #include <linux/stringify.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> struct report {struct perf_tool tool;
tools/perf/builtin-script.c +3 -0
@@ -37,6 +37,9 @@#include <inttypes.h> #include <signal.h> #include <sys/param.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "sane_ctype.h"
tools/perf/builtin-stat.c +3 -0
@@ -76,6 +76,9 @@#include <inttypes.h> #include <locale.h> #include <math.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "sane_ctype.h"
tools/perf/builtin-version.c +2 -1
@@ -1,6 +1,7 @@ -#include "util/util.h" #include "builtin.h" #include "perf.h" +#include <linux/compiler.h> +#include <stdio.h> int cmd_version (int argc__maybe_unused ,const char **argv__maybe_unused ) {
tools/perf/perf.c +3 -0
@@ -24,6 +24,9 @@#include <signal.h> #include <stdlib.h> #include <time.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <linux/kernel.h> const char perf_usage_string[] =
tools/perf/tests/attr.c +3 -0
@@ -25,6 +25,9 @@#include <linux/types.h> #include <linux/kernel.h> #include <sys/param.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "../perf.h" #include "util.h" #include <subcmd/exec-cmd.h>
tools/perf/tests/bpf.c +2 -0
@@ -1,6 +1,8 @@#include <errno.h> #include <stdio.h> #include <sys/epoll.h> +#include <sys/types.h> +#include <sys/stat.h> #include <util/util.h> #include <util/bpf-loader.h> #include <util/evlist.h>
tools/perf/tests/parse-events.c +3 -0
@@ -7,6 +7,9 @@#include "util.h" #include <dirent.h> #include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <linux/kernel.h> #include <linux/hw_breakpoint.h> #include <api/fs/fs.h>
tools/perf/util/build-id.c +2 -0
@@ -10,6 +10,8 @@#include <dirent.h> #include <errno.h> #include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> #include "build-id.h" #include "event.h" #include "symbol.h"
tools/perf/util/color.h +2 -0
@@ -1,6 +1,8 @@#ifndef __PERF_COLOR_H#define __PERF_COLOR_H +#include <stdio.h> +/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ #define COLOR_MAXLEN 24
tools/perf/util/config.c +3 -0
@@ -16,6 +16,9 @@#include "util/hist.h" /* perf_hist_config */ #include "util/llvm-utils.h" /* perf_llvm_config */ #include "config.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "sane_ctype.h"
tools/perf/util/dso.c +3 -0
@@ -2,6 +2,9 @@#include <linux/kernel.h> #include <sys/time.h> #include <sys/resource.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <errno.h> #include "compress.h" #include "path.h"
tools/perf/util/event.c +3 -0
@@ -3,6 +3,9 @@#include <inttypes.h> #include <linux/kernel.h> #include <linux/types.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ #include <api/fs/fs.h> #include "event.h"
tools/perf/util/header.c +3 -0
@@ -11,7 +11,10 @@#include <linux/list.h> #include <linux/kernel.h> #include <linux/bitops.h> +#include <sys/stat.h> +#include <sys/types.h> #include <sys/utsname.h> +#include <unistd.h> #include "evlist.h" #include "evsel.h"
tools/perf/util/machine.c +3 -0
@@ -14,6 +14,9 @@#include "thread.h" #include "vdso.h" #include <stdbool.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "unwind.h" #include "linux/hash.h" #include "asm/bug.h"
tools/perf/util/pmu.c +1 -0
@@ -2,6 +2,7 @@#include <linux/compiler.h> #include <sys/types.h> #include <errno.h> +#include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdbool.h>
tools/perf/util/probe-file.c +3 -0
@@ -15,7 +15,10 @@* */ #include <errno.h> +#include <sys/stat.h> +#include <sys/types.h> #include <sys/uio.h> +#include <unistd.h> #include "util.h" #include "event.h" #include "strlist.h"
tools/perf/util/strlist.c +1 -0
@@ -10,6 +10,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> static struct rb_node *strlist__node_new (struct rblist *rblist,const void *entry)
tools/perf/util/util.c +1 -0
@@ -3,6 +3,7 @@#include "debug.h" #include <api/fs/fs.h> #include <sys/mman.h> +#include <sys/stat.h> #include <sys/utsname.h> #include <dirent.h> #include <inttypes.h>
tools/perf/util/util.h +0 -3
@@ -7,9 +7,6 @@#define _DEFAULT_SOURCE 1#define HAS_BOOL -#include <unistd.h> -#include <stdio.h> -#include <sys/stat.h> #include <fcntl.h> #include <stdbool.h> #include <stddef.h>
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 16/22 perf tools: Remove poll.h and wait.h from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Not needed in this header, added to the places that need poll(), wait() and a few other prototypes.
--- tools/perf/arch/x86/tests/intel-cqm.c | 1 + tools/perf/builtin-ftrace.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-record.c | 2 ++ tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/util/debug.c | 1 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/llvm-utils.c | 1 + tools/perf/util/util.h | 2 -- 12 files changed, 12 insertions(+), 2 deletions(-)
tools/perf/arch/x86/tests/intel-cqm.c +1 -0
@@ -8,6 +8,7 @@#include <signal.h> #include <sys/mman.h> +#include <sys/wait.h> #include <errno.h> #include <string.h>
tools/perf/builtin-ftrace.c +1 -0
@@ -13,6 +13,7 @@#include <unistd.h> #include <signal.h> #include <fcntl.h> +#include <poll.h> #include "debug.h" #include <subcmd/parse-options.h>
tools/perf/builtin-kvm.c +1 -0
@@ -30,6 +30,7 @@#include <linux/time64.h> #include <errno.h> #include <inttypes.h> +#include <poll.h> #include <termios.h> #include <semaphore.h> #include <signal.h>
tools/perf/builtin-record.c +2 -0
@@ -44,10 +44,12 @@#include <errno.h> #include <inttypes.h> +#include <poll.h> #include <unistd.h> #include <sched.h> #include <signal.h> #include <sys/mman.h> +#include <sys/wait.h> #include <asm/bug.h> #include <linux/time64.h>
tools/perf/builtin-stat.c +1 -0
@@ -78,6 +78,7 @@#include <math.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/wait.h> #include <unistd.h> #include "sane_ctype.h"
tools/perf/builtin-trace.c +1 -0
@@ -45,6 +45,7 @@#include <errno.h> #include <inttypes.h> #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ +#include <poll.h> #include <signal.h> #include <stdlib.h> #include <string.h>
tools/perf/tests/builtin-test.c +1 -0
@@ -6,6 +6,7 @@#include <errno.h> #include <unistd.h> #include <string.h> +#include <sys/wait.h> #include "builtin.h" #include "hist.h" #include "intlist.h"
tools/perf/tests/event-times.c +1 -0
@@ -2,6 +2,7 @@#include <errno.h> #include <inttypes.h> #include <string.h> +#include <sys/wait.h> #include "tests.h" #include "evlist.h" #include "evsel.h"
tools/perf/util/debug.c +1 -0
@@ -6,6 +6,7 @@#include <string.h> #include <stdarg.h> #include <stdio.h> +#include <sys/wait.h> #include <api/debug.h> #include <linux/time64.h> #ifdef HAVE_BACKTRACE_SUPPORT
tools/perf/util/help-unknown-cmd.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include <poll.h> #include <stdio.h> #include <subcmd/help.h> #include "../builtin.h"
tools/perf/util/llvm-utils.c +1 -0
@@ -12,6 +12,7 @@#include "llvm-utils.h" #include "config.h" #include "util.h" +#include <sys/wait.h> #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
tools/perf/util/util.h +0 -2
@@ -12,8 +12,6 @@#include <stddef.h> #include <stdlib.h> #include <stdarg.h> -#include <sys/wait.h> -#include <poll.h> #include <linux/types.h> extern char buildid_dir[];
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 17/22 perf tools: Add the right header to obtain PERF_ALIGN()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The util/event.h header needs PERF_ALIGN(), but wasn't including linux/kernel.h, where it is defined, instead it was getting it by luck by including map.h, which it doesn't need at all.
Fix it by including the right header.
--- tools/perf/util/event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.h +1 -1
@@ -3,9 +3,9 @@#include <limits.h> #include <stdio.h> +#include <linux/kernel.h> #include "../perf.h" -#include "map.h" #include "build-id.h" #include "perf_regs.h"
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 18/22 perf tools: Use just forward declarations for struct thread where possible
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Removing various instances of unnecessary includes, reducing the maze of header dependencies.
--- tools/perf/arch/arm/util/unwind-libdw.c | 1 + tools/perf/arch/x86/util/unwind-libdw.c | 1 + tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-timechart.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/session.h | 3 +-- tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 3 ++- tools/perf/util/unwind-libdw.h | 6 ++++-- 15 files changed, 19 insertions(+), 5 deletions(-)
tools/perf/arch/arm/util/unwind-libdw.c +1 -0
@@ -1,6 +1,7 @@#include <elfutils/libdwfl.h> #include "../../util/unwind-libdw.h" #include "../../util/perf_regs.h" +#include "../../util/event.h" bool libdw__arch_set_initial_registers (Dwfl_Thread *thread,void *arg) {
tools/perf/arch/x86/util/unwind-libdw.c +1 -0
@@ -1,6 +1,7 @@#include <elfutils/libdwfl.h> #include "../../util/unwind-libdw.h" #include "../../util/perf_regs.h" +#include "../../util/event.h" bool libdw__arch_set_initial_registers (Dwfl_Thread *thread,void *arg) {
tools/perf/builtin-c2c.c +1 -0
@@ -32,6 +32,7 @@#include <asm/bug.h> #include "ui/browsers/hists.h" #include "evlist.h" +#include "thread.h" struct c2c_hists {struct hists hists;
tools/perf/builtin-inject.c +1 -0
@@ -18,6 +18,7 @@#include "util/data.h" #include "util/auxtrace.h" #include "util/jit.h" +#include "util/thread.h" #include <subcmd/parse-options.h>
tools/perf/builtin-mem.c +1 -0
@@ -12,6 +12,7 @@#include "util/data.h" #include "util/mem-events.h" #include "util/debug.h" +#include "util/symbol.h" #define MEM_OPERATION_LOAD 0x1#define MEM_OPERATION_STORE 0x2
tools/perf/builtin-timechart.c +1 -0
@@ -29,6 +29,7 @@#include <linux/rbtree.h> #include <linux/time64.h> #include "util/symbol.h" +#include "util/thread.h" #include "util/callchain.h" #include "perf.h"
tools/perf/ui/browsers/hists.c +1 -0
@@ -14,6 +14,7 @@#include "../../util/sort.h" #include "../../util/util.h" #include "../../util/top.h" +#include "../../util/thread.h" #include "../../arch/common.h" #include "../browsers/hists.h"
tools/perf/ui/stdio/hist.c +1 -0
@@ -6,6 +6,7 @@#include "../../util/evsel.h" #include "../../util/srcline.h" #include "../../util/string2.h" +#include "../../util/thread.h" #include "../../util/sane_ctype.h" static size_t callchain__fprintf_left_margin (FILE *fp,int left_margin)
tools/perf/util/build-id.c +1 -0
@@ -15,6 +15,7 @@#include "build-id.h" #include "event.h" #include "symbol.h" +#include "thread.h" #include <linux/kernel.h> #include "debug.h" #include "session.h"
tools/perf/util/hist.c +1 -0
@@ -9,6 +9,7 @@#include "evsel.h" #include "annotate.h" #include "srcline.h" +#include "thread.h" #include "ui/progress.h" #include <errno.h> #include <math.h>
tools/perf/util/session.c +1 -0
@@ -19,6 +19,7 @@#include "perf_regs.h" #include "asm/bug.h" #include "auxtrace.h" +#include "thread.h" #include "thread-stack.h" #include "stat.h"
tools/perf/util/session.h +1 -2
@@ -5,8 +5,6 @@#include "event.h" #include "header.h" #include "machine.h" -#include "symbol.h" -#include "thread.h" #include "data.h" #include "ordered-events.h" #include <linux/kernel.h>
@@ -14,6 +12,7 @@#include <linux/perf_event.h> struct ip_callchain ; +struct symbol ;struct thread ;struct auxtrace ;
tools/perf/util/sort.c +1 -0
@@ -6,6 +6,7 @@#include "hist.h" #include "comm.h" #include "symbol.h" +#include "thread.h" #include "evsel.h" #include "evlist.h" #include "strlist.h"
tools/perf/util/sort.h +2 -1
@@ -21,7 +21,8 @@#include "parse-events.h" #include "hist.h" #include "srcline.h" -#include "thread.h" + +struct thread ;extern regex_t parent_regex;extern const char *sort_order;
tools/perf/util/unwind-libdw.h +4 -2
@@ -2,10 +2,12 @@#define __PERF_UNWIND_LIBDW_H#include <elfutils/libdwfl.h> -#include "event.h" -#include "thread.h" #include "unwind.h" +struct machine ; +struct perf_sample ; +struct thread ; +bool libdw__arch_set_initial_registers (Dwfl_Thread *thread,void *arg);struct unwind_info {
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 19/22 tools: Update asm-generic/mman-common.h copy from the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in the commit Fixes: 3209f68b3ca4 ("statx: Include a mask for stx_attributes in struct statx")
Silencing this perf build warning:
Warning: tools/include/uapi/linux/stat.h differs from kernel
No need to change the statx syscall beautifiers in 'perf trace' at this time.
--- tools/include/uapi/linux/stat.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/include/uapi/linux/stat.h +3 -2
@@ -114,7 +114,7 @@ struct statx {__u64 stx_ino;/* Inode number */ __u64 stx_size;/* File size */ __u64 stx_blocks;/* Number of 512-byte blocks allocated */ -__u64 __spare1[1 ]; +__u64 stx_attributes_mask;/* Mask to show what's supported in stx_attributes */ /* 0x40 */ struct statx_timestamp stx_atime;/* Last access time */ struct statx_timestamp stx_btime;/* File creation time */
@@ -152,9 +152,10 @@ struct statx {#define STATX_BASIC_STATS 0x000007ffU/* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U/* Want/got stx_btime */ #define STATX_ALL 0x00000fffU/* All currently supported flags */ +#define STATX__RESERVED 0x80000000U/* Reserved for future struct statx expansion */ /* -* Attributes to be found in stx_attributes +* Attributes to be found in stx_attributes and masked in stx_attributes_mask. * * These give information about the features or the state of a file that might * be of use to ordinary userspace programs such as GUIs or ls rather than
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 20/22 tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Just a minor fix done in:
--- tools/arch/x86/lib/memcpy_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/arch/x86/lib/memcpy_64.S +1 -1
@@ -286,7 +286,7 @@ ENDPROC(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)
Signature · 1 line
2.9.3
Re: [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
Quoted 18 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Just a minor fix done in:
Fixes 26a37ab319a2 ("x86/mce: Fix copy/paste error in exception table entries")Cc Tony Luck <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/arch/x86/lib/memcpy_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/arch/x86/lib/memcpy_64.S +0
-0
tools/arch/x86/lib/memcpy_64.S ENDPROC(memcpy_mcsafe_unrolled) · line 292
Quoted 8 lines
tools/arch/x86/lib/memcpy_64.S +1
-1@@ -286,7 +286,7 @@ ENDPROC(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)
If we are going to have all these copies of kernel files below "tools/...", perhaps checkpatch could warn people touching one that the other needs the same update?
-Tony
Re: [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
Quoted 23 lines · Tony
Quoted 22 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Just a minor fix done in:
Fixes 26a37ab319a2 ("x86/mce: Fix copy/paste error in exception table entries")Cc Tony Luck <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/arch/x86/lib/memcpy_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/arch/x86/lib/memcpy_64.S +0
-1@@ -286,7 +286,7 @@ ENDPROC(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail)
Quoted 8 lines
tools/arch/x86/lib/memcpy_64.S ENDPROC(memcpy_mcsafe_unrolled) · line 292
Quoted 4 lines
tools/arch/x86/lib/memcpy_64.S +1
-0+ _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)If we are going to have all these copies of kernel files below "
tools/...", perhaps checkpatch could warn people touching one that the other needs the same update?
How would checkpatch know tools hasn't already updated the other?
RE: [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
Quoted 5 lines
Quoted 3 lines
If we are going to have all these copies of kernel files below "
tools/...", perhaps checkpatch could warn people touching one that the other needs the same update?How would checkpatch know tools hasn't already updated the other?
If checkpatch had a list of all the tools copies, it could warn if a patch touched a file without touching the copy.
Not completely ideal because people might update the two files in separate patches in a series (in which case they would see warnings from both patches).
Also means that checkpatch needs the list of copied files ... not sure how often that changes.
-Tony
Re: [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
Quoted 8 lines · Tony
Quoted 5 lines
Quoted 3 lines
If we are going to have all these copies of kernel files below "
tools/...", perhaps checkpatch could warn people touching one that the other needs the same update?How would checkpatch know tools hasn't already updated the other?
If checkpatch had a list of all the tools copies, it could warn if a patch touched a file without touching the copy.
I rather doubt these files are modified simultaneously.
A quick and no doubt incomplete git log -- "tools/*/kernel.h" seems to show little simultaneity.
Quoted 6 lines
Not completely ideal because people might update the two files in separate patches in a series (in which case they would see warnings from both patches).
Also means that checkpatch needs the list of copied files ... not sure how often that changes.
Nor I. Anyway, feel free to propose an actual patch.
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with the kernel
In reply to Luck, TonyEm Mon, Apr 24, 2017 at 01:36:30PM -0700, Luck, Tony escreveu:
Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 5 lines
From: Arnaldo Carvalho de Melo <[email protected]>
Just a minor fix done in:
Fixes 26a37ab319a2 ("x86/mce: Fix copy/paste error in exception table entries")
<SNIP>
Quoted 3 lines
If we are going to have all these copies of kernel files below "
tools/...", perhaps checkpatch could warn people touching one that the other needs the same update?
So, we have tools/perf/check-headers.sh that will warn, when building tools/perf/, if some of the files we get from the kernel is out of synch.
When we see this, we should look to see if the change will entail changes in tools/, if it will drag some other header we don't need, etc.
Sometimes, like in this case, we don't want to pull extra headers, like asm/export.h, so we have this in that check-headers.sh script:
[acme@jouet linux]$ tail -5 tools/perf/check-headers.sh
# diff with extra ignore lines check arch/x86/lib/memcpy_64.S -B -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" check arch/x86/lib/memset_64.S -B -I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" check include/uapi/asm-generic/mman.h -B -I "^#include <\(uapi/\)*asm-generic/mman-common.h>" check include/uapi/linux/mman.h -B -I "^#include <\(uapi/\)*asm/mman.h>" [acme@jouet linux]$
I.e. we want to get as close to what is in the kernel as possible, but with some exceptions.
And we don't want to add more work to the kernel developers, who can continue working as if there is no tools/ in the tree.
For those who want to help tools/, then its just a matter of building perf when doing changes to kernel headers.
We also want these copies because with:
[acme@jouet linux]$ make help | grep perf
perf-tar-src-pkg - Build perf-4.11.0-rc6.tar source tarball
perf-targz-src-pkg - Build perf-4.11.0-rc6.tar.gz source tarball perf-tarbz2-src-pkg - Build perf-4.11.0-rc6.tar.bz2 source tarball perf-tarxz-src-pkg - Build perf-4.11.0-rc6.tar.xz source tarball
[acme@jouet linux]$
We can create tarball with just what is needed to build perf, then get that tarball and move to some other system and build a newer perf to run in some older environment, older kernel, etc.
- Arnaldo
Arnaldo Carvalho de Melo
maintainerPATCH 21/22 tools arch x86: Sync cpufeatures.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To catch changes made in:
90218ac77d05 ("x86/cpufeature: Detect CPUID faulting support")
No changes needed in the tools using this file at this time.
--- tools/arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+)
tools/arch/x86/include/asm/cpufeatures.h +1 -0
@@ -187,6 +187,7 @@* Reuse free bits when adding new feature flags! */ #define X86_FEATURE_RING3MWAIT ( 7*32+ 0)/* Ring 3 MONITOR/MWAIT */ +#define X86_FEATURE_CPUID_FAULT ( 7*32+ 1)/* Intel CPUID faulting */ #define X86_FEATURE_CPB ( 7*32+ 2)/* AMD Core Performance Boost */ #define X86_FEATURE_EPB ( 7*32+ 3)/* IA32_ENERGY_PERF_BIAS support */ #define X86_FEATURE_CAT_L3 ( 7*32+ 4)/* Cache Allocation Technology L3 */
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 22/22 perf tools: Fix the code to strip command name
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Recent commit broke command name strip in perf_event__get_comm_ids function. It replaced left to right search for '\n' with rtrim, which actually does right to left search. It occasionally caught earlier '\n' and kept trash in the command name.
Keeping the ltrim, but moving back the left to right '\n' search instead of the rtrim.
--- tools/perf/util/event.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/event.c +8 -1
@@ -141,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, ppids =strstr (bf,"PPid:" );if (name) { +char *nl; + name +=5 ;/* strlen("Name:") */ - name =rtrim (ltrim (name)); + name =ltrim (name); + + nl =strchr (name,'\n' ); +if (nl) + *nl ='\0' ; + size =strlen (name);if (size >= len) size = len -1 ;
Signature · 1 line
2.9.3
Re: [PATCH 22/22] perf tools: Fix the code to strip command name
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Jiri Olsa <[email protected]>
Recent commit broke command name strip in
perf_event__get_comm_idsfunction. It replaced left to right search for '\n' with rtrim, which actually does right to left search. It occasionally caught earlier '\n' and kept trash in the command name.
interesting. When I reviewed that patch it didn't cross my mind that a comm Name could have a newline in it. seems very odd to do so.
Quoted 144 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider applying,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit
07590a7d4030c159b9a0d7171f81049a9ce23245:Merge tag 'perf-core-for-mingo-4.12-20170419' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2017-04-20 10:07:18 +0200)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-4.12-20170424for you to fetch changes up to
9d43f5e8df6804ae271407500af9062e9278167a:perf tools: Fix the code to strip command name (2017-04-24 13:43:37 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:User visible:
- Fix display of data source snoop indication in 'perf mem' (Andi Kleen)
- Fix the code to strip command name from
/proc/PID/stat(Jiri Olsa)Infrastructure:
- Continue the disentanglement of headers, specially
util.h(Arnaldo Carvalho de Melo)- Synchronize some header files with the kernel (Arnaldo Carvalho de Melo)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Andi Kleen (1):
perf mem: Fix display of data source snoop indicationArnaldo Carvalho de Melo (20):
perf unwind: Provide only forward declarations for pointer types perf tools: Addsignal.hto places using its definitions
perf tools: Move units conversion/formatting routines to separate object perf tools: Move timestamp routines fromutil.htotime-utils.hperf kvm: Make function only used by 'perf kvm' static
perf debug: Movedump_stack()andsighandler_dump_stack()todebug.hperf tools: Addcompress.hfor the*_decompress_to_file()headers perf callchain: Move callchain specific routines from util.[ch] perf tools: Includesys/param.hwhere needed
perf tools: Remove a few more needless includes fromutil.hperf tools: Removesys/ioctl.hfromutil.h
perf tools: Removestring.hfromutil.h
perf tools: Remove stale prototypes frombuiltin.h
perf tools: Removestring.h,unistd.handsys/stat.hfromutil.hperf tools: Removepoll.handwait.hfromutil.h
perf tools: Add the right header to obtainPERF_ALIGN()
perf tools: Use just forward declarations for struct thread where possible
tools: Updateasm-generic/mman-common.hcopy from the kernel tools arch: Syncarch/x86/lib/memcpy_64.Swith the kernel tools arch x86: Synccpufeatures.hJiri Olsa (1):
perf tools: Fix the code to strip command nametools/arch/x86/include/asm/cpufeatures.h | 1 + tools/arch/x86/lib/memcpy_64.S | 2 +- tools/include/uapi/linux/stat.h | 5 +- tools/lib/subcmd/help.h | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm/util/unwind-libdw.c | 1 + tools/perf/arch/arm64/util/dwarf-regs.c | 1 + tools/perf/arch/x86/tests/intel-cqm.c | 2 + tools/perf/arch/x86/util/unwind-libdw.c | 1 + tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-c2c.c | 2 + tools/perf/builtin-ftrace.c | 1 + tools/perf/builtin-help.c | 4 + tools/perf/builtin-inject.c | 2 + tools/perf/builtin-kvm.c | 17 +++ tools/perf/builtin-mem.c | 4 + tools/perf/builtin-record.c | 5 + tools/perf/builtin-report.c | 5 + tools/perf/builtin-script.c | 5 + tools/perf/builtin-stat.c | 5 + tools/perf/builtin-timechart.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 2 + tools/perf/builtin-version.c | 3 +- tools/perf/builtin.h | 4 - tools/perf/perf.c | 6 +- tools/perf/tests/attr.c | 4 + tools/perf/tests/bpf.c | 2 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/tests/parse-events.c | 3 + tools/perf/tests/unit_number__scnprintf.c | 2 +- tools/perf/trace/beauty/signum.c | 1 + tools/perf/ui/browsers/hists.c | 2 + tools/perf/ui/gtk/annotate.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/build-id.c | 3 + tools/perf/util/callchain.c | 103 +++++++++++++++ tools/perf/util/color.h | 2 + tools/perf/util/comm.c | 1 + tools/perf/util/compress.h | 12 ++ tools/perf/util/config.c | 4 + tools/perf/util/debug.c | 33 ++++- tools/perf/util/debug.h | 3 + tools/perf/util/dso.c | 4 + tools/perf/util/event.c | 12 +- tools/perf/util/event.h | 2 +- tools/perf/util/evlist.c | 3 + tools/perf/util/evlist.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/header.c | 4 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/hist.c | 2 + tools/perf/util/llvm-utils.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/machine.c | 3 + tools/perf/util/mem-events.c | 2 +- tools/perf/util/namespaces.c | 1 + tools/perf/util/parse-events.c | 2 + tools/perf/util/pmu.c | 1 + tools/perf/util/probe-file.c | 3 + tools/perf/util/python-ext-sources | 1 + tools/perf/util/python.c | 13 ++ tools/perf/util/session.c | 1 + tools/perf/util/session.h | 3 +- tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 3 +- tools/perf/util/strlist.c | 1 + tools/perf/util/time-utils.c | 25 ++++ tools/perf/util/time-utils.h | 7 + tools/perf/util/top.h | 2 +- tools/perf/util/units.c | 39 ++++++ tools/perf/util/units.h | 10 ++ tools/perf/util/unwind-libdw.h | 6 +- tools/perf/util/unwind.h | 9 +-
Quoted 8 lines
tools/perf/util/util.c | 211 +----------------------------- tools/perf/util/util.h | 38 ------ tools/perf/util/xyarray.c | 2 + tools/perf/util/zlib.c | 1 + 82 files changed, 412 insertions(+), 270 deletions(-) create mode 100644 tools/perf/util/compress.h create mode 100644 tools/perf/util/units.c create mode 100644 tools/perf/util/units.h
Pulled, thanks a lot Arnaldo!
Ingo