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 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-09-28 15:32:55 +02:00
|
|
|
#ifndef __PERF_HIST_H
|
|
|
|
#define __PERF_HIST_H
|
|
|
|
|
2019-01-29 12:04:58 +01:00
|
|
|
#include <linux/rbtree.h>
|
2009-12-14 13:10:39 -02:00
|
|
|
#include <linux/types.h>
|
2024-04-11 11:17:16 -07:00
|
|
|
#include "callchain.h"
|
2013-10-25 13:24:53 +02:00
|
|
|
#include "color.h"
|
2019-08-30 11:44:32 -03:00
|
|
|
#include "events_stats.h"
|
2024-04-11 11:17:16 -07:00
|
|
|
#include "evsel.h"
|
|
|
|
#include "map_symbol.h"
|
2022-08-26 09:42:28 -07:00
|
|
|
#include "mutex.h"
|
2024-04-11 11:17:16 -07:00
|
|
|
#include "sample.h"
|
|
|
|
#include "spark.h"
|
|
|
|
#include "stat.h"
|
2009-09-28 15:32:55 +02:00
|
|
|
|
2009-12-14 13:10:39 -02:00
|
|
|
struct addr_location;
|
2019-01-27 14:10:31 +01:00
|
|
|
struct mem_info;
|
2023-03-15 22:51:05 +08:00
|
|
|
struct kvm_info;
|
2019-01-27 14:10:31 +01:00
|
|
|
struct branch_info;
|
2019-09-18 10:09:54 -03:00
|
|
|
struct branch_stack;
|
2019-06-28 17:22:59 +08:00
|
|
|
struct block_info;
|
2019-08-30 11:28:14 -03:00
|
|
|
struct ui_progress;
|
2010-05-11 23:18:06 -03:00
|
|
|
|
2014-03-17 16:59:21 -03:00
|
|
|
enum hist_filter {
|
|
|
|
HIST_FILTER__DSO,
|
|
|
|
HIST_FILTER__THREAD,
|
|
|
|
HIST_FILTER__PARENT,
|
|
|
|
HIST_FILTER__SYMBOL,
|
|
|
|
HIST_FILTER__GUEST,
|
|
|
|
HIST_FILTER__HOST,
|
2015-09-04 10:45:44 -04:00
|
|
|
HIST_FILTER__SOCKET,
|
2016-08-17 14:55:23 +02:00
|
|
|
HIST_FILTER__C2C,
|
2014-03-17 16:59:21 -03:00
|
|
|
};
|
|
|
|
|
2010-07-20 14:42:52 -03:00
|
|
|
enum hist_column {
|
|
|
|
HISTC_SYMBOL,
|
2019-03-11 07:44:54 -07:00
|
|
|
HISTC_TIME,
|
2010-07-20 14:42:52 -03:00
|
|
|
HISTC_DSO,
|
|
|
|
HISTC_THREAD,
|
|
|
|
HISTC_COMM,
|
perf tools: Add 'cgroup_id' sort order keyword
This patch introduces a cgroup identifier entry field in perf report to
identify or distinguish data of different cgroups. It uses the device
number and inode number of cgroup namespace, included in perf data with
the new PERF_RECORD_NAMESPACES event, as cgroup identifier.
With the assumption that each container is created with it's own cgroup
namespace, this allows assessment/analysis of multiple containers at
once.
A simple test for this would be to clone a few processes passing
SIGCHILD & CLONE_NEWCROUP flags to each of them, execute shell and run
different workloads on each of those contexts, while running perf
record command with --namespaces option.
Shown below is the output of perf report, sorted with cgroup identifier,
on perf.data generated with the above test scenario, clearly indicating
one context's considerable use of kernel memory in comparison with
others:
$ perf report -s cgroup_id,sample --stdio
#
# Total Lost Samples: 0
#
# Samples: 5K of event 'kmem:kmalloc'
# Event count (approx.): 5965
#
# Overhead cgroup id (dev/inode) Samples
# ........ ..................... ............
#
81.27% 3/0xeffffffb 4848
16.24% 3/0xf00000d0 969
1.16% 3/0xf00000ce 69
0.82% 3/0xf00000cf 49
0.50% 0/0x0 30
While this is a start, there is further scope of improving this. For
example, instead of cgroup namespace's device and inode numbers, dev
and inode numbers of some or all namespaces may be used to distinguish
which processes are running in a given container context.
Also, scripts to map device and inode info to containers sounds
plausible for better tracing of containers.
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sargun Dhillon <sargun@sargun.me>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/148891933338.25309.756882900782042645.stgit@hbathini.in.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-08 02:12:13 +05:30
|
|
|
HISTC_CGROUP_ID,
|
2020-03-25 21:45:32 +09:00
|
|
|
HISTC_CGROUP,
|
2010-07-20 14:42:52 -03:00
|
|
|
HISTC_PARENT,
|
|
|
|
HISTC_CPU,
|
2015-09-04 10:45:43 -04:00
|
|
|
HISTC_SOCKET,
|
2013-04-05 10:26:31 +09:00
|
|
|
HISTC_SRCLINE,
|
2015-08-07 15:54:24 -07:00
|
|
|
HISTC_SRCFILE,
|
2012-02-09 23:21:01 +01:00
|
|
|
HISTC_MISPREDICT,
|
2013-09-20 07:40:41 -07:00
|
|
|
HISTC_IN_TX,
|
|
|
|
HISTC_ABORT,
|
2012-02-09 23:21:01 +01:00
|
|
|
HISTC_SYMBOL_FROM,
|
|
|
|
HISTC_SYMBOL_TO,
|
|
|
|
HISTC_DSO_FROM,
|
|
|
|
HISTC_DSO_TO,
|
2013-01-24 16:10:29 +01:00
|
|
|
HISTC_LOCAL_WEIGHT,
|
|
|
|
HISTC_GLOBAL_WEIGHT,
|
2021-01-05 11:57:51 -08:00
|
|
|
HISTC_CODE_PAGE_SIZE,
|
2013-01-24 16:10:35 +01:00
|
|
|
HISTC_MEM_DADDR_SYMBOL,
|
|
|
|
HISTC_MEM_DADDR_DSO,
|
2017-08-29 13:11:09 -04:00
|
|
|
HISTC_MEM_PHYS_DADDR,
|
2020-12-16 10:57:58 -08:00
|
|
|
HISTC_MEM_DATA_PAGE_SIZE,
|
2013-01-24 16:10:35 +01:00
|
|
|
HISTC_MEM_LOCKED,
|
|
|
|
HISTC_MEM_TLB,
|
|
|
|
HISTC_MEM_LVL,
|
|
|
|
HISTC_MEM_SNOOP,
|
2014-06-01 15:38:29 +02:00
|
|
|
HISTC_MEM_DCACHELINE,
|
2015-10-05 20:06:07 +02:00
|
|
|
HISTC_MEM_IADDR_SYMBOL,
|
2013-09-20 07:40:43 -07:00
|
|
|
HISTC_TRANSACTION,
|
2015-07-18 08:24:46 -07:00
|
|
|
HISTC_CYCLES,
|
2016-05-20 13:15:08 -07:00
|
|
|
HISTC_SRCLINE_FROM,
|
|
|
|
HISTC_SRCLINE_TO,
|
2015-12-23 02:07:04 +09:00
|
|
|
HISTC_TRACE,
|
2017-02-24 13:32:56 +00:00
|
|
|
HISTC_SYM_SIZE,
|
2018-03-27 06:09:56 -05:00
|
|
|
HISTC_DSO_SIZE,
|
2018-11-30 21:54:56 +08:00
|
|
|
HISTC_SYMBOL_IPC,
|
perf tools: Support data block and addr block
Two new data source fields, to indicate the block reasons of a load
instruction, are introduced on the Intel Sapphire Rapids server. The
fields can be used by the memory profiling.
Add a new sort function, SORT_MEM_BLOCKED, for the two fields.
For the previous platforms or the block reason is unknown, print "N/A"
for the block reason.
Add blocked as a default mem sort key for perf report and perf mem
report.
Committer testing:
So in machines without this capability we get a "N/A" filling the new "Blocked"
column:
$ perf mem record ls
arch certs CREDITS Documentation include ipc Kconfig lib MAINTAINERS mm samples security usr block
COPYING crypto drivers fs init Kbuild kernel LICENSES Makefile net README scripts sound tools
virt
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.008 MB perf.data (17 samples) ]
$
$ perf mem report --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
# Total Lost Samples: 0
#
# Samples: 6 of event 'cpu/mem-loads,ldlat=30/Pu'
# Total weight : 1381
# Sort order : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked,blocked
#
# Overhead Samples Local Weight Memory access Symbol Shared Object Data Symbol Data Object Snoop TLB access Locked Blocked
# ........ ....... ............ .................... ....................... ............. ...................... ............ ..... ............ ...... .......
#
32.87% 1 454 Local RAM or RAM hit [.] _dl_relocate_object ld-2.31.so [.] 0x00007fe91cef3078 libc-2.31.so Hit L1 or L2 hit No N/A
25.56% 1 353 LFB or LFB hit [.] strcmp ld-2.31.so [.] 0x00005586973855ca ls None L1 or L2 hit No N/A
22.59% 1 312 LFB or LFB hit [.] _dl_cache_libcmp ld-2.31.so [.] 0x00007fe91d0e3b18 ld.so.cache None L1 or L2 hit No N/A
8.47% 1 117 LFB or LFB hit [.] _dl_relocate_object ld-2.31.so [.] 0x00007fe91ceee570 libc-2.31.so None L1 or L2 hit No N/A
6.88% 1 95 LFB or LFB hit [.] _dl_relocate_object ld-2.31.so [.] 0x00007fe91ceed490 libc-2.31.so None L1 or L2 hit No N/A
3.62% 1 50 LFB or LFB hit [.] _dl_cache_libcmp ld-2.31.so [.] 0x00007fe91d0ebe60 ld.so.cache None L1 or L2 hit No N/A
# Samples: 11 of event 'cpu/mem-stores/Pu'
# Total weight : 11
# Sort order : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked,blocked
#
# Overhead Samples Local Weight Memory access Symbol Shared Object Data Symbol Data Object Snoop TLB access Locked Blocked
# ........ ....... ............ ............. ....................... ............. ...................... ........... ..... .......... ...... .......
#
9.09% 1 0 L1 hit [.] __strcoll_l libc-2.31.so [.] 0x00007fffe5648fc8 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] _dl_lookup_symbol_x ld-2.31.so [.] 0x00007fffe56490b8 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] _dl_name_match_p ld-2.31.so [.] 0x00007fffe56487d8 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] _dl_start ld-2.31.so [.] start_time+0x0 ld-2.31.so N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] _dl_sysdep_start ld-2.31.so [.] 0x00007fffe56494b8 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] do_lookup_x ld-2.31.so [.] 0x00007fffe5648ff8 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] do_lookup_x ld-2.31.so [.] 0x00007fffe5649064 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 hit [.] do_lookup_x ld-2.31.so [.] 0x00007fffe5649130 [stack] N/A N/A N/A N/A
9.09% 1 0 L1 miss [.] _dl_start ld-2.31.so [.] _rtld_global+0xaf8 ld-2.31.so N/A N/A N/A N/A
9.09% 1 0 L1 miss [.] _dl_start ld-2.31.so [.] _rtld_global+0xc28 ld-2.31.so N/A N/A N/A N/A
9.09% 1 0 L1 miss [.] _dl_start ld-2.31.so [.] 0x00007fffe56495b8 [stack] N/A N/A N/A N/A
# (Tip: Show user configuration overrides: perf config --user --list)
$
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/1612296553-21962-4-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-02-02 12:09:07 -08:00
|
|
|
HISTC_MEM_BLOCKED,
|
2021-02-02 12:09:10 -08:00
|
|
|
HISTC_LOCAL_INS_LAT,
|
|
|
|
HISTC_GLOBAL_INS_LAT,
|
2021-12-03 07:50:37 +05:30
|
|
|
HISTC_LOCAL_P_STAGE_CYC,
|
|
|
|
HISTC_GLOBAL_P_STAGE_CYC,
|
perf report: Add "addr_from" and "addr_to" sort dimensions
With the existing symbol_from/symbol_to, branches captured in the same
function would be collapsed into a single function if the latencies
associated with the each branch (cycles) were all the same. That is the
case on Intel Broadwell, for instance. Since Intel Skylake, the latency
is captured by hardware and therefore is used to disambiguate branches.
Add addr_from/addr_to sort dimensions to sort branches based on their
addresses and not the function there are in. The output is still the
function name but the offset within the function is provided to uniquely
identify each branch. These new sort dimensions also help with annotate
because they create different entries in the histogram which, in turn,
generates proper branch annotations.
Here is an example using AMD's branch sampling:
$ perf record -a -b -c 1000037 -e cpu/branch-brs/ test_prg
$ perf report
Samples: 6M of event 'cpu/branch-brs/', Event count (approx.): 6901276
Overhead Command Source Shared Object Source Symbol Target Symbol Basic Block Cycle
99.65% test_prg test_prg [.] test_thread [.] test_thread -
0.02% test_prg [kernel.vmlinux] [k] asm_sysvec_apic_timer_interrupt [k] error_entry -
$ perf report -F overhead,comm,dso,addr_from,addr_to
Samples: 6M of event 'cpu/branch-brs/', Event count (approx.): 6901276
Overhead Command Shared Object Source Address Target Address
4.22% test_prg test_prg [.] test_thread+0x3c [.] test_thread+0x4
4.13% test_prg test_prg [.] test_thread+0x4 [.] test_thread+0x3a
4.09% test_prg test_prg [.] test_thread+0x3a [.] test_thread+0x6
4.08% test_prg test_prg [.] test_thread+0x2 [.] test_thread+0x3c
4.06% test_prg test_prg [.] test_thread+0x3e [.] test_thread+0x2
3.87% test_prg test_prg [.] test_thread+0x6 [.] test_thread+0x38
3.84% test_prg test_prg [.] test_thread [.] test_thread+0x3e
3.76% test_prg test_prg [.] test_thread+0x1e [.] test_thread
3.76% test_prg test_prg [.] test_thread+0x38 [.] test_thread+0x8
3.56% test_prg test_prg [.] test_thread+0x22 [.] test_thread+0x1e
3.54% test_prg test_prg [.] test_thread+0x8 [.] test_thread+0x36
3.47% test_prg test_prg [.] test_thread+0x1c [.] test_thread+0x22
3.45% test_prg test_prg [.] test_thread+0x36 [.] test_thread+0xa
3.28% test_prg test_prg [.] test_thread+0x24 [.] test_thread+0x1c
3.25% test_prg test_prg [.] test_thread+0xa [.] test_thread+0x34
3.24% test_prg test_prg [.] test_thread+0x1a [.] test_thread+0x24
3.20% test_prg test_prg [.] test_thread+0x34 [.] test_thread+0xc
3.04% test_prg test_prg [.] test_thread+0x26 [.] test_thread+0x1a
3.01% test_prg test_prg [.] test_thread+0xc [.] test_thread+0x32
2.98% test_prg test_prg [.] test_thread+0x18 [.] test_thread+0x26
2.94% test_prg test_prg [.] test_thread+0x32 [.] test_thread+0xe
2.76% test_prg test_prg [.] test_thread+0x28 [.] test_thread+0x18
2.73% test_prg test_prg [.] test_thread+0xe [.] test_thread+0x30
2.67% test_prg test_prg [.] test_thread+0x30 [.] test_thread+0x10
2.67% test_prg test_prg [.] test_thread+0x16 [.] test_thread+0x28
2.46% test_prg test_prg [.] test_thread+0x10 [.] test_thread+0x2e
2.44% test_prg test_prg [.] test_thread+0x2a [.] test_thread+0x16
2.38% test_prg test_prg [.] test_thread+0x14 [.] test_thread+0x2a
2.32% test_prg test_prg [.] test_thread+0x2e [.] test_thread+0x12
2.28% test_prg test_prg [.] test_thread+0x12 [.] test_thread+0x2c
2.16% test_prg test_prg [.] test_thread+0x2c [.] test_thread+0x14
0.02% test_prg [kernel.vmlinux] [k] asm_sysvec_apic_ti+0x5 [k] error_entry
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Link: http://lore.kernel.org/lkml/20220208211637.2221872-13-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-02-08 13:16:37 -08:00
|
|
|
HISTC_ADDR_FROM,
|
|
|
|
HISTC_ADDR_TO,
|
2022-09-23 10:31:41 -07:00
|
|
|
HISTC_ADDR,
|
perf report: Add 'simd' sort field
Add 'simd' sort field to visualize SIMD ops in 'perf report'.
Rows are labeled with the SIMD ISA, and the type of predicate (if any):
- [p] partial predicate
- [e] empty predicate (no elements in the vector being used)
Example with Arm SPE and SVE (Scalable Vector Extension):
#include <arm_sve.h>
double src[1025], dst[1025];
int main(void) {
svfloat64_t vc = svdup_f64(1);
for(;;)
for(int i = 0; i < 1025; i += svcntd())
{
svbool_t pg = svwhilelt_b64(i, 1025);
svfloat64_t vsrc = svld1(pg, &src[i]);
svfloat64_t vdst = svadd_x(pg, vsrc, vc);
svst1(pg, &dst[i], vdst);
}
return 0;
}
... compiled using "gcc-11 -march=armv8-a+sve -O3"
Profiling on a platform that implements FEAT_SVE and FEAT_SPEv1p1:
$ perf record -e arm_spe_0// -- ./a.out
$ perf report --itrace=i1i -s overhead,pid,simd,sym
Overhead Pid:Command Simd Symbol
........ ................ ....... ......................
53.76% 10758:program [.] main
46.14% 10758:program [.] SVE [.] main
0.09% 10758:program [p] SVE [.] main
The report shows 0.09% of the sampled SVE operations use partial
predicates due to src and dst arrays not being multiples of the vector
register lengths.
Signed-off-by: German Gomez <german.gomez@arm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman.Khandual@arm.com
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230320151509.1137462-2-james.clark@arm.com
Signed-off-by: James Clark <james.clark@arm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-03-20 15:15:08 +00:00
|
|
|
HISTC_SIMD,
|
2023-12-12 16:13:14 -08:00
|
|
|
HISTC_TYPE,
|
perf report: Add 'typeoff' sort key
The typeoff sort key shows the data type name, offset and the name of
the field. This is useful to see which field in the struct is accessed
most frequently.
$ perf report -s type,typeoff --hierarchy --stdio
...
# Overhead Data Type / Data Type Offset
# ............ ............................
#
...
1.23% struct cfs_rq
0.19% struct cfs_rq +404 (throttle_count)
0.19% struct cfs_rq +0 (load.weight)
0.19% struct cfs_rq +336 (leaf_cfs_rq_list.next)
0.09% struct cfs_rq +272 (propagate)
0.09% struct cfs_rq +196 (removed.nr)
0.09% struct cfs_rq +80 (curr)
0.09% struct cfs_rq +544 (lt_b_children_throttled)
0.06% struct cfs_rq +320 (rq)
Committer testing:
Again with the perf.data from the previous csets:
# perf report --stdio -s type,typeoff
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 4 of event 'cpu_atom/mem-loads,ldlat=30/P'
# Event count (approx.): 7
#
# Overhead Data Type Data Type Offset
# ........ ......... ................
#
42.86% struct list_head struct list_head +8 (prev)
42.86% (unknown) (unknown) +0 (no field)
14.29% char char +0 (no field)
#
# (Tip: To see callchains in a more compact form: perf report -g folded)
#
# perf report --stdio -s dso,type,typeoff
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 4 of event 'cpu_atom/mem-loads,ldlat=30/P'
# Event count (approx.): 7
#
# Overhead Shared Object Data Type Data Type Offset
# ........ .................... ......... ................
#
42.86% [kernel.kallsyms] struct list_head struct list_head +8 (prev)
28.57% libc.so.6 (unknown) (unknown) +0 (no field)
14.29% [kernel.kallsyms] char char +0 (no field)
14.29% ld-linux-x86-64.so.2 (unknown) (unknown) +0 (no field)
#
# (Tip: If you have debuginfo enabled, try: perf report -s sym,srcline)
#
#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: linux-toolchains@vger.kernel.org
Cc: linux-trace-devel@vger.kernel.org
Link: https://lore.kernel.org/r/20231213001323.718046-13-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-12-12 16:13:18 -08:00
|
|
|
HISTC_TYPE_OFFSET,
|
2023-12-12 16:13:19 -08:00
|
|
|
HISTC_SYMBOL_OFFSET,
|
2010-07-20 14:42:52 -03:00
|
|
|
HISTC_NR_COLS, /* Last entry */
|
|
|
|
};
|
|
|
|
|
2011-10-18 19:07:34 -02:00
|
|
|
struct thread;
|
|
|
|
struct dso;
|
|
|
|
|
perf hist: Introduce hists class and move lots of methods to it
In cbbc79a we introduced support for multiple events by introducing a
new "event_stat_id" struct and then made several perf_session methods
receive a point to it instead of a pointer to perf_session, and kept the
event_stats and hists rb_tree in perf_session.
While working on the new newt based browser, I realised that it would be
better to introduce a new class, "hists" (short for "histograms"),
renaming the "event_stat_id" struct and the perf_session methods that
were really "hists" methods, as they manipulate only struct hists
members, not touching anything in the other perf_session members.
Other optimizations, such as calculating the maximum lenght of a symbol
name present in an hists instance will be possible as we add them,
avoiding a re-traversal just for finding that information.
The rationale for the name "hists" to replace "event_stat_id" is that we
may have multiple sets of hists for the same event_stat id, as, for
instance, the 'perf diff' tool has, so event stat id is not what
characterizes what this struct and the functions that manipulate it do.
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-10 13:04:11 -03:00
|
|
|
struct hists {
|
2018-12-06 11:18:18 -08:00
|
|
|
struct rb_root_cached entries_in_array[2];
|
|
|
|
struct rb_root_cached *entries_in;
|
|
|
|
struct rb_root_cached entries;
|
|
|
|
struct rb_root_cached entries_collapsed;
|
2010-05-10 13:57:51 -03:00
|
|
|
u64 nr_entries;
|
2013-12-26 15:11:52 +09:00
|
|
|
u64 nr_non_filtered_entries;
|
2016-02-16 23:08:19 +09:00
|
|
|
u64 callchain_period;
|
|
|
|
u64 callchain_non_filtered_period;
|
2015-03-02 22:21:35 -03:00
|
|
|
struct thread *thread_filter;
|
2011-10-18 19:07:34 -02:00
|
|
|
const struct dso *dso_filter;
|
2012-01-19 14:08:15 -02:00
|
|
|
const char *uid_filter_str;
|
2012-03-16 17:50:51 +09:00
|
|
|
const char *symbol_filter_str;
|
2022-08-26 09:42:28 -07:00
|
|
|
struct mutex lock;
|
2021-04-26 18:37:13 -07:00
|
|
|
struct hists_stats stats;
|
perf hist: Introduce hists class and move lots of methods to it
In cbbc79a we introduced support for multiple events by introducing a
new "event_stat_id" struct and then made several perf_session methods
receive a point to it instead of a pointer to perf_session, and kept the
event_stats and hists rb_tree in perf_session.
While working on the new newt based browser, I realised that it would be
better to introduce a new class, "hists" (short for "histograms"),
renaming the "event_stat_id" struct and the perf_session methods that
were really "hists" methods, as they manipulate only struct hists
members, not touching anything in the other perf_session members.
Other optimizations, such as calculating the maximum lenght of a symbol
name present in an hists instance will be possible as we add them,
avoiding a re-traversal just for finding that information.
The rationale for the name "hists" to replace "event_stat_id" is that we
may have multiple sets of hists for the same event_stat id, as, for
instance, the 'perf diff' tool has, so event stat id is not what
characterizes what this struct and the functions that manipulate it do.
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-10 13:04:11 -03:00
|
|
|
u64 event_stream;
|
2010-07-20 14:42:52 -03:00
|
|
|
u16 col_len[HISTC_NR_COLS];
|
2018-06-07 14:42:27 -03:00
|
|
|
bool has_callchains;
|
2015-09-04 10:45:44 -04:00
|
|
|
int socket_filter;
|
2016-01-18 10:24:22 +01:00
|
|
|
struct perf_hpp_list *hpp_list;
|
2016-03-07 16:44:45 -03:00
|
|
|
struct list_head hpp_formats;
|
2016-03-07 16:44:48 -03:00
|
|
|
int nr_hpp_node;
|
perf hist: Introduce hists class and move lots of methods to it
In cbbc79a we introduced support for multiple events by introducing a
new "event_stat_id" struct and then made several perf_session methods
receive a point to it instead of a pointer to perf_session, and kept the
event_stats and hists rb_tree in perf_session.
While working on the new newt based browser, I realised that it would be
better to introduce a new class, "hists" (short for "histograms"),
renaming the "event_stat_id" struct and the perf_session methods that
were really "hists" methods, as they manipulate only struct hists
members, not touching anything in the other perf_session members.
Other optimizations, such as calculating the maximum lenght of a symbol
name present in an hists instance will be possible as we add them,
avoiding a re-traversal just for finding that information.
The rationale for the name "hists" to replace "event_stat_id" is that we
may have multiple sets of hists for the same event_stat id, as, for
instance, the 'perf diff' tool has, so event stat id is not what
characterizes what this struct and the functions that manipulate it do.
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-10 13:04:11 -03:00
|
|
|
};
|
|
|
|
|
2016-05-03 13:54:42 +02:00
|
|
|
#define hists__has(__h, __f) (__h)->hpp_list->__f
|
|
|
|
|
2013-10-30 09:40:34 +09:00
|
|
|
struct hist_entry_iter;
|
|
|
|
|
|
|
|
struct hist_iter_ops {
|
|
|
|
int (*prepare_entry)(struct hist_entry_iter *, struct addr_location *);
|
|
|
|
int (*add_single_entry)(struct hist_entry_iter *, struct addr_location *);
|
|
|
|
int (*next_entry)(struct hist_entry_iter *, struct addr_location *);
|
|
|
|
int (*add_next_entry)(struct hist_entry_iter *, struct addr_location *);
|
|
|
|
int (*finish_entry)(struct hist_entry_iter *, struct addr_location *);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hist_entry_iter {
|
|
|
|
int total;
|
|
|
|
int curr;
|
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel;
|
2013-10-30 09:40:34 +09:00
|
|
|
struct perf_sample *sample;
|
|
|
|
struct hist_entry *he;
|
|
|
|
struct symbol *parent;
|
2024-05-07 11:35:45 -07:00
|
|
|
|
|
|
|
struct mem_info *mi;
|
|
|
|
struct branch_info *bi;
|
|
|
|
struct hist_entry **he_cache;
|
2013-10-30 09:40:34 +09:00
|
|
|
|
|
|
|
const struct hist_iter_ops *ops;
|
2014-01-07 17:02:25 +09:00
|
|
|
/* user-defined callback function (optional) */
|
|
|
|
int (*add_entry_cb)(struct hist_entry_iter *iter,
|
|
|
|
struct addr_location *al, bool single, void *arg);
|
2024-05-07 11:35:45 -07:00
|
|
|
bool hide_unresolved;
|
2013-10-30 09:40:34 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct hist_iter_ops hist_iter_normal;
|
|
|
|
extern const struct hist_iter_ops hist_iter_branch;
|
|
|
|
extern const struct hist_iter_ops hist_iter_mem;
|
2012-09-11 14:13:04 +09:00
|
|
|
extern const struct hist_iter_ops hist_iter_cumulative;
|
2013-10-30 09:40:34 +09:00
|
|
|
|
2024-04-11 11:17:16 -07:00
|
|
|
struct res_sample {
|
|
|
|
u64 time;
|
|
|
|
int cpu;
|
|
|
|
int tid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct he_stat {
|
|
|
|
u64 period;
|
|
|
|
u64 period_sys;
|
|
|
|
u64 period_us;
|
|
|
|
u64 period_guest_sys;
|
|
|
|
u64 period_guest_us;
|
2024-04-11 11:17:17 -07:00
|
|
|
u64 weight1;
|
|
|
|
u64 weight2;
|
|
|
|
u64 weight3;
|
2024-04-11 11:17:16 -07:00
|
|
|
u32 nr_events;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct namespace_id {
|
|
|
|
u64 dev;
|
|
|
|
u64 ino;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hist_entry_diff {
|
|
|
|
bool computed;
|
|
|
|
union {
|
|
|
|
/* PERF_HPP__DELTA */
|
|
|
|
double period_ratio_delta;
|
|
|
|
|
|
|
|
/* PERF_HPP__RATIO */
|
|
|
|
double period_ratio;
|
|
|
|
|
|
|
|
/* HISTC_WEIGHTED_DIFF */
|
|
|
|
s64 wdiff;
|
|
|
|
|
|
|
|
/* PERF_HPP_DIFF__CYCLES */
|
|
|
|
s64 cycles;
|
|
|
|
};
|
|
|
|
struct stats stats;
|
|
|
|
unsigned long svals[NUM_SPARKS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hist_entry_ops {
|
|
|
|
void *(*new)(size_t size);
|
|
|
|
void (*free)(void *ptr);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct hist_entry - histogram entry
|
|
|
|
*
|
|
|
|
* @row_offset - offset from the first callchain expanded to appear on screen
|
|
|
|
* @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
|
|
|
|
*/
|
|
|
|
struct hist_entry {
|
|
|
|
struct rb_node rb_node_in;
|
|
|
|
struct rb_node rb_node;
|
|
|
|
union {
|
|
|
|
struct list_head node;
|
|
|
|
struct list_head head;
|
|
|
|
} pairs;
|
|
|
|
struct he_stat stat;
|
|
|
|
struct he_stat *stat_acc;
|
|
|
|
struct map_symbol ms;
|
|
|
|
struct thread *thread;
|
|
|
|
struct comm *comm;
|
|
|
|
struct namespace_id cgroup_id;
|
|
|
|
u64 cgroup;
|
|
|
|
u64 ip;
|
|
|
|
u64 transaction;
|
|
|
|
s32 socket;
|
|
|
|
s32 cpu;
|
|
|
|
u64 code_page_size;
|
|
|
|
u64 weight;
|
|
|
|
u64 ins_lat;
|
|
|
|
u64 p_stage_cyc;
|
|
|
|
u8 cpumode;
|
|
|
|
u8 depth;
|
|
|
|
int mem_type_off;
|
|
|
|
struct simd_flags simd_flags;
|
|
|
|
|
|
|
|
/* We are added by hists__add_dummy_entry. */
|
|
|
|
bool dummy;
|
|
|
|
bool leaf;
|
|
|
|
|
|
|
|
char level;
|
|
|
|
u8 filtered;
|
|
|
|
|
|
|
|
u16 callchain_size;
|
|
|
|
union {
|
|
|
|
/*
|
|
|
|
* Since perf diff only supports the stdio output, TUI
|
|
|
|
* fields are only accessed from perf report (or perf
|
|
|
|
* top). So make it a union to reduce memory usage.
|
|
|
|
*/
|
|
|
|
struct hist_entry_diff diff;
|
|
|
|
struct /* for TUI */ {
|
|
|
|
u16 row_offset;
|
|
|
|
u16 nr_rows;
|
|
|
|
bool init_have_children;
|
|
|
|
bool unfolded;
|
|
|
|
bool has_children;
|
|
|
|
bool has_no_entry;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
char *srcline;
|
|
|
|
char *srcfile;
|
|
|
|
struct symbol *parent;
|
|
|
|
struct branch_info *branch_info;
|
|
|
|
long time;
|
|
|
|
struct hists *hists;
|
|
|
|
struct mem_info *mem_info;
|
|
|
|
struct block_info *block_info;
|
|
|
|
struct kvm_info *kvm_info;
|
|
|
|
void *raw_data;
|
|
|
|
u32 raw_size;
|
|
|
|
int num_res;
|
|
|
|
struct res_sample *res_samples;
|
|
|
|
void *trace_output;
|
|
|
|
struct perf_hpp_list *hpp_list;
|
|
|
|
struct hist_entry *parent_he;
|
|
|
|
struct hist_entry_ops *ops;
|
|
|
|
struct annotated_data_type *mem_type;
|
|
|
|
union {
|
|
|
|
/* this is for hierarchical entry structure */
|
|
|
|
struct {
|
|
|
|
struct rb_root_cached hroot_in;
|
|
|
|
struct rb_root_cached hroot_out;
|
|
|
|
}; /* non-leaf entries */
|
|
|
|
struct rb_root sorted_chain; /* leaf entry has callchains */
|
|
|
|
};
|
|
|
|
struct callchain_root callchain[0]; /* must be last member */
|
|
|
|
};
|
|
|
|
|
|
|
|
static __pure inline bool hist_entry__has_callchains(struct hist_entry *he)
|
|
|
|
{
|
|
|
|
return he->callchain_size != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool hist_entry__has_pairs(struct hist_entry *he)
|
|
|
|
{
|
|
|
|
return !list_empty(&he->pairs.node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct hist_entry *hist_entry__next_pair(struct hist_entry *he)
|
|
|
|
{
|
|
|
|
if (hist_entry__has_pairs(he))
|
|
|
|
return list_entry(he->pairs.node.next, struct hist_entry, pairs.node);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void hist_entry__add_pair(struct hist_entry *pair,
|
|
|
|
struct hist_entry *he)
|
|
|
|
{
|
|
|
|
list_add_tail(&pair->pairs.node, &he->pairs.head);
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:19:21 +02:00
|
|
|
struct hist_entry *hists__add_entry(struct hists *hists,
|
|
|
|
struct addr_location *al,
|
|
|
|
struct symbol *parent,
|
|
|
|
struct branch_info *bi,
|
|
|
|
struct mem_info *mi,
|
2023-03-15 22:51:05 +08:00
|
|
|
struct kvm_info *ki,
|
2016-06-14 20:19:21 +02:00
|
|
|
struct perf_sample *sample,
|
|
|
|
bool sample_self);
|
2016-07-05 08:56:05 +02:00
|
|
|
|
|
|
|
struct hist_entry *hists__add_entry_ops(struct hists *hists,
|
|
|
|
struct hist_entry_ops *ops,
|
|
|
|
struct addr_location *al,
|
|
|
|
struct symbol *sym_parent,
|
|
|
|
struct branch_info *bi,
|
|
|
|
struct mem_info *mi,
|
2023-03-15 22:51:05 +08:00
|
|
|
struct kvm_info *ki,
|
2016-07-05 08:56:05 +02:00
|
|
|
struct perf_sample *sample,
|
|
|
|
bool sample_self);
|
|
|
|
|
2019-06-28 17:22:59 +08:00
|
|
|
struct hist_entry *hists__add_entry_block(struct hists *hists,
|
|
|
|
struct addr_location *al,
|
|
|
|
struct block_info *bi);
|
|
|
|
|
2013-10-30 09:40:34 +09:00
|
|
|
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
|
2014-01-07 17:02:25 +09:00
|
|
|
int max_stack_depth, void *arg);
|
2013-10-30 09:40:34 +09:00
|
|
|
|
perf hists: Do column alignment on the format iterator
We were doing column alignment in the format function for each cell,
returning a string padded with spaces so that when the next column is
printed the cursor is at its column alignment.
This ends up needlessly printing trailing spaces, do it at the format
iterator, that is where we know if it is needed, i.e. if there is more
columns to be printed.
This eliminates the need for triming lines when doing a dump using 'P'
in the TUI browser and also produces far saner results with things like
piping 'perf report' to 'less'.
Right now only the formatters for sym->name and the 'locked' column
(perf mem report), that are the ones that end up at the end of lines
in the default 'perf report', 'perf top' and 'perf mem report' tools,
the others will be done in a subsequent patch.
In the end the 'width' parameter for the formatters now mean, in
'printf' terms, the 'precision', where before it was the field 'width'.
Reported-by: Dave Jones <davej@codemonkey.org.uk>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-s7iwl2gj23w92l6tibnrcqzr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-11 17:14:13 -03:00
|
|
|
struct perf_hpp;
|
|
|
|
struct perf_hpp_fmt;
|
|
|
|
|
2012-01-04 12:27:03 -02:00
|
|
|
int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right);
|
|
|
|
int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right);
|
2013-09-20 07:40:43 -07:00
|
|
|
int hist_entry__transaction_len(void);
|
2013-11-05 15:32:36 -03:00
|
|
|
int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
|
2012-08-20 13:52:06 +09:00
|
|
|
struct hists *hists);
|
perf hists: Do column alignment on the format iterator
We were doing column alignment in the format function for each cell,
returning a string padded with spaces so that when the next column is
printed the cursor is at its column alignment.
This ends up needlessly printing trailing spaces, do it at the format
iterator, that is where we know if it is needed, i.e. if there is more
columns to be printed.
This eliminates the need for triming lines when doing a dump using 'P'
in the TUI browser and also produces far saner results with things like
piping 'perf report' to 'less'.
Right now only the formatters for sym->name and the 'locked' column
(perf mem report), that are the ones that end up at the end of lines
in the default 'perf report', 'perf top' and 'perf mem report' tools,
the others will be done in a subsequent patch.
In the end the 'width' parameter for the formatters now mean, in
'printf' terms, the 'precision', where before it was the field 'width'.
Reported-by: Dave Jones <davej@codemonkey.org.uk>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-s7iwl2gj23w92l6tibnrcqzr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-11 17:14:13 -03:00
|
|
|
int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
|
|
|
|
struct perf_hpp_fmt *fmt, int printed);
|
2024-04-11 11:17:16 -07:00
|
|
|
int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, size_t size,
|
|
|
|
unsigned int width);
|
2014-12-19 12:31:40 -03:00
|
|
|
void hist_entry__delete(struct hist_entry *he);
|
2009-12-14 13:10:39 -02:00
|
|
|
|
2019-02-04 15:18:06 +01:00
|
|
|
typedef int (*hists__resort_cb_t)(struct hist_entry *he, void *arg);
|
2016-08-01 20:02:34 +02:00
|
|
|
|
2020-05-06 12:58:55 -03:00
|
|
|
void evsel__output_resort_cb(struct evsel *evsel, struct ui_progress *prog,
|
|
|
|
hists__resort_cb_t cb, void *cb_arg);
|
|
|
|
void evsel__output_resort(struct evsel *evsel, struct ui_progress *prog);
|
2014-12-22 13:44:10 +09:00
|
|
|
void hists__output_resort(struct hists *hists, struct ui_progress *prog);
|
2016-08-01 20:02:34 +02:00
|
|
|
void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
|
|
|
|
hists__resort_cb_t cb);
|
2016-02-16 23:08:25 +09:00
|
|
|
int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
|
2010-05-14 10:36:42 -03:00
|
|
|
|
2011-10-17 09:05:04 -02:00
|
|
|
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
|
2014-08-12 17:16:05 +09:00
|
|
|
void hists__delete_entries(struct hists *hists);
|
perf top: Reuse the 'report' hist_entry/hists classes
This actually fixes several problems we had in the old 'perf top':
1. Unresolved symbols not show, limitation that came from the old
"KernelTop" codebase, to solve it we would need to do changes
that would make sym_entry have most of the hist_entry fields.
2. It was using the number of samples, not the sum of sample->period.
And brings the --sort code that allows us to have all the views in
'perf report', for instance:
[root@emilia ~]# perf top --sort dso
PerfTop: 5903 irqs/sec kernel:77.5% exact: 0.0% [1000Hz cycles], (all, 8 CPUs)
------------------------------------------------------------------------------
31.59% libcrypto.so.1.0.0
21.55% [kernel]
18.57% libpython2.6.so.1.0
7.04% libc-2.12.so
6.99% _backend_agg.so
4.72% sshd
1.48% multiarray.so
1.39% libfreetype.so.6.3.22
1.37% perf
0.71% libgobject-2.0.so.0.2200.5
0.53% [tg3]
0.48% libglib-2.0.so.0.2200.5
0.44% libstdc++.so.6.0.13
0.40% libcairo.so.2.10800.8
0.38% libm-2.12.so
0.34% umath.so
0.30% libgdk-x11-2.0.so.0.1800.9
0.22% libpthread-2.12.so
0.20% libgtk-x11-2.0.so.0.1800.9
0.20% librt-2.12.so
0.15% _path.so
0.13% libpango-1.0.so.0.2800.1
0.11% libatlas.so.3.0
0.09% ft2font.so
0.09% libpangoft2-1.0.so.0.2800.1
0.08% libX11.so.6.3.0
0.07% [vdso]
0.06% cyclictest
^C
All the filter lists can be used as well: --dsos, --comms, --symbols,
etc.
The 'perf report' TUI is also reused, being possible to apply all the
zoom operations, do annotation, etc.
This change will allow multiple simplifications in the symbol system as
well, that will be detailed in upcoming changesets.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-xzaaldxq7zhqrrxdxjifk1mh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2011-10-05 19:16:15 -03:00
|
|
|
void hists__output_recalc_col_len(struct hists *hists, int max_rows);
|
|
|
|
|
2019-06-28 17:23:03 +08:00
|
|
|
struct hist_entry *hists__get_entry(struct hists *hists, int idx);
|
|
|
|
|
2014-01-14 11:52:48 +09:00
|
|
|
u64 hists__total_period(struct hists *hists);
|
2014-04-24 16:37:26 +09:00
|
|
|
void hists__reset_stats(struct hists *hists);
|
2014-04-24 16:21:46 +09:00
|
|
|
void hists__inc_stats(struct hists *hists, struct hist_entry *h);
|
2021-04-26 18:37:13 -07:00
|
|
|
void hists__inc_nr_events(struct hists *hists);
|
2014-05-28 14:12:18 +09:00
|
|
|
void hists__inc_nr_samples(struct hists *hists, bool filtered);
|
2022-09-01 12:57:38 -07:00
|
|
|
void hists__inc_nr_lost_samples(struct hists *hists, u32 lost);
|
2010-05-14 10:36:42 -03:00
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
|
2016-06-14 20:19:18 +02:00
|
|
|
int max_cols, float min_pcnt, FILE *fp,
|
2018-06-20 15:58:20 -03:00
|
|
|
bool ignore_callchains);
|
2021-04-26 18:37:15 -07:00
|
|
|
size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp,
|
|
|
|
bool skip_empty);
|
2010-05-11 11:10:15 -03:00
|
|
|
|
2011-10-18 19:07:34 -02:00
|
|
|
void hists__filter_by_dso(struct hists *hists);
|
|
|
|
void hists__filter_by_thread(struct hists *hists);
|
2012-03-16 17:50:51 +09:00
|
|
|
void hists__filter_by_symbol(struct hists *hists);
|
2015-09-04 10:45:45 -04:00
|
|
|
void hists__filter_by_socket(struct hists *hists);
|
2010-05-11 11:10:15 -03:00
|
|
|
|
2014-04-22 14:49:31 +09:00
|
|
|
static inline bool hists__has_filter(struct hists *hists)
|
|
|
|
{
|
|
|
|
return hists->thread_filter || hists->dso_filter ||
|
2015-09-04 10:45:44 -04:00
|
|
|
hists->symbol_filter_str || (hists->socket_filter > -1);
|
2014-04-22 14:49:31 +09:00
|
|
|
}
|
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
u16 hists__col_len(struct hists *hists, enum hist_column col);
|
|
|
|
void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len);
|
|
|
|
bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len);
|
2012-08-20 13:52:05 +09:00
|
|
|
void hists__reset_col_len(struct hists *hists);
|
|
|
|
void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
|
2010-07-20 14:42:52 -03:00
|
|
|
|
2012-11-08 17:54:33 -03:00
|
|
|
void hists__match(struct hists *leader, struct hists *other);
|
2012-11-08 18:03:09 -03:00
|
|
|
int hists__link(struct hists *leader, struct hists *other);
|
2019-08-28 08:15:55 +09:00
|
|
|
int hists__unlink(struct hists *hists);
|
2012-11-08 17:54:33 -03:00
|
|
|
|
2024-04-11 11:17:16 -07:00
|
|
|
static inline float hist_entry__get_percent_limit(struct hist_entry *he)
|
|
|
|
{
|
|
|
|
u64 period = he->stat.period;
|
|
|
|
u64 total_period = hists__total_period(he->hists);
|
|
|
|
|
|
|
|
if (unlikely(total_period == 0))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (symbol_conf.cumulate_callchain)
|
|
|
|
period = he->stat_acc->period;
|
|
|
|
|
|
|
|
return period * 100.0 / total_period;
|
|
|
|
}
|
|
|
|
|
2014-10-09 16:16:00 -03:00
|
|
|
struct hists_evsel {
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel evsel;
|
2014-10-09 16:16:00 -03:00
|
|
|
struct hists hists;
|
|
|
|
};
|
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
static inline struct evsel *hists_to_evsel(struct hists *hists)
|
2014-10-09 16:16:00 -03:00
|
|
|
{
|
|
|
|
struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists);
|
|
|
|
return &hevsel->evsel;
|
|
|
|
}
|
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
static inline struct hists *evsel__hists(struct evsel *evsel)
|
2014-10-09 16:16:00 -03:00
|
|
|
{
|
|
|
|
struct hists_evsel *hevsel = (struct hists_evsel *)evsel;
|
|
|
|
return &hevsel->hists;
|
|
|
|
}
|
|
|
|
|
perf hists: Check if a hist_entry has callchains before using them
So far if we use 'perf record -g' this will make
symbol_conf.use_callchain 'true' and logic will assume that all events
have callchains enabled, but ever since we added the possibility of
setting up callchains for some events (e.g.: -e
cycles/call-graph=dwarf/) while not for others, we limit usage scenarios
by looking at that symbol_conf.use_callchain global boolean, we better
look at each event attributes.
On the road to that we need to look if a hist_entry has callchains, that
is, to go from hist_entry->hists to the evsel that contains it, to then
look at evsel->sample_type for PERF_SAMPLE_CALLCHAIN.
The next step is to add a symbol_conf.ignore_callchains global, to use
in the places where what we really want to know is if callchains should
be ignored, even if present.
Then -g will mean just to select a callchain mode to be applied to all
events not explicitely setting some other callchain mode, i.e. a default
callchain mode, and --no-call-graph will set
symbol_conf.ignore_callchains with that clear intention.
That too will at some point become a per evsel thing, that tools can set
for all or just a few of its evsels.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-0sas5cm4dsw2obn75g7ruz69@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-29 13:59:24 -03:00
|
|
|
static __pure inline bool hists__has_callchains(struct hists *hists)
|
|
|
|
{
|
2018-06-07 14:42:27 -03:00
|
|
|
return hists->has_callchains;
|
perf hists: Check if a hist_entry has callchains before using them
So far if we use 'perf record -g' this will make
symbol_conf.use_callchain 'true' and logic will assume that all events
have callchains enabled, but ever since we added the possibility of
setting up callchains for some events (e.g.: -e
cycles/call-graph=dwarf/) while not for others, we limit usage scenarios
by looking at that symbol_conf.use_callchain global boolean, we better
look at each event attributes.
On the road to that we need to look if a hist_entry has callchains, that
is, to go from hist_entry->hists to the evsel that contains it, to then
look at evsel->sample_type for PERF_SAMPLE_CALLCHAIN.
The next step is to add a symbol_conf.ignore_callchains global, to use
in the places where what we really want to know is if callchains should
be ignored, even if present.
Then -g will mean just to select a callchain mode to be applied to all
events not explicitely setting some other callchain mode, i.e. a default
callchain mode, and --no-call-graph will set
symbol_conf.ignore_callchains with that clear intention.
That too will at some point become a per evsel thing, that tools can set
for all or just a few of its evsels.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-0sas5cm4dsw2obn75g7ruz69@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-05-29 13:59:24 -03:00
|
|
|
}
|
|
|
|
|
2014-10-09 16:16:00 -03:00
|
|
|
int hists__init(void);
|
2016-01-18 10:24:22 +01:00
|
|
|
int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
|
2016-01-07 10:14:10 +01:00
|
|
|
|
2018-12-06 11:18:18 -08:00
|
|
|
struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists);
|
2014-10-09 16:16:00 -03:00
|
|
|
|
2012-09-03 11:53:06 +09:00
|
|
|
struct perf_hpp {
|
|
|
|
char *buf;
|
|
|
|
size_t size;
|
|
|
|
const char *sep;
|
|
|
|
void *ptr;
|
2019-06-28 17:23:03 +08:00
|
|
|
bool skip;
|
2012-09-03 11:53:06 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
struct perf_hpp_fmt {
|
2014-07-31 14:47:40 +09:00
|
|
|
const char *name;
|
2014-03-10 16:43:52 +09:00
|
|
|
int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
2016-08-07 17:28:30 +02:00
|
|
|
struct hists *hists, int line, int *span);
|
2014-03-10 16:43:52 +09:00
|
|
|
int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
2016-06-14 20:19:20 +02:00
|
|
|
struct hists *hists);
|
2022-12-15 11:28:14 -08:00
|
|
|
void (*init)(struct perf_hpp_fmt *fmt, struct hist_entry *he);
|
2013-01-31 23:31:11 +01:00
|
|
|
int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he);
|
|
|
|
int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he);
|
2015-01-08 09:45:46 +09:00
|
|
|
int64_t (*cmp)(struct perf_hpp_fmt *fmt,
|
|
|
|
struct hist_entry *a, struct hist_entry *b);
|
|
|
|
int64_t (*collapse)(struct perf_hpp_fmt *fmt,
|
|
|
|
struct hist_entry *a, struct hist_entry *b);
|
|
|
|
int64_t (*sort)(struct perf_hpp_fmt *fmt,
|
|
|
|
struct hist_entry *a, struct hist_entry *b);
|
2016-01-18 10:24:03 +01:00
|
|
|
bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
|
2016-01-18 10:24:09 +01:00
|
|
|
void (*free)(struct perf_hpp_fmt *fmt);
|
2012-10-13 00:06:16 +02:00
|
|
|
|
|
|
|
struct list_head list;
|
2014-03-03 11:46:55 +09:00
|
|
|
struct list_head sort_list;
|
perf tools: Move elide bool into perf_hpp_fmt struct
After output/sort fields refactoring, it's expensive
to check the elide bool in its current location inside
the 'struct sort_entry'.
The perf_hpp__should_skip function gets highly noticable in
workloads with high number of output/sort fields, like for:
$ perf report -i perf-test.data -F overhead,sample,period,comm,pid,dso,symbol,cpu --stdio
Performance report:
9.70% perf [.] perf_hpp__should_skip
Moving the elide bool into the 'struct perf_hpp_fmt', which
makes the perf_hpp__should_skip just single struct read.
Got speedup of around 22% for my test perf.data workload.
The change should not harm any other workload types.
Performance counter stats for (10 runs):
before:
358,319,732,626 cycles ( +- 0.55% )
467,129,581,515 instructions # 1.30 insns per cycle ( +- 0.00% )
150.943975206 seconds time elapsed ( +- 0.62% )
now:
278,785,972,990 cycles ( +- 0.12% )
370,146,797,640 instructions # 1.33 insns per cycle ( +- 0.00% )
116.416670507 seconds time elapsed ( +- 0.31% )
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20140601142622.GA9131@krava.brq.redhat.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
2014-05-23 17:15:47 +02:00
|
|
|
bool elide;
|
2014-07-31 14:47:37 +09:00
|
|
|
int len;
|
2014-07-31 14:47:38 +09:00
|
|
|
int user_len;
|
2016-01-18 10:24:01 +01:00
|
|
|
int idx;
|
2016-03-07 16:44:43 -03:00
|
|
|
int level;
|
2012-09-03 11:53:06 +09:00
|
|
|
};
|
|
|
|
|
2016-01-18 10:24:12 +01:00
|
|
|
struct perf_hpp_list {
|
|
|
|
struct list_head fields;
|
|
|
|
struct list_head sorts;
|
2016-05-03 13:54:42 +02:00
|
|
|
|
2016-08-07 17:28:26 +02:00
|
|
|
int nr_header_lines;
|
2016-05-03 13:54:42 +02:00
|
|
|
int need_collapse;
|
2016-05-03 13:54:43 +02:00
|
|
|
int parent;
|
2016-05-03 13:54:44 +02:00
|
|
|
int sym;
|
2016-05-03 13:54:45 +02:00
|
|
|
int dso;
|
2016-05-03 13:54:46 +02:00
|
|
|
int socket;
|
2016-05-03 13:54:47 +02:00
|
|
|
int thread;
|
2016-05-03 13:54:48 +02:00
|
|
|
int comm;
|
2016-01-18 10:24:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct perf_hpp_list perf_hpp_list;
|
2012-10-13 00:06:16 +02:00
|
|
|
|
2016-03-07 16:44:45 -03:00
|
|
|
struct perf_hpp_list_node {
|
|
|
|
struct list_head list;
|
|
|
|
struct perf_hpp_list hpp;
|
|
|
|
int level;
|
2016-03-07 16:44:46 -03:00
|
|
|
bool skip;
|
2016-03-07 16:44:45 -03:00
|
|
|
};
|
|
|
|
|
2016-01-18 10:24:14 +01:00
|
|
|
void perf_hpp_list__column_register(struct perf_hpp_list *list,
|
|
|
|
struct perf_hpp_fmt *format);
|
|
|
|
void perf_hpp_list__register_sort_field(struct perf_hpp_list *list,
|
|
|
|
struct perf_hpp_fmt *format);
|
2017-01-18 14:14:57 +09:00
|
|
|
void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
|
|
|
|
struct perf_hpp_fmt *format);
|
2016-01-18 10:24:14 +01:00
|
|
|
|
|
|
|
static inline void perf_hpp__column_register(struct perf_hpp_fmt *format)
|
|
|
|
{
|
|
|
|
perf_hpp_list__column_register(&perf_hpp_list, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
|
|
|
|
{
|
|
|
|
perf_hpp_list__register_sort_field(&perf_hpp_list, format);
|
|
|
|
}
|
|
|
|
|
2017-01-18 14:14:57 +09:00
|
|
|
static inline void perf_hpp__prepend_sort_field(struct perf_hpp_fmt *format)
|
|
|
|
{
|
|
|
|
perf_hpp_list__prepend_sort_field(&perf_hpp_list, format);
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:24:17 +01:00
|
|
|
#define perf_hpp_list__for_each_format(_list, format) \
|
|
|
|
list_for_each_entry(format, &(_list)->fields, list)
|
2012-10-13 00:06:16 +02:00
|
|
|
|
2016-01-18 10:24:18 +01:00
|
|
|
#define perf_hpp_list__for_each_format_safe(_list, format, tmp) \
|
|
|
|
list_for_each_entry_safe(format, tmp, &(_list)->fields, list)
|
2014-05-07 18:42:24 +09:00
|
|
|
|
2016-01-18 10:24:19 +01:00
|
|
|
#define perf_hpp_list__for_each_sort_list(_list, format) \
|
|
|
|
list_for_each_entry(format, &(_list)->sorts, sort_list)
|
2014-03-03 11:46:55 +09:00
|
|
|
|
2016-01-18 10:24:20 +01:00
|
|
|
#define perf_hpp_list__for_each_sort_list_safe(_list, format, tmp) \
|
|
|
|
list_for_each_entry_safe(format, tmp, &(_list)->sorts, sort_list)
|
2014-05-07 18:42:24 +09:00
|
|
|
|
2016-01-18 10:24:23 +01:00
|
|
|
#define hists__for_each_format(hists, format) \
|
2019-12-19 08:08:32 +00:00
|
|
|
perf_hpp_list__for_each_format((hists)->hpp_list, format)
|
2016-01-18 10:24:23 +01:00
|
|
|
|
2016-01-18 10:24:24 +01:00
|
|
|
#define hists__for_each_sort_list(hists, format) \
|
2019-12-19 08:08:32 +00:00
|
|
|
perf_hpp_list__for_each_sort_list((hists)->hpp_list, format)
|
2016-01-18 10:24:24 +01:00
|
|
|
|
2012-09-03 11:53:06 +09:00
|
|
|
extern struct perf_hpp_fmt perf_hpp__format[];
|
|
|
|
|
|
|
|
enum {
|
2013-02-03 20:08:34 +01:00
|
|
|
/* Matches perf_hpp__format array. */
|
2012-09-03 11:53:06 +09:00
|
|
|
PERF_HPP__OVERHEAD,
|
|
|
|
PERF_HPP__OVERHEAD_SYS,
|
|
|
|
PERF_HPP__OVERHEAD_US,
|
|
|
|
PERF_HPP__OVERHEAD_GUEST_SYS,
|
|
|
|
PERF_HPP__OVERHEAD_GUEST_US,
|
2013-10-30 16:06:59 +09:00
|
|
|
PERF_HPP__OVERHEAD_ACC,
|
2012-09-03 11:53:06 +09:00
|
|
|
PERF_HPP__SAMPLES,
|
|
|
|
PERF_HPP__PERIOD,
|
perf report: Add weight[123] output fields
Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
like 'ins_lat', 'p_stage_cyc' and 'retire_lat'. Note that they are in
the sort keys too but the difference is that output fields will sum up
the weight values and display the average.
In the sort key, users can see the distribution of weight value and I
think it's confusing we have local vs. global weight for the same weight.
For example, I experiment with mem-loads events to get the weights. On
my laptop, it seems only weight1 field is supported.
$ perf mem record -- perf test -w noploop
Let's look at the noploop function only. It has 7 samples.
$ perf script -F event,ip,sym,weight | grep noploop
# event weight ip sym
cpu/mem-loads,ldlat=30/P: 43 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 48 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 59 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 33 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
When you use the 'weight' sort key, it'd show entries with a separate
weight value separately. Also note that the first entry has 3 samples
with weight value 38, so they are displayed together and the weight
value is the sum of 3 samples (114 = 38 * 3).
$ perf report -n -s +weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Weight
0.53% 3 perf perf [.] noploop 114
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
If you use 'local_weight' sort key, you can see the actual weight.
$ perf report -n -s +local_weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Local Weight
0.53% 3 perf perf [.] noploop 38
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
But when you use the -F/--field option instead, you can see the average
weight for the while noploop function (as it won't group samples by
weight value and use the default 'comm,dso,sym' sort keys).
$ perf report -n -F +weight | grep -e Weight -e noploop
Warning:
--fields weight shows the average value unlike in the --sort key.
# Overhead Samples Weight1 Command Shared Object Symbol
1.23% 7 42.4 perf perf [.] noploop
The weight1 field shows the average value:
(38 * 3 + 59 + 48 + 43 + 33) / 7 = 42.4
Also it'd show the warning that 'weight' field has the average value.
Using 'weight1' can remove the warning.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240411181718.2367948-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-04-11 11:17:18 -07:00
|
|
|
PERF_HPP__WEIGHT1,
|
|
|
|
PERF_HPP__WEIGHT2,
|
|
|
|
PERF_HPP__WEIGHT3,
|
2012-09-03 11:53:06 +09:00
|
|
|
|
|
|
|
PERF_HPP__MAX_INDEX
|
|
|
|
};
|
|
|
|
|
2012-10-04 21:49:39 +09:00
|
|
|
void perf_hpp__init(void);
|
2013-12-16 16:55:13 +09:00
|
|
|
void perf_hpp__cancel_cumulate(void);
|
2016-01-18 10:24:21 +01:00
|
|
|
void perf_hpp__setup_output_field(struct perf_hpp_list *list);
|
|
|
|
void perf_hpp__reset_output_field(struct perf_hpp_list *list);
|
|
|
|
void perf_hpp__append_sort_keys(struct perf_hpp_list *list);
|
2016-03-07 16:44:45 -03:00
|
|
|
int perf_hpp__setup_hists_formats(struct perf_hpp_list *list,
|
2019-07-21 13:23:52 +02:00
|
|
|
struct evlist *evlist);
|
2016-01-18 10:24:21 +01:00
|
|
|
|
2014-03-04 10:46:34 +09:00
|
|
|
|
|
|
|
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
|
2015-12-23 02:07:08 +09:00
|
|
|
bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *format);
|
|
|
|
bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt, struct hists *hists);
|
2016-02-25 00:13:33 +09:00
|
|
|
bool perf_hpp__is_trace_entry(struct perf_hpp_fmt *fmt);
|
|
|
|
bool perf_hpp__is_srcline_entry(struct perf_hpp_fmt *fmt);
|
|
|
|
bool perf_hpp__is_srcfile_entry(struct perf_hpp_fmt *fmt);
|
2016-03-09 22:46:57 +09:00
|
|
|
bool perf_hpp__is_thread_entry(struct perf_hpp_fmt *fmt);
|
|
|
|
bool perf_hpp__is_comm_entry(struct perf_hpp_fmt *fmt);
|
|
|
|
bool perf_hpp__is_dso_entry(struct perf_hpp_fmt *fmt);
|
|
|
|
bool perf_hpp__is_sym_entry(struct perf_hpp_fmt *fmt);
|
perf tools: Move elide bool into perf_hpp_fmt struct
After output/sort fields refactoring, it's expensive
to check the elide bool in its current location inside
the 'struct sort_entry'.
The perf_hpp__should_skip function gets highly noticable in
workloads with high number of output/sort fields, like for:
$ perf report -i perf-test.data -F overhead,sample,period,comm,pid,dso,symbol,cpu --stdio
Performance report:
9.70% perf [.] perf_hpp__should_skip
Moving the elide bool into the 'struct perf_hpp_fmt', which
makes the perf_hpp__should_skip just single struct read.
Got speedup of around 22% for my test perf.data workload.
The change should not harm any other workload types.
Performance counter stats for (10 runs):
before:
358,319,732,626 cycles ( +- 0.55% )
467,129,581,515 instructions # 1.30 insns per cycle ( +- 0.00% )
150.943975206 seconds time elapsed ( +- 0.62% )
now:
278,785,972,990 cycles ( +- 0.12% )
370,146,797,640 instructions # 1.33 insns per cycle ( +- 0.00% )
116.416670507 seconds time elapsed ( +- 0.31% )
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20140601142622.GA9131@krava.brq.redhat.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
2014-05-23 17:15:47 +02:00
|
|
|
|
2016-03-07 16:44:45 -03:00
|
|
|
struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt);
|
|
|
|
|
2016-02-25 00:13:37 +09:00
|
|
|
int hist_entry__filter(struct hist_entry *he, int type, const void *arg);
|
|
|
|
|
2015-12-23 02:07:08 +09:00
|
|
|
static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format,
|
|
|
|
struct hists *hists)
|
perf tools: Move elide bool into perf_hpp_fmt struct
After output/sort fields refactoring, it's expensive
to check the elide bool in its current location inside
the 'struct sort_entry'.
The perf_hpp__should_skip function gets highly noticable in
workloads with high number of output/sort fields, like for:
$ perf report -i perf-test.data -F overhead,sample,period,comm,pid,dso,symbol,cpu --stdio
Performance report:
9.70% perf [.] perf_hpp__should_skip
Moving the elide bool into the 'struct perf_hpp_fmt', which
makes the perf_hpp__should_skip just single struct read.
Got speedup of around 22% for my test perf.data workload.
The change should not harm any other workload types.
Performance counter stats for (10 runs):
before:
358,319,732,626 cycles ( +- 0.55% )
467,129,581,515 instructions # 1.30 insns per cycle ( +- 0.00% )
150.943975206 seconds time elapsed ( +- 0.62% )
now:
278,785,972,990 cycles ( +- 0.12% )
370,146,797,640 instructions # 1.33 insns per cycle ( +- 0.00% )
116.416670507 seconds time elapsed ( +- 0.31% )
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20140601142622.GA9131@krava.brq.redhat.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
2014-05-23 17:15:47 +02:00
|
|
|
{
|
2015-12-23 02:07:08 +09:00
|
|
|
if (format->elide)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (perf_hpp__is_dynamic_entry(format) &&
|
|
|
|
!perf_hpp__defined_dynamic_entry(format, hists))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
perf tools: Move elide bool into perf_hpp_fmt struct
After output/sort fields refactoring, it's expensive
to check the elide bool in its current location inside
the 'struct sort_entry'.
The perf_hpp__should_skip function gets highly noticable in
workloads with high number of output/sort fields, like for:
$ perf report -i perf-test.data -F overhead,sample,period,comm,pid,dso,symbol,cpu --stdio
Performance report:
9.70% perf [.] perf_hpp__should_skip
Moving the elide bool into the 'struct perf_hpp_fmt', which
makes the perf_hpp__should_skip just single struct read.
Got speedup of around 22% for my test perf.data workload.
The change should not harm any other workload types.
Performance counter stats for (10 runs):
before:
358,319,732,626 cycles ( +- 0.55% )
467,129,581,515 instructions # 1.30 insns per cycle ( +- 0.00% )
150.943975206 seconds time elapsed ( +- 0.62% )
now:
278,785,972,990 cycles ( +- 0.12% )
370,146,797,640 instructions # 1.33 insns per cycle ( +- 0.00% )
116.416670507 seconds time elapsed ( +- 0.31% )
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20140601142622.GA9131@krava.brq.redhat.com
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
2014-05-23 17:15:47 +02:00
|
|
|
}
|
|
|
|
|
2014-03-20 11:18:54 +09:00
|
|
|
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
|
2014-07-31 14:47:37 +09:00
|
|
|
void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists);
|
2014-07-31 14:47:38 +09:00
|
|
|
void perf_hpp__set_user_width(const char *width_list_str);
|
2016-09-20 14:30:24 +09:00
|
|
|
void hists__reset_column_width(struct hists *hists);
|
2012-09-03 11:53:06 +09:00
|
|
|
|
perf report: Add weight[123] output fields
Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
like 'ins_lat', 'p_stage_cyc' and 'retire_lat'. Note that they are in
the sort keys too but the difference is that output fields will sum up
the weight values and display the average.
In the sort key, users can see the distribution of weight value and I
think it's confusing we have local vs. global weight for the same weight.
For example, I experiment with mem-loads events to get the weights. On
my laptop, it seems only weight1 field is supported.
$ perf mem record -- perf test -w noploop
Let's look at the noploop function only. It has 7 samples.
$ perf script -F event,ip,sym,weight | grep noploop
# event weight ip sym
cpu/mem-loads,ldlat=30/P: 43 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 48 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 59 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 33 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
When you use the 'weight' sort key, it'd show entries with a separate
weight value separately. Also note that the first entry has 3 samples
with weight value 38, so they are displayed together and the weight
value is the sum of 3 samples (114 = 38 * 3).
$ perf report -n -s +weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Weight
0.53% 3 perf perf [.] noploop 114
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
If you use 'local_weight' sort key, you can see the actual weight.
$ perf report -n -s +local_weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Local Weight
0.53% 3 perf perf [.] noploop 38
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
But when you use the -F/--field option instead, you can see the average
weight for the while noploop function (as it won't group samples by
weight value and use the default 'comm,dso,sym' sort keys).
$ perf report -n -F +weight | grep -e Weight -e noploop
Warning:
--fields weight shows the average value unlike in the --sort key.
# Overhead Samples Weight1 Command Shared Object Symbol
1.23% 7 42.4 perf perf [.] noploop
The weight1 field shows the average value:
(38 * 3 + 59 + 48 + 43 + 33) / 7 = 42.4
Also it'd show the warning that 'weight' field has the average value.
Using 'weight1' can remove the warning.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240411181718.2367948-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-04-11 11:17:18 -07:00
|
|
|
enum perf_hpp_fmt_type {
|
|
|
|
PERF_HPP_FMT_TYPE__RAW,
|
|
|
|
PERF_HPP_FMT_TYPE__PERCENT,
|
|
|
|
PERF_HPP_FMT_TYPE__AVERAGE,
|
|
|
|
};
|
|
|
|
|
2014-03-03 10:14:05 +09:00
|
|
|
typedef u64 (*hpp_field_fn)(struct hist_entry *he);
|
|
|
|
typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
|
2014-03-03 10:14:04 +09:00
|
|
|
typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...);
|
2014-03-03 10:14:03 +09:00
|
|
|
|
2014-07-31 14:47:38 +09:00
|
|
|
int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he, hpp_field_fn get_field,
|
perf report: Add weight[123] output fields
Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
like 'ins_lat', 'p_stage_cyc' and 'retire_lat'. Note that they are in
the sort keys too but the difference is that output fields will sum up
the weight values and display the average.
In the sort key, users can see the distribution of weight value and I
think it's confusing we have local vs. global weight for the same weight.
For example, I experiment with mem-loads events to get the weights. On
my laptop, it seems only weight1 field is supported.
$ perf mem record -- perf test -w noploop
Let's look at the noploop function only. It has 7 samples.
$ perf script -F event,ip,sym,weight | grep noploop
# event weight ip sym
cpu/mem-loads,ldlat=30/P: 43 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 48 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 59 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 33 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
When you use the 'weight' sort key, it'd show entries with a separate
weight value separately. Also note that the first entry has 3 samples
with weight value 38, so they are displayed together and the weight
value is the sum of 3 samples (114 = 38 * 3).
$ perf report -n -s +weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Weight
0.53% 3 perf perf [.] noploop 114
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
If you use 'local_weight' sort key, you can see the actual weight.
$ perf report -n -s +local_weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Local Weight
0.53% 3 perf perf [.] noploop 38
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
But when you use the -F/--field option instead, you can see the average
weight for the while noploop function (as it won't group samples by
weight value and use the default 'comm,dso,sym' sort keys).
$ perf report -n -F +weight | grep -e Weight -e noploop
Warning:
--fields weight shows the average value unlike in the --sort key.
# Overhead Samples Weight1 Command Shared Object Symbol
1.23% 7 42.4 perf perf [.] noploop
The weight1 field shows the average value:
(38 * 3 + 59 + 48 + 43 + 33) / 7 = 42.4
Also it'd show the warning that 'weight' field has the average value.
Using 'weight1' can remove the warning.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240411181718.2367948-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-04-11 11:17:18 -07:00
|
|
|
const char *fmtstr, hpp_snprint_fn print_fn,
|
|
|
|
enum perf_hpp_fmt_type fmtype);
|
2014-07-31 14:47:38 +09:00
|
|
|
int hpp__fmt_acc(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he, hpp_field_fn get_field,
|
perf report: Add weight[123] output fields
Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
like 'ins_lat', 'p_stage_cyc' and 'retire_lat'. Note that they are in
the sort keys too but the difference is that output fields will sum up
the weight values and display the average.
In the sort key, users can see the distribution of weight value and I
think it's confusing we have local vs. global weight for the same weight.
For example, I experiment with mem-loads events to get the weights. On
my laptop, it seems only weight1 field is supported.
$ perf mem record -- perf test -w noploop
Let's look at the noploop function only. It has 7 samples.
$ perf script -F event,ip,sym,weight | grep noploop
# event weight ip sym
cpu/mem-loads,ldlat=30/P: 43 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 48 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
cpu/mem-loads,ldlat=30/P: 59 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 33 55b3c122bffc noploop
cpu/mem-loads,ldlat=30/P: 38 55b3c122bffc noploop <--- same weight
When you use the 'weight' sort key, it'd show entries with a separate
weight value separately. Also note that the first entry has 3 samples
with weight value 38, so they are displayed together and the weight
value is the sum of 3 samples (114 = 38 * 3).
$ perf report -n -s +weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Weight
0.53% 3 perf perf [.] noploop 114
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
If you use 'local_weight' sort key, you can see the actual weight.
$ perf report -n -s +local_weight | grep -e Weight -e noploop
# Overhead Samples Command Shared Object Symbol Local Weight
0.53% 3 perf perf [.] noploop 38
0.18% 1 perf perf [.] noploop 59
0.18% 1 perf perf [.] noploop 48
0.18% 1 perf perf [.] noploop 43
0.18% 1 perf perf [.] noploop 33
But when you use the -F/--field option instead, you can see the average
weight for the while noploop function (as it won't group samples by
weight value and use the default 'comm,dso,sym' sort keys).
$ perf report -n -F +weight | grep -e Weight -e noploop
Warning:
--fields weight shows the average value unlike in the --sort key.
# Overhead Samples Weight1 Command Shared Object Symbol
1.23% 7 42.4 perf perf [.] noploop
The weight1 field shows the average value:
(38 * 3 + 59 + 48 + 43 + 33) / 7 = 42.4
Also it'd show the warning that 'weight' field has the average value.
Using 'weight1' can remove the warning.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240411181718.2367948-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-04-11 11:17:18 -07:00
|
|
|
const char *fmtstr, hpp_snprint_fn print_fn,
|
|
|
|
enum perf_hpp_fmt_type fmtype);
|
2014-03-03 10:14:03 +09:00
|
|
|
|
2014-03-03 10:14:04 +09:00
|
|
|
static inline void advance_hpp(struct perf_hpp *hpp, int inc)
|
|
|
|
{
|
|
|
|
hpp->buf += inc;
|
|
|
|
hpp->size -= inc;
|
|
|
|
}
|
|
|
|
|
2013-10-25 13:24:53 +02:00
|
|
|
static inline size_t perf_hpp__use_color(void)
|
|
|
|
{
|
|
|
|
return !symbol_conf.field_sep;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t perf_hpp__color_overhead(void)
|
|
|
|
{
|
|
|
|
return perf_hpp__use_color() ?
|
|
|
|
(COLOR_MAXLEN + sizeof(PERF_COLOR_RESET)) * PERF_HPP__MAX_INDEX
|
|
|
|
: 0;
|
|
|
|
}
|
|
|
|
|
2019-07-21 13:23:52 +02:00
|
|
|
struct evlist;
|
2011-03-05 21:40:06 -03:00
|
|
|
|
2012-11-02 14:50:05 +09:00
|
|
|
struct hist_browser_timer {
|
|
|
|
void (*timer)(void *arg);
|
|
|
|
void *arg;
|
|
|
|
int refresh;
|
|
|
|
};
|
|
|
|
|
2019-03-11 07:44:58 -07:00
|
|
|
enum rstype {
|
|
|
|
A_NORMAL,
|
|
|
|
A_ASM,
|
|
|
|
A_SOURCE
|
|
|
|
};
|
2018-05-28 13:54:59 -03:00
|
|
|
|
2024-04-11 11:17:16 -07:00
|
|
|
struct block_hist {
|
|
|
|
struct hists block_hists;
|
|
|
|
struct perf_hpp_list block_list;
|
|
|
|
struct perf_hpp_fmt block_fmt;
|
|
|
|
int block_idx;
|
|
|
|
bool valid;
|
|
|
|
struct hist_entry he;
|
|
|
|
};
|
2019-11-18 22:08:48 +08:00
|
|
|
|
2013-09-30 12:07:11 +02:00
|
|
|
#ifdef HAVE_SLANG_SUPPORT
|
2012-09-28 18:32:02 +09:00
|
|
|
#include "../ui/keysyms.h"
|
2019-03-11 07:44:57 -07:00
|
|
|
void attr_to_script(char *buf, struct perf_event_attr *attr);
|
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
|
2023-11-28 09:54:38 -08:00
|
|
|
struct hist_browser_timer *hbt);
|
2015-03-17 18:27:28 -03:00
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
|
2023-11-28 09:54:38 -08:00
|
|
|
struct hist_browser_timer *hbt);
|
2012-09-28 18:32:02 +09:00
|
|
|
|
2020-11-30 14:23:35 -03:00
|
|
|
int evlist__tui_browse_hists(struct evlist *evlist, const char *help, struct hist_browser_timer *hbt,
|
2023-11-28 09:54:38 -08:00
|
|
|
float min_pcnt, struct perf_env *env, bool warn_lost_event);
|
2019-03-11 07:44:57 -07:00
|
|
|
|
2019-07-21 13:23:51 +02:00
|
|
|
int script_browse(const char *script_opt, struct evsel *evsel);
|
2019-03-11 07:44:58 -07:00
|
|
|
|
|
|
|
void run_script(char *cmd);
|
|
|
|
int res_sample_browse(struct res_sample *res_samples, int num_res,
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel, enum rstype rstype);
|
2019-03-11 07:44:58 -07:00
|
|
|
void res_sample_init(void);
|
2019-11-18 22:08:48 +08:00
|
|
|
|
|
|
|
int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
|
2023-11-28 09:54:38 -08:00
|
|
|
float min_percent, struct perf_env *env);
|
2012-09-28 18:32:02 +09:00
|
|
|
#else
|
2011-03-06 13:07:30 -03:00
|
|
|
static inline
|
2020-11-30 14:23:35 -03:00
|
|
|
int evlist__tui_browse_hists(struct evlist *evlist __maybe_unused,
|
|
|
|
const char *help __maybe_unused,
|
|
|
|
struct hist_browser_timer *hbt __maybe_unused,
|
|
|
|
float min_pcnt __maybe_unused,
|
|
|
|
struct perf_env *env __maybe_unused,
|
2023-11-28 09:54:38 -08:00
|
|
|
bool warn_lost_event __maybe_unused)
|
2010-05-23 22:36:51 -03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-17 18:27:28 -03:00
|
|
|
static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2023-11-28 09:54:38 -08:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused)
|
2015-03-17 18:27:28 -03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-23 22:36:51 -03:00
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2023-11-28 09:54:38 -08:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused)
|
2010-05-22 11:25:40 -03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-30 11:56:04 +08:00
|
|
|
|
2019-03-11 07:44:57 -07:00
|
|
|
static inline int script_browse(const char *script_opt __maybe_unused,
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel __maybe_unused)
|
2012-10-30 11:56:04 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-11 07:44:58 -07:00
|
|
|
static inline int res_sample_browse(struct res_sample *res_samples __maybe_unused,
|
|
|
|
int num_res __maybe_unused,
|
2019-07-21 13:23:51 +02:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2019-03-11 07:44:58 -07:00
|
|
|
enum rstype rstype __maybe_unused)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void res_sample_init(void) {}
|
|
|
|
|
2019-11-18 22:08:48 +08:00
|
|
|
static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused,
|
|
|
|
struct evsel *evsel __maybe_unused,
|
2019-11-18 22:08:49 +08:00
|
|
|
float min_percent __maybe_unused,
|
2023-11-28 09:54:38 -08:00
|
|
|
struct perf_env *env __maybe_unused)
|
2019-11-18 22:08:48 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-26 16:02:02 +11:00
|
|
|
#define K_LEFT -1000
|
|
|
|
#define K_RIGHT -2000
|
2013-02-26 16:02:03 +11:00
|
|
|
#define K_SWITCH_INPUT_DATA -3000
|
2020-02-20 09:36:15 +08:00
|
|
|
#define K_RELOAD -4000
|
2010-05-11 11:10:15 -03:00
|
|
|
#endif
|
2010-07-21 17:58:25 -03:00
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
unsigned int hists__sort_list_width(struct hists *hists);
|
2016-02-26 21:13:16 +09:00
|
|
|
unsigned int hists__overhead_width(struct hists *hists);
|
2014-02-07 12:06:07 +09:00
|
|
|
|
2015-07-18 08:24:49 -07:00
|
|
|
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
|
2019-11-07 15:47:15 +08:00
|
|
|
struct perf_sample *sample, bool nonany_branch_mode,
|
|
|
|
u64 *total_cycles);
|
2015-07-18 08:24:49 -07:00
|
|
|
|
2014-02-07 12:06:07 +09:00
|
|
|
struct option;
|
2016-03-22 13:09:37 -03:00
|
|
|
int parse_filter_percentage(const struct option *opt, const char *arg, int unset);
|
2014-01-14 12:02:15 +09:00
|
|
|
int perf_hist_config(const char *var, const char *value);
|
2014-02-07 12:06:07 +09:00
|
|
|
|
2016-01-18 10:24:13 +01:00
|
|
|
void perf_hpp_list__init(struct perf_hpp_list *list);
|
|
|
|
|
2016-02-25 00:13:36 +09:00
|
|
|
enum hierarchy_move_dir {
|
|
|
|
HMD_NORMAL,
|
|
|
|
HMD_FORCE_SIBLING,
|
|
|
|
HMD_FORCE_CHILD,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rb_node *rb_hierarchy_last(struct rb_node *node);
|
|
|
|
struct rb_node *__rb_hierarchy_next(struct rb_node *node,
|
|
|
|
enum hierarchy_move_dir hmd);
|
|
|
|
struct rb_node *rb_hierarchy_prev(struct rb_node *node);
|
|
|
|
|
|
|
|
static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)
|
|
|
|
{
|
|
|
|
return __rb_hierarchy_next(node, HMD_NORMAL);
|
|
|
|
}
|
|
|
|
|
2016-02-25 00:13:41 +09:00
|
|
|
#define HIERARCHY_INDENT 3
|
|
|
|
|
2016-02-26 21:13:16 +09:00
|
|
|
bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit);
|
2016-09-22 17:36:35 +02:00
|
|
|
int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...);
|
|
|
|
int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...);
|
2016-09-22 17:36:36 +02:00
|
|
|
int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
|
|
|
|
struct perf_hpp_list *hpp_list);
|
2016-09-22 17:36:37 +02:00
|
|
|
int hists__fprintf_headers(struct hists *hists, FILE *fp);
|
2018-04-02 14:20:20 -03:00
|
|
|
int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq);
|
|
|
|
|
|
|
|
static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t size)
|
|
|
|
{
|
|
|
|
return __hists__scnprintf_title(hists, bf, size, true);
|
|
|
|
}
|
2016-02-26 21:13:16 +09:00
|
|
|
|
2009-09-28 15:32:55 +02:00
|
|
|
#endif /* __PERF_HIST_H */
|