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 17:07:57 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-09-28 17:32:55 +04:00
|
|
|
#ifndef __PERF_HIST_H
|
|
|
|
#define __PERF_HIST_H
|
|
|
|
|
2019-01-29 14:04:58 +03:00
|
|
|
#include <linux/rbtree.h>
|
2009-12-14 18:10:39 +03:00
|
|
|
#include <linux/types.h>
|
2011-10-06 00:50:23 +04:00
|
|
|
#include <pthread.h>
|
2014-10-09 23:16:00 +04:00
|
|
|
#include "evsel.h"
|
2013-10-25 15:24:53 +04:00
|
|
|
#include "color.h"
|
2019-08-30 17:44:32 +03:00
|
|
|
#include "events_stats.h"
|
2009-09-28 17:32:55 +04:00
|
|
|
|
2009-12-14 18:10:39 +03:00
|
|
|
struct hist_entry;
|
2016-07-05 09:56:05 +03:00
|
|
|
struct hist_entry_ops;
|
2009-12-14 18:10:39 +03:00
|
|
|
struct addr_location;
|
2019-01-29 14:04:58 +03:00
|
|
|
struct map_symbol;
|
2019-01-27 16:10:31 +03:00
|
|
|
struct mem_info;
|
|
|
|
struct branch_info;
|
2019-09-18 16:09:54 +03:00
|
|
|
struct branch_stack;
|
2019-06-28 12:22:59 +03:00
|
|
|
struct block_info;
|
2009-12-14 18:10:39 +03:00
|
|
|
struct symbol;
|
2019-08-30 17:28:14 +03:00
|
|
|
struct ui_progress;
|
2010-05-12 06:18:06 +04:00
|
|
|
|
2014-03-17 23:59:21 +04: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 17:45:44 +03:00
|
|
|
HIST_FILTER__SOCKET,
|
2016-08-17 15:55:23 +03:00
|
|
|
HIST_FILTER__C2C,
|
2014-03-17 23:59:21 +04:00
|
|
|
};
|
|
|
|
|
2010-07-20 21:42:52 +04:00
|
|
|
enum hist_column {
|
|
|
|
HISTC_SYMBOL,
|
2019-03-11 17:44:54 +03:00
|
|
|
HISTC_TIME,
|
2010-07-20 21:42:52 +04: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-07 23:42:13 +03:00
|
|
|
HISTC_CGROUP_ID,
|
2010-07-20 21:42:52 +04:00
|
|
|
HISTC_PARENT,
|
|
|
|
HISTC_CPU,
|
2015-09-04 17:45:43 +03:00
|
|
|
HISTC_SOCKET,
|
2013-04-05 05:26:31 +04:00
|
|
|
HISTC_SRCLINE,
|
2015-08-08 01:54:24 +03:00
|
|
|
HISTC_SRCFILE,
|
2012-02-10 02:21:01 +04:00
|
|
|
HISTC_MISPREDICT,
|
2013-09-20 18:40:41 +04:00
|
|
|
HISTC_IN_TX,
|
|
|
|
HISTC_ABORT,
|
2012-02-10 02:21:01 +04:00
|
|
|
HISTC_SYMBOL_FROM,
|
|
|
|
HISTC_SYMBOL_TO,
|
|
|
|
HISTC_DSO_FROM,
|
|
|
|
HISTC_DSO_TO,
|
2013-01-24 19:10:29 +04:00
|
|
|
HISTC_LOCAL_WEIGHT,
|
|
|
|
HISTC_GLOBAL_WEIGHT,
|
2013-01-24 19:10:35 +04:00
|
|
|
HISTC_MEM_DADDR_SYMBOL,
|
|
|
|
HISTC_MEM_DADDR_DSO,
|
2017-08-29 20:11:09 +03:00
|
|
|
HISTC_MEM_PHYS_DADDR,
|
2013-01-24 19:10:35 +04:00
|
|
|
HISTC_MEM_LOCKED,
|
|
|
|
HISTC_MEM_TLB,
|
|
|
|
HISTC_MEM_LVL,
|
|
|
|
HISTC_MEM_SNOOP,
|
2014-06-01 17:38:29 +04:00
|
|
|
HISTC_MEM_DCACHELINE,
|
2015-10-05 21:06:07 +03:00
|
|
|
HISTC_MEM_IADDR_SYMBOL,
|
2013-09-20 18:40:43 +04:00
|
|
|
HISTC_TRANSACTION,
|
2015-07-18 18:24:46 +03:00
|
|
|
HISTC_CYCLES,
|
2016-05-20 23:15:08 +03:00
|
|
|
HISTC_SRCLINE_FROM,
|
|
|
|
HISTC_SRCLINE_TO,
|
2015-12-22 20:07:04 +03:00
|
|
|
HISTC_TRACE,
|
2017-02-24 16:32:56 +03:00
|
|
|
HISTC_SYM_SIZE,
|
2018-03-27 14:09:56 +03:00
|
|
|
HISTC_DSO_SIZE,
|
2018-11-30 16:54:56 +03:00
|
|
|
HISTC_SYMBOL_IPC,
|
2010-07-20 21:42:52 +04:00
|
|
|
HISTC_NR_COLS, /* Last entry */
|
|
|
|
};
|
|
|
|
|
2011-10-19 01:07:34 +04: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 20:04:11 +04:00
|
|
|
struct hists {
|
2018-12-06 22:18:18 +03: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 20:57:51 +04:00
|
|
|
u64 nr_entries;
|
2013-12-26 10:11:52 +04:00
|
|
|
u64 nr_non_filtered_entries;
|
2016-02-16 17:08:19 +03:00
|
|
|
u64 callchain_period;
|
|
|
|
u64 callchain_non_filtered_period;
|
2015-03-03 04:21:35 +03:00
|
|
|
struct thread *thread_filter;
|
2011-10-19 01:07:34 +04:00
|
|
|
const struct dso *dso_filter;
|
2012-01-19 20:08:15 +04:00
|
|
|
const char *uid_filter_str;
|
2012-03-16 12:50:51 +04:00
|
|
|
const char *symbol_filter_str;
|
2011-10-06 00:50:23 +04:00
|
|
|
pthread_mutex_t lock;
|
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 20:04:11 +04:00
|
|
|
struct events_stats stats;
|
|
|
|
u64 event_stream;
|
2010-07-20 21:42:52 +04:00
|
|
|
u16 col_len[HISTC_NR_COLS];
|
2018-06-07 20:42:27 +03:00
|
|
|
bool has_callchains;
|
2015-09-04 17:45:44 +03:00
|
|
|
int socket_filter;
|
2016-01-18 12:24:22 +03:00
|
|
|
struct perf_hpp_list *hpp_list;
|
2016-03-07 22:44:45 +03:00
|
|
|
struct list_head hpp_formats;
|
2016-03-07 22: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 20:04:11 +04:00
|
|
|
};
|
|
|
|
|
2016-05-03 14:54:42 +03:00
|
|
|
#define hists__has(__h, __f) (__h)->hpp_list->__f
|
|
|
|
|
2013-10-30 04:40:34 +04: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;
|
|
|
|
|
|
|
|
bool hide_unresolved;
|
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel;
|
2013-10-30 04:40:34 +04:00
|
|
|
struct perf_sample *sample;
|
|
|
|
struct hist_entry *he;
|
|
|
|
struct symbol *parent;
|
|
|
|
void *priv;
|
|
|
|
|
|
|
|
const struct hist_iter_ops *ops;
|
2014-01-07 12:02:25 +04:00
|
|
|
/* user-defined callback function (optional) */
|
|
|
|
int (*add_entry_cb)(struct hist_entry_iter *iter,
|
|
|
|
struct addr_location *al, bool single, void *arg);
|
2013-10-30 04:40:34 +04: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 09:13:04 +04:00
|
|
|
extern const struct hist_iter_ops hist_iter_cumulative;
|
2013-10-30 04:40:34 +04:00
|
|
|
|
2016-06-14 21:19:21 +03: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,
|
|
|
|
struct perf_sample *sample,
|
|
|
|
bool sample_self);
|
2016-07-05 09:56:05 +03: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,
|
|
|
|
struct perf_sample *sample,
|
|
|
|
bool sample_self);
|
|
|
|
|
2019-06-28 12:22:59 +03:00
|
|
|
struct hist_entry *hists__add_entry_block(struct hists *hists,
|
|
|
|
struct addr_location *al,
|
|
|
|
struct block_info *bi);
|
|
|
|
|
2013-10-30 04:40:34 +04:00
|
|
|
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
|
2014-01-07 12:02:25 +04:00
|
|
|
int max_stack_depth, void *arg);
|
2013-10-30 04:40:34 +04: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 23:14:13 +03:00
|
|
|
struct perf_hpp;
|
|
|
|
struct perf_hpp_fmt;
|
|
|
|
|
2012-01-04 18:27:03 +04: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 18:40:43 +04:00
|
|
|
int hist_entry__transaction_len(void);
|
2013-11-05 22:32:36 +04:00
|
|
|
int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
|
2012-08-20 08:52:06 +04: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 23:14:13 +03:00
|
|
|
int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
|
|
|
|
struct perf_hpp_fmt *fmt, int printed);
|
2014-12-19 18:31:40 +03:00
|
|
|
void hist_entry__delete(struct hist_entry *he);
|
2009-12-14 18:10:39 +03:00
|
|
|
|
2019-02-04 17:18:06 +03:00
|
|
|
typedef int (*hists__resort_cb_t)(struct hist_entry *he, void *arg);
|
2016-08-01 21:02:34 +03:00
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
void perf_evsel__output_resort_cb(struct evsel *evsel, struct ui_progress *prog,
|
2019-02-04 17:18:07 +03:00
|
|
|
hists__resort_cb_t cb, void *cb_arg);
|
2019-07-21 14:23:51 +03:00
|
|
|
void perf_evsel__output_resort(struct evsel *evsel, struct ui_progress *prog);
|
2014-12-22 07:44:10 +03:00
|
|
|
void hists__output_resort(struct hists *hists, struct ui_progress *prog);
|
2016-08-01 21:02:34 +03:00
|
|
|
void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
|
|
|
|
hists__resort_cb_t cb);
|
2016-02-16 17:08:25 +03:00
|
|
|
int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
|
2010-05-14 17:36:42 +04:00
|
|
|
|
2011-10-17 15:05:04 +04:00
|
|
|
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
|
2014-08-12 12:16:05 +04: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-06 02:16:15 +04:00
|
|
|
void hists__output_recalc_col_len(struct hists *hists, int max_rows);
|
|
|
|
|
2019-06-28 12:23:03 +03:00
|
|
|
struct hist_entry *hists__get_entry(struct hists *hists, int idx);
|
|
|
|
|
2014-01-14 06:52:48 +04:00
|
|
|
u64 hists__total_period(struct hists *hists);
|
2014-04-24 11:37:26 +04:00
|
|
|
void hists__reset_stats(struct hists *hists);
|
2014-04-24 11:21:46 +04:00
|
|
|
void hists__inc_stats(struct hists *hists, struct hist_entry *h);
|
2013-11-05 22:32:36 +04:00
|
|
|
void hists__inc_nr_events(struct hists *hists, u32 type);
|
2014-05-28 09:12:18 +04:00
|
|
|
void hists__inc_nr_samples(struct hists *hists, bool filtered);
|
2010-05-14 17:36:42 +04:00
|
|
|
|
2013-11-05 22:32:36 +04:00
|
|
|
size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
|
2016-06-14 21:19:18 +03:00
|
|
|
int max_cols, float min_pcnt, FILE *fp,
|
2018-06-20 21:58:20 +03:00
|
|
|
bool ignore_callchains);
|
2019-07-21 14:23:52 +03:00
|
|
|
size_t perf_evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp);
|
2010-05-11 18:10:15 +04:00
|
|
|
|
2011-10-19 01:07:34 +04:00
|
|
|
void hists__filter_by_dso(struct hists *hists);
|
|
|
|
void hists__filter_by_thread(struct hists *hists);
|
2012-03-16 12:50:51 +04:00
|
|
|
void hists__filter_by_symbol(struct hists *hists);
|
2015-09-04 17:45:45 +03:00
|
|
|
void hists__filter_by_socket(struct hists *hists);
|
2010-05-11 18:10:15 +04:00
|
|
|
|
2014-04-22 09:49:31 +04:00
|
|
|
static inline bool hists__has_filter(struct hists *hists)
|
|
|
|
{
|
|
|
|
return hists->thread_filter || hists->dso_filter ||
|
2015-09-04 17:45:44 +03:00
|
|
|
hists->symbol_filter_str || (hists->socket_filter > -1);
|
2014-04-22 09:49:31 +04:00
|
|
|
}
|
|
|
|
|
2013-11-05 22:32:36 +04: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 08:52:05 +04:00
|
|
|
void hists__reset_col_len(struct hists *hists);
|
|
|
|
void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
|
2010-07-20 21:42:52 +04:00
|
|
|
|
2012-11-09 00:54:33 +04:00
|
|
|
void hists__match(struct hists *leader, struct hists *other);
|
2012-11-09 01:03:09 +04:00
|
|
|
int hists__link(struct hists *leader, struct hists *other);
|
2019-08-28 02:15:55 +03:00
|
|
|
int hists__unlink(struct hists *hists);
|
2012-11-09 00:54:33 +04:00
|
|
|
|
2014-10-09 23:16:00 +04:00
|
|
|
struct hists_evsel {
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel evsel;
|
2014-10-09 23:16:00 +04:00
|
|
|
struct hists hists;
|
|
|
|
};
|
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
static inline struct evsel *hists_to_evsel(struct hists *hists)
|
2014-10-09 23:16:00 +04:00
|
|
|
{
|
|
|
|
struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists);
|
|
|
|
return &hevsel->evsel;
|
|
|
|
}
|
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
static inline struct hists *evsel__hists(struct evsel *evsel)
|
2014-10-09 23:16:00 +04: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 19:59:24 +03:00
|
|
|
static __pure inline bool hists__has_callchains(struct hists *hists)
|
|
|
|
{
|
2018-06-07 20: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 19:59:24 +03:00
|
|
|
}
|
|
|
|
|
2014-10-09 23:16:00 +04:00
|
|
|
int hists__init(void);
|
2016-01-18 12:24:22 +03:00
|
|
|
int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
|
2016-01-07 12:14:10 +03:00
|
|
|
|
2018-12-06 22:18:18 +03:00
|
|
|
struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists);
|
2014-10-09 23:16:00 +04:00
|
|
|
|
2012-09-03 06:53:06 +04:00
|
|
|
struct perf_hpp {
|
|
|
|
char *buf;
|
|
|
|
size_t size;
|
|
|
|
const char *sep;
|
|
|
|
void *ptr;
|
2019-06-28 12:23:03 +03:00
|
|
|
bool skip;
|
2012-09-03 06:53:06 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct perf_hpp_fmt {
|
2014-07-31 09:47:40 +04:00
|
|
|
const char *name;
|
2014-03-10 11:43:52 +04:00
|
|
|
int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
2016-08-07 18:28:30 +03:00
|
|
|
struct hists *hists, int line, int *span);
|
2014-03-10 11:43:52 +04:00
|
|
|
int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
2016-06-14 21:19:20 +03:00
|
|
|
struct hists *hists);
|
2013-02-01 02:31:11 +04: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 03:45:46 +03: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 12:24:03 +03:00
|
|
|
bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
|
2016-01-18 12:24:09 +03:00
|
|
|
void (*free)(struct perf_hpp_fmt *fmt);
|
2012-10-13 02:06:16 +04:00
|
|
|
|
|
|
|
struct list_head list;
|
2014-03-03 06:46:55 +04: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 19:15:47 +04:00
|
|
|
bool elide;
|
2014-07-31 09:47:37 +04:00
|
|
|
int len;
|
2014-07-31 09:47:38 +04:00
|
|
|
int user_len;
|
2016-01-18 12:24:01 +03:00
|
|
|
int idx;
|
2016-03-07 22:44:43 +03:00
|
|
|
int level;
|
2012-09-03 06:53:06 +04:00
|
|
|
};
|
|
|
|
|
2016-01-18 12:24:12 +03:00
|
|
|
struct perf_hpp_list {
|
|
|
|
struct list_head fields;
|
|
|
|
struct list_head sorts;
|
2016-05-03 14:54:42 +03:00
|
|
|
|
2016-08-07 18:28:26 +03:00
|
|
|
int nr_header_lines;
|
2016-05-03 14:54:42 +03:00
|
|
|
int need_collapse;
|
2016-05-03 14:54:43 +03:00
|
|
|
int parent;
|
2016-05-03 14:54:44 +03:00
|
|
|
int sym;
|
2016-05-03 14:54:45 +03:00
|
|
|
int dso;
|
2016-05-03 14:54:46 +03:00
|
|
|
int socket;
|
2016-05-03 14:54:47 +03:00
|
|
|
int thread;
|
2016-05-03 14:54:48 +03:00
|
|
|
int comm;
|
2016-01-18 12:24:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct perf_hpp_list perf_hpp_list;
|
2012-10-13 02:06:16 +04:00
|
|
|
|
2016-03-07 22:44:45 +03:00
|
|
|
struct perf_hpp_list_node {
|
|
|
|
struct list_head list;
|
|
|
|
struct perf_hpp_list hpp;
|
|
|
|
int level;
|
2016-03-07 22:44:46 +03:00
|
|
|
bool skip;
|
2016-03-07 22:44:45 +03:00
|
|
|
};
|
|
|
|
|
2016-01-18 12:24:14 +03: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 08:14:57 +03:00
|
|
|
void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
|
|
|
|
struct perf_hpp_fmt *format);
|
2016-01-18 12:24:14 +03: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 08:14:57 +03: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 12:24:17 +03:00
|
|
|
#define perf_hpp_list__for_each_format(_list, format) \
|
|
|
|
list_for_each_entry(format, &(_list)->fields, list)
|
2012-10-13 02:06:16 +04:00
|
|
|
|
2016-01-18 12:24:18 +03: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 13:42:24 +04:00
|
|
|
|
2016-01-18 12:24:19 +03:00
|
|
|
#define perf_hpp_list__for_each_sort_list(_list, format) \
|
|
|
|
list_for_each_entry(format, &(_list)->sorts, sort_list)
|
2014-03-03 06:46:55 +04:00
|
|
|
|
2016-01-18 12:24:20 +03: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 13:42:24 +04:00
|
|
|
|
2016-01-18 12:24:23 +03:00
|
|
|
#define hists__for_each_format(hists, format) \
|
|
|
|
perf_hpp_list__for_each_format((hists)->hpp_list, fmt)
|
|
|
|
|
2016-01-18 12:24:24 +03:00
|
|
|
#define hists__for_each_sort_list(hists, format) \
|
|
|
|
perf_hpp_list__for_each_sort_list((hists)->hpp_list, fmt)
|
|
|
|
|
2012-09-03 06:53:06 +04:00
|
|
|
extern struct perf_hpp_fmt perf_hpp__format[];
|
|
|
|
|
|
|
|
enum {
|
2013-02-03 23:08:34 +04:00
|
|
|
/* Matches perf_hpp__format array. */
|
2012-09-03 06:53:06 +04: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 11:06:59 +04:00
|
|
|
PERF_HPP__OVERHEAD_ACC,
|
2012-09-03 06:53:06 +04:00
|
|
|
PERF_HPP__SAMPLES,
|
|
|
|
PERF_HPP__PERIOD,
|
|
|
|
|
|
|
|
PERF_HPP__MAX_INDEX
|
|
|
|
};
|
|
|
|
|
2012-10-04 16:49:39 +04:00
|
|
|
void perf_hpp__init(void);
|
2013-12-16 11:55:13 +04:00
|
|
|
void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
|
|
|
|
void perf_hpp__cancel_cumulate(void);
|
2016-01-18 12:24:21 +03: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 22:44:45 +03:00
|
|
|
int perf_hpp__setup_hists_formats(struct perf_hpp_list *list,
|
2019-07-21 14:23:52 +03:00
|
|
|
struct evlist *evlist);
|
2016-01-18 12:24:21 +03:00
|
|
|
|
2014-03-04 05:46:34 +04:00
|
|
|
|
|
|
|
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
|
2015-12-22 20:07:08 +03: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-24 18:13:33 +03: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 16:46:57 +03: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 19:15:47 +04:00
|
|
|
|
2016-03-07 22:44:45 +03:00
|
|
|
struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt);
|
|
|
|
|
2016-02-24 18:13:37 +03:00
|
|
|
int hist_entry__filter(struct hist_entry *he, int type, const void *arg);
|
|
|
|
|
2015-12-22 20:07:08 +03: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 19:15:47 +04:00
|
|
|
{
|
2015-12-22 20:07:08 +03: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 19:15:47 +04:00
|
|
|
}
|
|
|
|
|
2014-03-20 06:18:54 +04:00
|
|
|
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
|
2014-07-31 09:47:37 +04:00
|
|
|
void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists);
|
2014-07-31 09:47:38 +04:00
|
|
|
void perf_hpp__set_user_width(const char *width_list_str);
|
2016-09-20 08:30:24 +03:00
|
|
|
void hists__reset_column_width(struct hists *hists);
|
2012-09-03 06:53:06 +04:00
|
|
|
|
2014-03-03 05:14:05 +04:00
|
|
|
typedef u64 (*hpp_field_fn)(struct hist_entry *he);
|
|
|
|
typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
|
2014-03-03 05:14:04 +04:00
|
|
|
typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...);
|
2014-03-03 05:14:03 +04:00
|
|
|
|
2014-07-31 09:47:38 +04:00
|
|
|
int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he, hpp_field_fn get_field,
|
|
|
|
const char *fmtstr, hpp_snprint_fn print_fn, bool fmt_percent);
|
|
|
|
int hpp__fmt_acc(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct hist_entry *he, hpp_field_fn get_field,
|
|
|
|
const char *fmtstr, hpp_snprint_fn print_fn, bool fmt_percent);
|
2014-03-03 05:14:03 +04:00
|
|
|
|
2014-03-03 05:14:04 +04:00
|
|
|
static inline void advance_hpp(struct perf_hpp *hpp, int inc)
|
|
|
|
{
|
|
|
|
hpp->buf += inc;
|
|
|
|
hpp->size -= inc;
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:24:53 +04: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 14:23:52 +03:00
|
|
|
struct evlist;
|
2011-03-06 03:40:06 +03:00
|
|
|
|
2012-11-02 09:50:05 +04:00
|
|
|
struct hist_browser_timer {
|
|
|
|
void (*timer)(void *arg);
|
|
|
|
void *arg;
|
|
|
|
int refresh;
|
|
|
|
};
|
|
|
|
|
2018-05-28 19:54:59 +03:00
|
|
|
struct annotation_options;
|
2019-03-11 17:44:58 +03:00
|
|
|
struct res_sample;
|
|
|
|
|
|
|
|
enum rstype {
|
|
|
|
A_NORMAL,
|
|
|
|
A_ASM,
|
|
|
|
A_SOURCE
|
|
|
|
};
|
2018-05-28 19:54:59 +03:00
|
|
|
|
2013-09-30 14:07:11 +04:00
|
|
|
#ifdef HAVE_SLANG_SUPPORT
|
2012-09-28 13:32:02 +04:00
|
|
|
#include "../ui/keysyms.h"
|
2019-03-11 17:44:57 +03:00
|
|
|
void attr_to_script(char *buf, struct perf_event_attr *attr);
|
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
|
2018-05-28 19:54:59 +03:00
|
|
|
struct hist_browser_timer *hbt,
|
|
|
|
struct annotation_options *annotation_opts);
|
2015-03-18 00:27:28 +03:00
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
|
2018-05-28 19:54:59 +03:00
|
|
|
struct hist_browser_timer *hbt,
|
|
|
|
struct annotation_options *annotation_opts);
|
2012-09-28 13:32:02 +04:00
|
|
|
|
2019-07-21 14:23:52 +03:00
|
|
|
int perf_evlist__tui_browse_hists(struct evlist *evlist, const char *help,
|
2012-11-02 09:50:06 +04:00
|
|
|
struct hist_browser_timer *hbt,
|
2013-05-14 06:09:04 +04:00
|
|
|
float min_pcnt,
|
2018-01-19 00:26:29 +03:00
|
|
|
struct perf_env *env,
|
2018-05-28 19:54:59 +03:00
|
|
|
bool warn_lost_event,
|
|
|
|
struct annotation_options *annotation_options);
|
2019-03-11 17:44:57 +03:00
|
|
|
|
2019-07-21 14:23:51 +03:00
|
|
|
int script_browse(const char *script_opt, struct evsel *evsel);
|
2019-03-11 17:44:58 +03:00
|
|
|
|
|
|
|
void run_script(char *cmd);
|
|
|
|
int res_sample_browse(struct res_sample *res_samples, int num_res,
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel, enum rstype rstype);
|
2019-03-11 17:44:58 +03:00
|
|
|
void res_sample_init(void);
|
2012-09-28 13:32:02 +04:00
|
|
|
#else
|
2011-03-06 19:07:30 +03:00
|
|
|
static inline
|
2019-07-21 14:23:52 +03:00
|
|
|
int perf_evlist__tui_browse_hists(struct evlist *evlist __maybe_unused,
|
2012-09-11 02:15:03 +04:00
|
|
|
const char *help __maybe_unused,
|
2012-11-02 09:50:06 +04:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused,
|
2013-05-14 06:09:04 +04:00
|
|
|
float min_pcnt __maybe_unused,
|
2018-01-19 00:26:29 +03:00
|
|
|
struct perf_env *env __maybe_unused,
|
2018-05-28 19:54:59 +03:00
|
|
|
bool warn_lost_event __maybe_unused,
|
|
|
|
struct annotation_options *annotation_options __maybe_unused)
|
2010-05-24 05:36:51 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-03-18 00:27:28 +03:00
|
|
|
static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2018-05-28 19:54:59 +03:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused,
|
|
|
|
struct annotation_options *annotation_options __maybe_unused)
|
2015-03-18 00:27:28 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-24 05:36:51 +04:00
|
|
|
|
2013-11-05 22:32:36 +04:00
|
|
|
static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2018-05-28 19:54:59 +03:00
|
|
|
struct hist_browser_timer *hbt __maybe_unused,
|
|
|
|
struct annotation_options *annotation_opts __maybe_unused)
|
2010-05-22 18:25:40 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-30 07:56:04 +04:00
|
|
|
|
2019-03-11 17:44:57 +03:00
|
|
|
static inline int script_browse(const char *script_opt __maybe_unused,
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel __maybe_unused)
|
2012-10-30 07:56:04 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-11 17:44:58 +03:00
|
|
|
static inline int res_sample_browse(struct res_sample *res_samples __maybe_unused,
|
|
|
|
int num_res __maybe_unused,
|
2019-07-21 14:23:51 +03:00
|
|
|
struct evsel *evsel __maybe_unused,
|
2019-03-11 17:44:58 +03:00
|
|
|
enum rstype rstype __maybe_unused)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void res_sample_init(void) {}
|
|
|
|
|
2013-02-26 09:02:02 +04:00
|
|
|
#define K_LEFT -1000
|
|
|
|
#define K_RIGHT -2000
|
2013-02-26 09:02:03 +04:00
|
|
|
#define K_SWITCH_INPUT_DATA -3000
|
2010-05-11 18:10:15 +04:00
|
|
|
#endif
|
2010-07-22 00:58:25 +04:00
|
|
|
|
2013-11-05 22:32:36 +04:00
|
|
|
unsigned int hists__sort_list_width(struct hists *hists);
|
2016-02-26 15:13:16 +03:00
|
|
|
unsigned int hists__overhead_width(struct hists *hists);
|
2014-02-07 07:06:07 +04:00
|
|
|
|
2015-07-18 18:24:49 +03:00
|
|
|
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
|
2019-11-07 10:47:15 +03:00
|
|
|
struct perf_sample *sample, bool nonany_branch_mode,
|
|
|
|
u64 *total_cycles);
|
2015-07-18 18:24:49 +03:00
|
|
|
|
2014-02-07 07:06:07 +04:00
|
|
|
struct option;
|
2016-03-22 19:09:37 +03:00
|
|
|
int parse_filter_percentage(const struct option *opt, const char *arg, int unset);
|
2014-01-14 07:02:15 +04:00
|
|
|
int perf_hist_config(const char *var, const char *value);
|
2014-02-07 07:06:07 +04:00
|
|
|
|
2016-01-18 12:24:13 +03:00
|
|
|
void perf_hpp_list__init(struct perf_hpp_list *list);
|
|
|
|
|
2016-02-24 18:13:36 +03: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-24 18:13:41 +03:00
|
|
|
#define HIERARCHY_INDENT 3
|
|
|
|
|
2016-02-26 15:13:16 +03:00
|
|
|
bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit);
|
2016-09-22 18:36:35 +03: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 18:36:36 +03:00
|
|
|
int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
|
|
|
|
struct perf_hpp_list *hpp_list);
|
2016-09-22 18:36:37 +03:00
|
|
|
int hists__fprintf_headers(struct hists *hists, FILE *fp);
|
2018-04-02 20: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 15:13:16 +03:00
|
|
|
|
2009-09-28 17:32:55 +04:00
|
|
|
#endif /* __PERF_HIST_H */
|