License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-06-26 22:28:00 +08:00
|
|
|
#ifndef __PERF_CALLCHAIN_H
|
|
|
|
#define __PERF_CALLCHAIN_H
|
|
|
|
|
2009-07-02 01:46:08 +08:00
|
|
|
#include <linux/list.h>
|
2009-07-01 23:28:37 +08:00
|
|
|
#include <linux/rbtree.h>
|
2019-01-27 19:02:41 +08:00
|
|
|
#include "map_symbol.h"
|
2017-07-18 20:13:15 +08:00
|
|
|
#include "branch.h"
|
2009-06-26 22:28:00 +08:00
|
|
|
|
2019-09-11 00:24:07 +08:00
|
|
|
struct addr_location;
|
2019-08-30 04:19:02 +08:00
|
|
|
struct evsel;
|
2019-09-11 00:24:07 +08:00
|
|
|
struct ip_callchain;
|
2019-01-27 18:55:39 +08:00
|
|
|
struct map;
|
2019-09-11 00:24:07 +08:00
|
|
|
struct perf_sample;
|
|
|
|
struct thread;
|
2020-10-09 10:28:43 +08:00
|
|
|
struct hists;
|
2019-01-27 18:55:39 +08:00
|
|
|
|
perf tools: Improve call graph documents and help messages
The --call-graph option is complex so we should provide better guide for
users. Also change help message to be consistent with config option
names. Now perf top will show help like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph <record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]>
setup and enables call-graph (stack chain/backtrace):
record_mode: call graph recording mode (fp|dwarf|lbr)
record_size: if record_mode is 'dwarf', max size of stack recording (<bytes>)
default: 8192 (bytes)
print_type: call graph printing style (graph|flat|fractal|none)
threshold: minimum call graph inclusion threshold (<percent>)
print_limit: maximum number of call graph entry (<number>)
order: call graph order (caller|callee)
sort_key: call graph sort key (function|address)
branch: include last branch info to call graph (branch)
Default: fp,graph,0.5,caller,function
Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445524112-5201-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-22 22:28:32 +08:00
|
|
|
#define HELP_PAD "\t\t\t\t"
|
|
|
|
|
|
|
|
#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace):\n\n"
|
2015-10-22 14:28:48 +08:00
|
|
|
|
perf tools: Improve call graph documents and help messages
The --call-graph option is complex so we should provide better guide for
users. Also change help message to be consistent with config option
names. Now perf top will show help like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph <record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]>
setup and enables call-graph (stack chain/backtrace):
record_mode: call graph recording mode (fp|dwarf|lbr)
record_size: if record_mode is 'dwarf', max size of stack recording (<bytes>)
default: 8192 (bytes)
print_type: call graph printing style (graph|flat|fractal|none)
threshold: minimum call graph inclusion threshold (<percent>)
print_limit: maximum number of call graph entry (<number>)
order: call graph order (caller|callee)
sort_key: call graph sort key (function|address)
branch: include last branch info to call graph (branch)
Default: fp,graph,0.5,caller,function
Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445524112-5201-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-22 22:28:32 +08:00
|
|
|
# define RECORD_MODE_HELP HELP_PAD "record_mode:\tcall graph recording mode (fp|dwarf|lbr)\n"
|
2015-10-22 14:28:48 +08:00
|
|
|
|
perf tools: Improve call graph documents and help messages
The --call-graph option is complex so we should provide better guide for
users. Also change help message to be consistent with config option
names. Now perf top will show help like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph <record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]>
setup and enables call-graph (stack chain/backtrace):
record_mode: call graph recording mode (fp|dwarf|lbr)
record_size: if record_mode is 'dwarf', max size of stack recording (<bytes>)
default: 8192 (bytes)
print_type: call graph printing style (graph|flat|fractal|none)
threshold: minimum call graph inclusion threshold (<percent>)
print_limit: maximum number of call graph entry (<number>)
order: call graph order (caller|callee)
sort_key: call graph sort key (function|address)
branch: include last branch info to call graph (branch)
Default: fp,graph,0.5,caller,function
Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445524112-5201-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-22 22:28:32 +08:00
|
|
|
#define RECORD_SIZE_HELP \
|
|
|
|
HELP_PAD "record_size:\tif record_mode is 'dwarf', max size of stack recording (<bytes>)\n" \
|
|
|
|
HELP_PAD "\t\tdefault: 8192 (bytes)\n"
|
|
|
|
|
|
|
|
#define CALLCHAIN_RECORD_HELP CALLCHAIN_HELP RECORD_MODE_HELP RECORD_SIZE_HELP
|
|
|
|
|
|
|
|
#define CALLCHAIN_REPORT_HELP \
|
2015-11-09 13:45:37 +08:00
|
|
|
HELP_PAD "print_type:\tcall graph printing style (graph|flat|fractal|folded|none)\n" \
|
perf tools: Improve call graph documents and help messages
The --call-graph option is complex so we should provide better guide for
users. Also change help message to be consistent with config option
names. Now perf top will show help like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph <record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]>
setup and enables call-graph (stack chain/backtrace):
record_mode: call graph recording mode (fp|dwarf|lbr)
record_size: if record_mode is 'dwarf', max size of stack recording (<bytes>)
default: 8192 (bytes)
print_type: call graph printing style (graph|flat|fractal|none)
threshold: minimum call graph inclusion threshold (<percent>)
print_limit: maximum number of call graph entry (<number>)
order: call graph order (caller|callee)
sort_key: call graph sort key (function|address)
branch: include last branch info to call graph (branch)
Default: fp,graph,0.5,caller,function
Requested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445524112-5201-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-22 22:28:32 +08:00
|
|
|
HELP_PAD "threshold:\tminimum call graph inclusion threshold (<percent>)\n" \
|
|
|
|
HELP_PAD "print_limit:\tmaximum number of call graph entry (<number>)\n" \
|
|
|
|
HELP_PAD "order:\t\tcall graph order (caller|callee)\n" \
|
|
|
|
HELP_PAD "sort_key:\tcall graph sort key (function|address)\n" \
|
2015-11-09 13:45:41 +08:00
|
|
|
HELP_PAD "branch:\t\tinclude last branch info to call graph (branch)\n" \
|
|
|
|
HELP_PAD "value:\t\tcall graph value (percent|period|count)\n"
|
2015-10-22 14:28:48 +08:00
|
|
|
|
2014-05-05 18:46:17 +08:00
|
|
|
enum perf_call_graph_mode {
|
|
|
|
CALLCHAIN_NONE,
|
|
|
|
CALLCHAIN_FP,
|
|
|
|
CALLCHAIN_DWARF,
|
2015-01-06 02:23:04 +08:00
|
|
|
CALLCHAIN_LBR,
|
2014-05-05 18:46:17 +08:00
|
|
|
CALLCHAIN_MAX
|
|
|
|
};
|
|
|
|
|
2009-07-02 23:58:21 +08:00
|
|
|
enum chain_mode {
|
2009-08-08 08:16:24 +08:00
|
|
|
CHAIN_NONE,
|
2009-07-05 13:39:21 +08:00
|
|
|
CHAIN_FLAT,
|
|
|
|
CHAIN_GRAPH_ABS,
|
2015-11-09 13:45:37 +08:00
|
|
|
CHAIN_GRAPH_REL,
|
|
|
|
CHAIN_FOLDED,
|
2009-07-02 23:58:21 +08:00
|
|
|
};
|
2009-06-26 22:28:00 +08:00
|
|
|
|
2011-06-07 23:49:46 +08:00
|
|
|
enum chain_order {
|
|
|
|
ORDER_CALLER,
|
|
|
|
ORDER_CALLEE
|
|
|
|
};
|
|
|
|
|
2009-06-26 22:28:00 +08:00
|
|
|
struct callchain_node {
|
|
|
|
struct callchain_node *parent;
|
2009-07-01 18:37:06 +08:00
|
|
|
struct list_head val;
|
2015-11-09 13:45:43 +08:00
|
|
|
struct list_head parent_val;
|
2013-10-11 13:15:36 +08:00
|
|
|
struct rb_node rb_node_in; /* to insert nodes in an rbtree */
|
|
|
|
struct rb_node rb_node; /* to sort nodes in an output tree */
|
|
|
|
struct rb_root rb_root_in; /* input tree of children */
|
|
|
|
struct rb_root rb_root; /* sorted output tree of children */
|
2009-07-01 18:37:06 +08:00
|
|
|
unsigned int val_nr;
|
2015-11-09 13:45:40 +08:00
|
|
|
unsigned int count;
|
|
|
|
unsigned int children_count;
|
2009-07-01 18:37:06 +08:00
|
|
|
u64 hit;
|
2009-08-07 13:11:05 +08:00
|
|
|
u64 children_hit;
|
2009-06-26 22:28:00 +08:00
|
|
|
};
|
|
|
|
|
2010-08-23 02:05:22 +08:00
|
|
|
struct callchain_root {
|
|
|
|
u64 max_depth;
|
|
|
|
struct callchain_node node;
|
|
|
|
};
|
|
|
|
|
2009-07-05 13:39:21 +08:00
|
|
|
struct callchain_param;
|
|
|
|
|
2010-08-23 02:05:22 +08:00
|
|
|
typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *,
|
2009-07-05 13:39:21 +08:00
|
|
|
u64, struct callchain_param *);
|
|
|
|
|
2013-07-19 06:33:57 +08:00
|
|
|
enum chain_key {
|
|
|
|
CCKEY_FUNCTION,
|
2017-03-19 05:49:28 +08:00
|
|
|
CCKEY_ADDRESS,
|
|
|
|
CCKEY_SRCLINE
|
2013-07-19 06:33:57 +08:00
|
|
|
};
|
|
|
|
|
2015-11-09 13:45:41 +08:00
|
|
|
enum chain_value {
|
|
|
|
CCVAL_PERCENT,
|
|
|
|
CCVAL_PERIOD,
|
|
|
|
CCVAL_COUNT,
|
|
|
|
};
|
|
|
|
|
perf unwind: Do not look just at the global callchain_param.record_mode
When setting up DWARF callchains on specific events, without using
'record' or 'trace' --call-graph, but instead doing it like:
perf trace -e cycles/call-graph=dwarf/
The unwind__prepare_access() call in thread__insert_map() when we
process PERF_RECORD_MMAP(2) metadata events were not being performed,
precluding us from using per-event DWARF callchains, handling them just
when we asked for all events to be DWARF, using "--call-graph dwarf".
We do it in the PERF_RECORD_MMAP because we have to look at one of the
executable maps to figure out the executable type (64-bit, 32-bit) of
the DSO laid out in that mmap. Also to look at the architecture where
the perf.data file was recorded.
All this probably should be deferred to when we process a sample for
some thread that has callchains, so that we do this processing only for
the threads with samples, not for all of them.
For now, fix using DWARF on specific events.
Before:
# perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.048 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.048/0.048/0.048/0.000 ms
0.000 probe_libc:inet_pton:(7fe9597bb350))
Problem processing probe_libc:inet_pton callchain, skipping...
#
After:
# perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.060 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.060/0.060/0.060/0.000 ms
0.000 probe_libc:inet_pton:(7fd4aa930350))
__inet_pton (inlined)
gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
__GI_getaddrinfo (inlined)
[0xffffaa804e51af3f] (/usr/bin/ping)
__libc_start_main (/usr/lib64/libc-2.26.so)
[0xffffaa804e51b379] (/usr/bin/ping)
#
# perf trace --call-graph=dwarf --no-syscalls -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.057 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.057/0.057/0.057/0.000 ms
0.000 probe_libc:inet_pton:(7f9363b9e350))
__inet_pton (inlined)
gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
__GI_getaddrinfo (inlined)
[0xffffa9e8a14e0f3f] (/usr/bin/ping)
__libc_start_main (/usr/lib64/libc-2.26.so)
[0xffffa9e8a14e1379] (/usr/bin/ping)
#
# perf trace --call-graph=fp --no-syscalls -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.077 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.077/0.077/0.077/0.000 ms
0.000 probe_libc:inet_pton:(7f4947e1c350))
__inet_pton (inlined)
gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so)
__GI_getaddrinfo (inlined)
[0xffffaa716d88ef3f] (/usr/bin/ping)
__libc_start_main (/usr/lib64/libc-2.26.so)
[0xffffaa716d88f379] (/usr/bin/ping)
#
# perf trace --no-syscalls -e probe_libc:inet_pton/call-graph=fp/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.078 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.078/0.078/0.078/0.000 ms
0.000 probe_libc:inet_pton:(7fa157696350))
__GI___inet_pton (/usr/lib64/libc-2.26.so)
getaddrinfo (/usr/lib64/libc-2.26.so)
[0xffffa9ba39c74f40] (/usr/bin/ping)
#
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hendrick Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/r/20180116182650.GE16107@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-01-16 03:48:46 +08:00
|
|
|
extern bool dwarf_callchain_users;
|
|
|
|
|
2009-07-05 13:39:21 +08:00
|
|
|
struct callchain_param {
|
2014-09-23 09:01:41 +08:00
|
|
|
bool enabled;
|
|
|
|
enum perf_call_graph_mode record_mode;
|
|
|
|
u32 dump_size;
|
2009-07-05 13:39:21 +08:00
|
|
|
enum chain_mode mode;
|
perf tools: Per event max-stack settings
The tooling counterpart, now it is possible to do:
# perf record -e sched:sched_switch/max-stack=10/ -e cycles/call-graph=dwarf,max-stack=4/ -e cpu-cycles/call-graph=dwarf,max-stack=1024/ usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.052 MB perf.data (5 samples) ]
# perf evlist -v
sched:sched_switch: type: 2, size: 112, config: 0x110, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, sample_max_stack: 10
cycles/call-graph=dwarf,max-stack=4/: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|PERIOD|REGS_USER|STACK_USER|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, enable_on_exec: 1, sample_id_all: 1, exclude_guest: 1, exclude_callchain_user: 1, sample_regs_user: 0xff0fff, sample_stack_user: 8192, sample_max_stack: 4
cpu-cycles/call-graph=dwarf,max-stack=1024/: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|PERIOD|REGS_USER|STACK_USER|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, enable_on_exec: 1, sample_id_all: 1, exclude_guest: 1, exclude_callchain_user: 1, sample_regs_user: 0xff0fff, sample_stack_user: 8192, sample_max_stack: 1024
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
Using just /max-stack=N/ means /call-graph=fp,max-stack=N/, that should
be further configurable by means of some .perfconfig knob.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/n/tip-kolmn1yo40p7jhswxwrc7rrd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-04-29 06:03:42 +08:00
|
|
|
u16 max_stack;
|
2010-05-10 07:28:10 +08:00
|
|
|
u32 print_limit;
|
2009-07-05 13:39:21 +08:00
|
|
|
double min_percent;
|
|
|
|
sort_chain_func_t sort;
|
2011-06-07 23:49:46 +08:00
|
|
|
enum chain_order order;
|
2015-10-22 15:45:46 +08:00
|
|
|
bool order_set;
|
2013-07-19 06:33:57 +08:00
|
|
|
enum chain_key key;
|
perf callchain: Support handling complete branch stacks as histograms
Currently branch stacks can be only shown as edge histograms for
individual branches. I never found this display particularly useful.
This implements an alternative mode that creates histograms over
complete branch traces, instead of individual branches, similar to how
normal callgraphs are handled. This is done by putting it in front of
the normal callgraph and then using the normal callgraph histogram
infrastructure to unify them.
This way in complex functions we can understand the control flow that
lead to a particular sample, and may even see some control flow in the
caller for short functions.
Example (simplified, of course for such simple code this is usually not
needed), please run this after the whole patchkit is in, as at this
point in the patch order there is no --branch-history, that will be
added in a patch after this one:
tcall.c:
volatile a = 10000, b = 100000, c;
__attribute__((noinline)) f2()
{
c = a / b;
}
__attribute__((noinline)) f1()
{
f2();
f2();
}
main()
{
int i;
for (i = 0; i < 1000000; i++)
f1();
}
% perf record -b -g ./tsrc/tcall
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.044 MB perf.data (~1923 samples) ]
% perf report --no-children --branch-history
...
54.91% tcall.c:6 [.] f2 tcall
|
|--65.53%-- f2 tcall.c:5
| |
| |--70.83%-- f1 tcall.c:11
| | f1 tcall.c:10
| | main tcall.c:18
| | main tcall.c:18
| | main tcall.c:17
| | main tcall.c:17
| | f1 tcall.c:13
| | f1 tcall.c:13
| | f2 tcall.c:7
| | f2 tcall.c:5
| | f1 tcall.c:12
| | f1 tcall.c:12
| | f2 tcall.c:7
| | f2 tcall.c:5
| | f1 tcall.c:11
| |
| --29.17%-- f1 tcall.c:12
| f1 tcall.c:12
| f2 tcall.c:7
| f2 tcall.c:5
| f1 tcall.c:11
| f1 tcall.c:10
| main tcall.c:18
| main tcall.c:18
| main tcall.c:17
| main tcall.c:17
| f1 tcall.c:13
| f1 tcall.c:13
| f2 tcall.c:7
| f2 tcall.c:5
| f1 tcall.c:12
The default output is unchanged.
This is only implemented in perf report, no change to record or anywhere
else.
This adds the basic code to report:
- add a new "branch" option to the -g option parser to enable this mode
- when the flag is set include the LBR into the callstack in machine.c.
The rest of the history code is unchanged and doesn't know the
difference between LBR entry and normal call entry.
- detect overlaps with the callchain
- remove small loop duplicates in the LBR
Current limitations:
- The LBR flags (mispredict etc.) are not shown in the history
and LBR entries have no special marker.
- It would be nice if annotate marked the LBR entries somehow
(e.g. with arrows)
v2: Various fixes.
v3: Merge further patches into this one. Fix white space.
v4: Improve manpage. Address review feedback.
v5: Rename functions. Better error message without -g. Fix crash without
-b.
v6: Rebase
v7: Rebase. Use NO_ENTRY in memset.
v8: Port to latest tip. Move add_callchain_ip to separate
patch. Skip initial entries in callchain. Minor cleanups.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1415844328-4884-3-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-11-13 10:05:20 +08:00
|
|
|
bool branch_callstack;
|
2015-11-09 13:45:41 +08:00
|
|
|
enum chain_value value;
|
2009-07-05 13:39:21 +08:00
|
|
|
};
|
|
|
|
|
2014-10-10 03:12:24 +08:00
|
|
|
extern struct callchain_param callchain_param;
|
2016-07-04 20:16:21 +08:00
|
|
|
extern struct callchain_param callchain_param_default;
|
2014-10-10 03:12:24 +08:00
|
|
|
|
2009-06-26 22:28:00 +08:00
|
|
|
struct callchain_list {
|
2009-07-01 18:37:06 +08:00
|
|
|
u64 ip;
|
2010-03-25 03:40:18 +08:00
|
|
|
struct map_symbol ms;
|
2015-05-05 22:55:46 +08:00
|
|
|
struct /* for TUI */ {
|
|
|
|
bool unfolded;
|
|
|
|
bool has_children;
|
|
|
|
};
|
2016-10-31 09:19:51 +08:00
|
|
|
u64 branch_count;
|
2019-01-04 14:10:30 +08:00
|
|
|
u64 from_count;
|
2016-10-31 09:19:51 +08:00
|
|
|
u64 predicted_count;
|
|
|
|
u64 abort_count;
|
|
|
|
u64 cycles_count;
|
|
|
|
u64 iter_count;
|
2017-08-07 21:05:15 +08:00
|
|
|
u64 iter_cycles;
|
2017-07-18 20:13:15 +08:00
|
|
|
struct branch_type_stat brtype_stat;
|
2017-10-10 04:32:56 +08:00
|
|
|
const char *srcline;
|
2009-06-26 22:28:00 +08:00
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2011-01-14 11:51:58 +08:00
|
|
|
/*
|
|
|
|
* A callchain cursor is a single linked list that
|
|
|
|
* let one feed a callchain progressively.
|
2012-07-18 00:20:59 +08:00
|
|
|
* It keeps persistent allocated entries to minimize
|
2011-01-14 11:51:58 +08:00
|
|
|
* allocations.
|
|
|
|
*/
|
|
|
|
struct callchain_cursor_node {
|
|
|
|
u64 ip;
|
2019-11-04 23:14:32 +08:00
|
|
|
struct map_symbol ms;
|
2017-10-10 04:32:56 +08:00
|
|
|
const char *srcline;
|
2020-03-20 04:25:11 +08:00
|
|
|
/* Indicate valid cursor node for LBR stitch */
|
|
|
|
bool valid;
|
|
|
|
|
perf report: Add branch flag to callchain cursor node
Since the branch ip has been added to call stack for easier browsing,
this patch adds more branch information. For example, add a flag to
indicate if this ip is a branch, and also add with the branch flag.
Then we can know if the cursor node represents a branch and know what
the branch flag it has.
The branch history code has a loop detection pass that removes loops. It
would be nice for knowing how many loops were removed then in next
steps, we can compute out the average number of iterations.
For example:
Before remove_loops(),
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x300, to = 0x250
entry3: from = 0x300, to = 0x250
entry4: from = 0x700, to = 0x800
After remove_loops()
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x700, to = 0x800
The original entry2 and entry3 are removed. So the number of iterations
(from = 0x300, to = 0x250) is equal to removed number + 1 (2 + 1).
iterations = removed number + 1;
average iteractions = Sum(iteractions) / number of samples
This formula ignores other cases, for example, iterations cross multiple
buffers and one buffer contains 2+ loops. Because in practice, it's good
enough.
Signed-off-by: Yao Jin <yao.jin@linux.intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linux-kernel@vger.kernel.org
Cc: Yao Jin <yao.jin@linux.intel.com>
Link: http://lkml.kernel.org/n/1477876794-30749-2-git-send-email-yao.jin@linux.intel.com
[ Renamed 'iter' to 'nr_loop_iter' for clarity ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-31 09:19:49 +08:00
|
|
|
bool branch;
|
|
|
|
struct branch_flags branch_flags;
|
2017-07-18 20:13:15 +08:00
|
|
|
u64 branch_from;
|
perf report: Add branch flag to callchain cursor node
Since the branch ip has been added to call stack for easier browsing,
this patch adds more branch information. For example, add a flag to
indicate if this ip is a branch, and also add with the branch flag.
Then we can know if the cursor node represents a branch and know what
the branch flag it has.
The branch history code has a loop detection pass that removes loops. It
would be nice for knowing how many loops were removed then in next
steps, we can compute out the average number of iterations.
For example:
Before remove_loops(),
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x300, to = 0x250
entry3: from = 0x300, to = 0x250
entry4: from = 0x700, to = 0x800
After remove_loops()
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x700, to = 0x800
The original entry2 and entry3 are removed. So the number of iterations
(from = 0x300, to = 0x250) is equal to removed number + 1 (2 + 1).
iterations = removed number + 1;
average iteractions = Sum(iteractions) / number of samples
This formula ignores other cases, for example, iterations cross multiple
buffers and one buffer contains 2+ loops. Because in practice, it's good
enough.
Signed-off-by: Yao Jin <yao.jin@linux.intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linux-kernel@vger.kernel.org
Cc: Yao Jin <yao.jin@linux.intel.com>
Link: http://lkml.kernel.org/n/1477876794-30749-2-git-send-email-yao.jin@linux.intel.com
[ Renamed 'iter' to 'nr_loop_iter' for clarity ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-31 09:19:49 +08:00
|
|
|
int nr_loop_iter;
|
2017-08-07 21:05:15 +08:00
|
|
|
u64 iter_cycles;
|
2011-01-14 11:51:58 +08:00
|
|
|
struct callchain_cursor_node *next;
|
|
|
|
};
|
|
|
|
|
perf callchain: Stitch LBR call stack
In LBR call stack mode, the depth of reconstructed LBR call stack limits
to the number of LBR registers.
For example, on skylake, the depth of reconstructed LBR call stack is
always <= 32.
# To display the perf.data header info, please use
# --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 6K of event 'cycles'
# Event count (approx.): 6487119731
#
# Children Self Command Shared Object Symbol
# ........ ........ ............... ..................
# ................................
99.97% 99.97% tchain_edit tchain_edit [.] f43
|
--99.64%--f11
f12
f13
f14
f15
f16
f17
f18
f19
f20
f21
f22
f23
f24
f25
f26
f27
f28
f29
f30
f31
f32
f33
f34
f35
f36
f37
f38
f39
f40
f41
f42
f43
For a call stack which is deeper than LBR limit, HW will overwrite the
LBR register with oldest branch. Only partial call stacks can be
reconstructed.
However, the overwritten LBRs may still be retrieved from previous
sample. At that moment, HW hasn't overwritten the LBR registers yet.
Perf tools can stitch those overwritten LBRs on current call stacks to
get a more complete call stack.
To determine if LBRs can be stitched, perf tools need to compare current
sample with previous sample.
- They should have identical LBR records (Same from, to and flags
values, and the same physical index of LBR registers).
- The searching starts from the base-of-stack of current sample.
Once perf determines to stitch the previous LBRs, the corresponding LBR
cursor nodes will be copied to 'lists'. The 'lists' is to track the LBR
cursor nodes which are going to be stitched.
When the stitching is over, the nodes will not be freed immediately.
They will be moved to 'free_lists'. Next stitching may reuse the space.
Both 'lists' and 'free_lists' will be freed when all samples are
processed.
Committer notes:
Fix the intel-pt.c initialization of the union with 'struct
branch_flags', that breaks the build with its unnamed union on older gcc
versions.
Uninline thread__free_stitch_list(), as it grew big and started dragging
includes to thread.h, so move it to thread.c where what it needs in
terms of headers are already there.
This fixes the build in several systems such as debian:experimental when
cross building to the MIPS32 architecture, i.e. in the other cases what
was needed was being included by sheer luck.
In file included from builtin-sched.c:11:
util/thread.h: In function 'thread__free_stitch_list':
util/thread.h:169:3: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
169 | free(pos);
| ^~~~
util/thread.h:169:3: error: incompatible implicit declaration of built-in function 'free' [-Werror]
util/thread.h:19:1: note: include '<stdlib.h>' or provide a declaration of 'free'
18 | #include "callchain.h"
+++ |+#include <stdlib.h>
19 |
util/thread.h:174:3: error: incompatible implicit declaration of built-in function 'free' [-Werror]
174 | free(pos);
| ^~~~
util/thread.h:174:3: note: include '<stdlib.h>' or provide a declaration of 'free'
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pavel Gerasimov <pavel.gerasimov@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vitaly Slobodskoy <vitaly.slobodskoy@intel.com>
Link: http://lore.kernel.org/lkml/20200319202517.23423-13-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-03-20 04:25:12 +08:00
|
|
|
struct stitch_list {
|
|
|
|
struct list_head node;
|
|
|
|
struct callchain_cursor_node cursor;
|
|
|
|
};
|
|
|
|
|
2011-01-14 11:51:58 +08:00
|
|
|
struct callchain_cursor {
|
|
|
|
u64 nr;
|
|
|
|
struct callchain_cursor_node *first;
|
|
|
|
struct callchain_cursor_node **last;
|
|
|
|
u64 pos;
|
|
|
|
struct callchain_cursor_node *curr;
|
|
|
|
};
|
|
|
|
|
2012-05-31 13:43:26 +08:00
|
|
|
extern __thread struct callchain_cursor callchain_cursor;
|
|
|
|
|
2010-08-23 02:05:22 +08:00
|
|
|
static inline void callchain_init(struct callchain_root *root)
|
2009-06-26 22:28:00 +08:00
|
|
|
{
|
2010-08-23 02:05:22 +08:00
|
|
|
INIT_LIST_HEAD(&root->node.val);
|
2015-11-21 18:23:55 +08:00
|
|
|
INIT_LIST_HEAD(&root->node.parent_val);
|
2010-07-08 12:06:17 +08:00
|
|
|
|
2010-08-23 02:05:22 +08:00
|
|
|
root->node.parent = NULL;
|
|
|
|
root->node.hit = 0;
|
2010-08-27 08:28:40 +08:00
|
|
|
root->node.children_hit = 0;
|
2013-10-11 13:15:36 +08:00
|
|
|
root->node.rb_root_in = RB_ROOT;
|
2010-08-23 02:05:22 +08:00
|
|
|
root->max_depth = 0;
|
2009-06-26 22:28:00 +08:00
|
|
|
}
|
|
|
|
|
2011-01-14 11:51:59 +08:00
|
|
|
static inline u64 callchain_cumul_hits(struct callchain_node *node)
|
2009-08-07 13:11:05 +08:00
|
|
|
{
|
|
|
|
return node->hit + node->children_hit;
|
|
|
|
}
|
|
|
|
|
2015-11-09 13:45:40 +08:00
|
|
|
static inline unsigned callchain_cumul_counts(struct callchain_node *node)
|
|
|
|
{
|
|
|
|
return node->count + node->children_count;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:52:00 +08:00
|
|
|
int callchain_register_param(struct callchain_param *param);
|
2011-01-14 11:51:58 +08:00
|
|
|
int callchain_append(struct callchain_root *root,
|
|
|
|
struct callchain_cursor *cursor,
|
|
|
|
u64 period);
|
|
|
|
|
|
|
|
int callchain_merge(struct callchain_cursor *cursor,
|
|
|
|
struct callchain_root *dst, struct callchain_root *src);
|
2010-05-09 22:47:13 +08:00
|
|
|
|
2019-01-27 18:55:39 +08:00
|
|
|
void callchain_cursor_reset(struct callchain_cursor *cursor);
|
2011-01-14 11:51:58 +08:00
|
|
|
|
|
|
|
int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
|
2019-11-04 23:14:32 +08:00
|
|
|
struct map_symbol *ms,
|
perf report: Add branch flag to callchain cursor node
Since the branch ip has been added to call stack for easier browsing,
this patch adds more branch information. For example, add a flag to
indicate if this ip is a branch, and also add with the branch flag.
Then we can know if the cursor node represents a branch and know what
the branch flag it has.
The branch history code has a loop detection pass that removes loops. It
would be nice for knowing how many loops were removed then in next
steps, we can compute out the average number of iterations.
For example:
Before remove_loops(),
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x300, to = 0x250
entry3: from = 0x300, to = 0x250
entry4: from = 0x700, to = 0x800
After remove_loops()
entry0: from = 0x100, to = 0x200
entry1: from = 0x300, to = 0x250
entry2: from = 0x700, to = 0x800
The original entry2 and entry3 are removed. So the number of iterations
(from = 0x300, to = 0x250) is equal to removed number + 1 (2 + 1).
iterations = removed number + 1;
average iteractions = Sum(iteractions) / number of samples
This formula ignores other cases, for example, iterations cross multiple
buffers and one buffer contains 2+ loops. Because in practice, it's good
enough.
Signed-off-by: Yao Jin <yao.jin@linux.intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linux-kernel@vger.kernel.org
Cc: Yao Jin <yao.jin@linux.intel.com>
Link: http://lkml.kernel.org/n/1477876794-30749-2-git-send-email-yao.jin@linux.intel.com
[ Renamed 'iter' to 'nr_loop_iter' for clarity ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-31 09:19:49 +08:00
|
|
|
bool branch, struct branch_flags *flags,
|
2017-10-10 04:32:56 +08:00
|
|
|
int nr_loop_iter, u64 iter_cycles, u64 branch_from,
|
|
|
|
const char *srcline);
|
2011-01-14 11:51:58 +08:00
|
|
|
|
|
|
|
/* Close a cursor writing session. Initialize for the reader */
|
|
|
|
static inline void callchain_cursor_commit(struct callchain_cursor *cursor)
|
|
|
|
{
|
|
|
|
cursor->curr = cursor->first;
|
|
|
|
cursor->pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cursor reading iteration helpers */
|
|
|
|
static inline struct callchain_cursor_node *
|
|
|
|
callchain_cursor_current(struct callchain_cursor *cursor)
|
|
|
|
{
|
|
|
|
if (cursor->pos == cursor->nr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return cursor->curr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
|
|
|
|
{
|
|
|
|
cursor->curr = cursor->curr->next;
|
|
|
|
cursor->pos++;
|
|
|
|
}
|
2012-12-12 03:46:05 +08:00
|
|
|
|
2016-12-06 11:40:02 +08:00
|
|
|
int callchain_cursor__copy(struct callchain_cursor *dst,
|
|
|
|
struct callchain_cursor *src);
|
|
|
|
|
2012-12-12 03:46:05 +08:00
|
|
|
struct option;
|
2014-01-14 13:25:35 +08:00
|
|
|
struct hist_entry;
|
2012-12-12 03:46:05 +08:00
|
|
|
|
|
|
|
int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset);
|
2013-10-26 22:25:33 +08:00
|
|
|
int record_callchain_opt(const struct option *opt, const char *arg, int unset);
|
|
|
|
|
2016-04-16 03:37:17 +08:00
|
|
|
struct record_opts;
|
|
|
|
|
|
|
|
int record_opts__parse_callchain(struct record_opts *record,
|
|
|
|
struct callchain_param *callchain,
|
|
|
|
const char *arg, bool unset);
|
|
|
|
|
2016-04-15 01:48:07 +08:00
|
|
|
int sample__resolve_callchain(struct perf_sample *sample,
|
|
|
|
struct callchain_cursor *cursor, struct symbol **parent,
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel, struct addr_location *al,
|
2014-01-14 13:25:35 +08:00
|
|
|
int max_stack);
|
|
|
|
int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample);
|
2013-10-31 12:58:30 +08:00
|
|
|
int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node,
|
|
|
|
bool hide_unresolved);
|
2014-01-14 13:25:35 +08:00
|
|
|
|
2012-12-12 03:46:05 +08:00
|
|
|
extern const char record_callchain_help[];
|
2016-03-24 02:06:35 +08:00
|
|
|
int parse_callchain_record(const char *arg, struct callchain_param *param);
|
2015-08-04 16:30:20 +08:00
|
|
|
int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
|
2014-04-08 02:55:24 +08:00
|
|
|
int parse_callchain_report_opt(const char *arg);
|
perf top: Support call-graph display options also
Currently 'perf top --call-graph' option is same as 'perf record'. But
'perf top' also need to receive display options in 'perf report'. To do
that, change parse_callchain_report_opt() to allow record options too.
Now perf top can receive display options like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph
<mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]>
setup and enables call-graph (stack chain/backtrace)
recording: fp dwarf lbr, output_type (graph, flat,
fractal, or none), min percent threshold, optional
print limit, callchain order, key (function or
address), add branches
$ perf top --call-graph callee,graph,fp
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445495330-25416-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-22 14:28:49 +08:00
|
|
|
int parse_callchain_top_opt(const char *arg);
|
2014-09-23 09:01:43 +08:00
|
|
|
int perf_callchain_config(const char *var, const char *value);
|
2012-09-10 12:38:00 +08:00
|
|
|
|
|
|
|
static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
|
|
|
|
struct callchain_cursor *src)
|
|
|
|
{
|
|
|
|
*dest = *src;
|
|
|
|
|
|
|
|
dest->first = src->curr;
|
|
|
|
dest->nr -= src->pos;
|
|
|
|
}
|
2014-06-25 23:49:03 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_SKIP_CALLCHAIN_IDX
|
2016-03-24 02:06:35 +08:00
|
|
|
int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain);
|
2014-06-25 23:49:03 +08:00
|
|
|
#else
|
2014-10-23 23:50:25 +08:00
|
|
|
static inline int arch_skip_callchain_idx(struct thread *thread __maybe_unused,
|
2014-06-25 23:49:03 +08:00
|
|
|
struct ip_callchain *chain __maybe_unused)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-12-17 23:45:15 +08:00
|
|
|
void arch__add_leaf_frame_record_opts(struct record_opts *opts);
|
|
|
|
|
2014-11-13 10:05:23 +08:00
|
|
|
char *callchain_list__sym_name(struct callchain_list *cl,
|
|
|
|
char *bf, size_t bfsize, bool show_dso);
|
2015-11-09 13:45:39 +08:00
|
|
|
char *callchain_node__scnprintf_value(struct callchain_node *node,
|
|
|
|
char *bf, size_t bfsize, u64 total);
|
|
|
|
int callchain_node__fprintf_value(struct callchain_node *node,
|
|
|
|
FILE *fp, u64 total);
|
2014-11-13 10:05:23 +08:00
|
|
|
|
2017-08-07 21:05:15 +08:00
|
|
|
int callchain_list_counts__printf_value(struct callchain_list *clist,
|
2016-10-31 09:19:51 +08:00
|
|
|
FILE *fp, char *bf, int bfsize);
|
|
|
|
|
2014-12-30 13:38:13 +08:00
|
|
|
void free_callchain(struct callchain_root *root);
|
2016-01-05 11:06:00 +08:00
|
|
|
void decay_callchain(struct callchain_root *root);
|
2015-11-09 13:45:43 +08:00
|
|
|
int callchain_node__make_parent_list(struct callchain_node *node);
|
2014-12-30 13:38:13 +08:00
|
|
|
|
2016-10-31 09:19:51 +08:00
|
|
|
int callchain_branch_counts(struct callchain_root *root,
|
|
|
|
u64 *branch_count, u64 *predicted_count,
|
|
|
|
u64 *abort_count, u64 *cycles_count);
|
|
|
|
|
2020-05-07 17:50:23 +08:00
|
|
|
void callchain_param_setup(u64 sample_type);
|
2020-10-09 10:28:41 +08:00
|
|
|
|
|
|
|
bool callchain_cnode_matched(struct callchain_node *base_cnode,
|
|
|
|
struct callchain_node *pair_cnode);
|
|
|
|
|
2020-10-09 10:28:43 +08:00
|
|
|
u64 callchain_total_hits(struct hists *hists);
|
|
|
|
|
2020-10-09 10:28:44 +08:00
|
|
|
s64 callchain_avg_cycles(struct callchain_node *cnode);
|
|
|
|
|
2009-09-25 00:02:18 +08:00
|
|
|
#endif /* __PERF_CALLCHAIN_H */
|