[GIT PULL 00/37] perf/core improvements and fixes

From: Arnaldo Carvalho de Melo
Date: Thu Nov 19 2015 - 12:55:30 EST


Hi Ingo,

Please consider pulling, this was based on tip/perf/urgent and I did a
test merge of tip/perf/core with tip/perf/urgent and then with this branch,
haven't noticed problems,

Best regards,

- Arnaldo

The following changes since commit e15bf88a44d1fcb685754b2868b1cd28927af3aa:

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2015-11-18 06:56:48 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to 2c6caff2b26fde8f3f87183f8c97f2cebfdbcb98:

perf ui/gtk: Support folded callchains (2015-11-19 13:19:26 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Allows BPF scriptlets specify arguments to be fetched using
DWARF info, using a prologue generated at compile/build time (He Kuang, Wang Nan)

- Allow attaching BPF scriptlets to module symbols (Wang Nan)

- Allow attaching BPF scriptlets to userspace code using uprobe (Wang Nan)

- BPF programs now can specify 'perf probe' tunables via its section name,
separating key=val values using semicolons (Wang Nan)

Testing some of these new BPF features:

Use case: get callchains when receiving SSL packets, filter then in the
kernel, at arbitrary place.

# cat ssl.bpf.c
#define SEC(NAME) __attribute__((section(NAME), used))

struct pt_regs;

SEC("func=__inet_lookup_established hnum")
int func(struct pt_regs *ctx, int err, unsigned short port)
{
return err == 0 && port == 443;
}

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
#
# perf record -a -g -e ssl.bpf.c
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.787 MB perf.data (3 samples) ]
# perf script | head -30
swapper 0 [000] 58783.268118: perf_bpf_probe:func: (ffffffff816a0f60) hnum=0x1bb
8a0f61 __inet_lookup_established (/lib/modules/4.3.0+/build/vmlinux)
896def ip_rcv_finish (/lib/modules/4.3.0+/build/vmlinux)
8976c2 ip_rcv (/lib/modules/4.3.0+/build/vmlinux)
855eba __netif_receive_skb_core (/lib/modules/4.3.0+/build/vmlinux)
8565d8 __netif_receive_skb (/lib/modules/4.3.0+/build/vmlinux)
8572a8 process_backlog (/lib/modules/4.3.0+/build/vmlinux)
856b11 net_rx_action (/lib/modules/4.3.0+/build/vmlinux)
2a284b __do_softirq (/lib/modules/4.3.0+/build/vmlinux)
2a2ba3 irq_exit (/lib/modules/4.3.0+/build/vmlinux)
96b7a4 do_IRQ (/lib/modules/4.3.0+/build/vmlinux)
969807 ret_from_intr (/lib/modules/4.3.0+/build/vmlinux)
2dede5 cpu_startup_entry (/lib/modules/4.3.0+/build/vmlinux)
95d5bc rest_init (/lib/modules/4.3.0+/build/vmlinux)
1163ffa start_kernel ([kernel.vmlinux].init.text)
11634d7 x86_64_start_reservations ([kernel.vmlinux].init.text)
1163623 x86_64_start_kernel ([kernel.vmlinux].init.text)

qemu-system-x86 9178 [003] 58785.792417: perf_bpf_probe:func: (ffffffff816a0f60) hnum=0x1bb
8a0f61 __inet_lookup_established (/lib/modules/4.3.0+/build/vmlinux)
896def ip_rcv_finish (/lib/modules/4.3.0+/build/vmlinux)
8976c2 ip_rcv (/lib/modules/4.3.0+/build/vmlinux)
855eba __netif_receive_skb_core (/lib/modules/4.3.0+/build/vmlinux)
8565d8 __netif_receive_skb (/lib/modules/4.3.0+/build/vmlinux)
856660 netif_receive_skb_internal (/lib/modules/4.3.0+/build/vmlinux)
8566ec netif_receive_skb_sk (/lib/modules/4.3.0+/build/vmlinux)
430a br_handle_frame_finish ([bridge])
48bc br_handle_frame ([bridge])
855f44 __netif_receive_skb_core (/lib/modules/4.3.0+/build/vmlinux)
8565d8 __netif_receive_skb (/lib/modules/4.3.0+/build/vmlinux)
#

Use 'perf probe' various options to list functions, see what variables can
be collected at any given point, experiment first collecting without a filter,
then filter, use it together with 'perf trace', 'perf top', with or without
callchains, if it explodes, please tell us!

- Introduce a new callchain mode: "folded", that will list per line
representations of all callchains for a give histogram entry, facilitating
'perf report' output processing by other tools, such as Brendan Gregg's
flamegraph tools (Namhyung Kim)

E.g:

# perf report | grep -v ^# | head
18.37% 0.00% swapper [kernel.kallsyms] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--12.07%--start_secondary
|
--6.30%--rest_init
start_kernel
x86_64_start_reservations
x86_64_start_kernel
#

Becomes, in "folded" mode:

# perf report -g folded | grep -v ^# | head -5
18.37% 0.00% swapper [kernel.kallsyms] [k] cpu_startup_entry
12.07% cpu_startup_entry;start_secondary
6.30% cpu_startup_entry;rest_init;start_kernel;x86_64_start_reservations;x86_64_start_kernel
16.90% 0.00% swapper [kernel.kallsyms] [k] call_cpuidle
11.23% call_cpuidle;cpu_startup_entry;start_secondary
5.67% call_cpuidle;cpu_startup_entry;rest_init;start_kernel;x86_64_start_reservations;x86_64_start_kernel
16.90% 0.00% swapper [kernel.kallsyms] [k] cpuidle_enter
11.23% cpuidle_enter;call_cpuidle;cpu_startup_entry;start_secondary
5.67% cpuidle_enter;call_cpuidle;cpu_startup_entry;rest_init;start_kernel;x86_64_start_reservations;x86_64_start_kernel
15.12% 0.00% swapper [kernel.kallsyms] [k] cpuidle_enter_state
#

The user can also select one of "count", "period" or "percent" as the first column.

Infrastructure:

- Fix multiple leaks found with valgrind and a refcount
debugger (Masami Hiramatsu)

- Add further 'perf test' entries for BPF and LLVM (Wang Nan)

- Improve 'perf test' to suport subtests, so that the series of tests
performed in the LLVM and BPF main tests appear in the default 'perf test'
output (Wang Nan)

- Move memdup() from tools/perf to tools/lib/string.c (Arnaldo Carvalho de Melo)

- Adopt strtobool() from the kernel into tools/lib/ (Wang Nan)

- Fix selftests_install tools/ Makefile rule (Kevin Hilman)

Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf test: Fix build of BPF and LLVM on older glibc libraries
tools: Adopt memdup() from tools/perf, moving it to tools/lib/string.c
perf tests: Pass the subtest index to each test routine

He Kuang (1):
perf bpf: Add prologue for BPF programs for fetching arguments

Kevin Hilman (1):
tools: Fix selftests_install Makefile rule

Masami Hiramatsu (9):
perf probe: Fix to free temporal Dwarf_Frame
perf machine: Fix machine__findnew_module_map to put registered map
perf machine: Fix machine__destroy_kernel_maps to drop vmlinux_maps references
perf machine: Fix to destroy kernel maps when machine exits
perf tools: Make perf_exec_path() always return malloc'd string
perf tools: Fix to put new map after inserting to map_groups in dso__load_sym
perf tools: Fix __dsos__addnew to put dso after adding it to the list
perf tools: Fix machine__create_kernel_maps to put kernel dso refcount
perf machine: Fix machine__findnew_module_map to put dso

Namhyung Kim (9):
perf report: Support folded callchain mode on --stdio
perf callchain: Abstract callchain print function
perf callchain: Add count fields to struct callchain_node
perf report: Add callchain value option
perf hists browser: Factor out hist_browser__show_callchain_list()
perf hists browser: Support flat callchains
perf hists browser: Support folded callchains
perf ui/gtk: Support flat callchains
perf ui/gtk: Support folded callchains

Wang Nan (14):
tools: Clone the kernel's strtobool function
bpf tools: Load a program with different instances using preprocessor
perf bpf: Add BPF_PROLOGUE config options for further patches
perf bpf: Compile dwarf-regs.c if CONFIG_BPF_PROLOGUE is on
perf bpf: Allow BPF program attach to uprobe events
perf bpf: Allow attaching BPF programs to modules symbols
perf bpf: Allow BPF program config probing options
perf bpf: Generate prologue for BPF programs
perf test: Test the BPF prologue adding infrastructure
perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux
perf bpf: Use same BPF program if arguments are identical
perf test: Print result for each LLVM subtest
perf test: Print result for each BPF subtest
perf test: Mute test cases error messages if verbose == 0

tools/Makefile | 2 +-
tools/include/linux/string.h | 11 +
tools/lib/bpf/libbpf.c | 146 ++++++++-
tools/lib/bpf/libbpf.h | 64 ++++
tools/lib/string.c | 62 ++++
tools/perf/Documentation/perf-report.txt | 14 +-
tools/perf/MANIFEST | 2 +
tools/perf/arch/x86/include/arch-tests.h | 8 +-
tools/perf/arch/x86/tests/insn-x86.c | 2 +-
tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 +-
tools/perf/arch/x86/tests/rdpmc.c | 2 +-
tools/perf/arch/x86/util/Build | 1 +
tools/perf/builtin-report.c | 4 +-
tools/perf/config/Makefile | 12 +
tools/perf/tests/.gitignore | 1 +
tools/perf/tests/Build | 9 +-
tools/perf/tests/attr.c | 2 +-
tools/perf/tests/bp_signal.c | 2 +-
tools/perf/tests/bp_signal_overflow.c | 2 +-
tools/perf/tests/bpf-script-test-prologue.c | 35 +++
tools/perf/tests/bpf.c | 93 ++++--
tools/perf/tests/builtin-test.c | 112 ++++++-
tools/perf/tests/code-reading.c | 2 +-
tools/perf/tests/dso-data.c | 6 +-
tools/perf/tests/dwarf-unwind.c | 2 +-
tools/perf/tests/evsel-roundtrip-name.c | 2 +-
tools/perf/tests/evsel-tp-sched.c | 2 +-
tools/perf/tests/fdarray.c | 4 +-
tools/perf/tests/hists_cumulate.c | 2 +-
tools/perf/tests/hists_filter.c | 2 +-
tools/perf/tests/hists_link.c | 2 +-
tools/perf/tests/hists_output.c | 2 +-
tools/perf/tests/keep-tracking.c | 2 +-
tools/perf/tests/kmod-path.c | 2 +-
tools/perf/tests/llvm.c | 75 +++--
tools/perf/tests/llvm.h | 2 +
tools/perf/tests/mmap-basic.c | 2 +-
tools/perf/tests/mmap-thread-lookup.c | 2 +-
tools/perf/tests/openat-syscall-all-cpus.c | 2 +-
tools/perf/tests/openat-syscall-tp-fields.c | 2 +-
tools/perf/tests/openat-syscall.c | 2 +-
tools/perf/tests/parse-events.c | 2 +-
tools/perf/tests/parse-no-sample-id-all.c | 2 +-
tools/perf/tests/perf-record.c | 2 +-
tools/perf/tests/pmu.c | 2 +-
tools/perf/tests/python-use.c | 3 +-
tools/perf/tests/sample-parsing.c | 2 +-
tools/perf/tests/sw-clock.c | 2 +-
tools/perf/tests/switch-tracking.c | 2 +-
tools/perf/tests/task-exit.c | 2 +-
tools/perf/tests/tests.h | 89 +++---
tools/perf/tests/thread-map.c | 2 +-
tools/perf/tests/thread-mg-share.c | 2 +-
tools/perf/tests/topology.c | 2 +-
tools/perf/tests/vmlinux-kallsyms.c | 2 +-
tools/perf/ui/browsers/hists.c | 315 +++++++++++++++++--
tools/perf/ui/gtk/hists.c | 148 ++++++++-
tools/perf/ui/stdio/hist.c | 94 +++++-
tools/perf/util/Build | 7 +
tools/perf/util/bpf-loader.c | 434 ++++++++++++++++++++++++-
tools/perf/util/bpf-loader.h | 4 +
tools/perf/util/bpf-prologue.c | 455 +++++++++++++++++++++++++++
tools/perf/util/bpf-prologue.h | 34 ++
tools/perf/util/callchain.c | 135 +++++++-
tools/perf/util/callchain.h | 28 +-
tools/perf/util/dso.c | 2 +
tools/perf/util/exec_cmd.c | 21 +-
tools/perf/util/exec_cmd.h | 5 +-
tools/perf/util/help.c | 6 +-
tools/perf/util/include/linux/string.h | 3 -
tools/perf/util/machine.c | 17 +-
tools/perf/util/probe-event.c | 7 +-
tools/perf/util/probe-finder.c | 9 +-
tools/perf/util/string.c | 16 -
tools/perf/util/symbol-elf.c | 2 +
tools/perf/util/util.c | 3 +-
77 files changed, 2286 insertions(+), 282 deletions(-)
create mode 100644 tools/include/linux/string.h
create mode 100644 tools/lib/string.c
create mode 100644 tools/perf/tests/bpf-script-test-prologue.c
create mode 100644 tools/perf/util/bpf-prologue.c
create mode 100644 tools/perf/util/bpf-prologue.h
delete mode 100644 tools/perf/util/include/linux/string.h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/