2009-09-28 17:32:55 +04:00
|
|
|
#ifndef __PERF_HIST_H
|
|
|
|
#define __PERF_HIST_H
|
|
|
|
|
2009-12-14 18:10:39 +03:00
|
|
|
#include <linux/types.h>
|
2011-10-06 00:50:23 +04:00
|
|
|
#include <pthread.h>
|
2009-09-28 17:32:55 +04:00
|
|
|
#include "callchain.h"
|
2014-10-09 23:16:00 +04:00
|
|
|
#include "evsel.h"
|
2012-11-02 09:50:06 +04:00
|
|
|
#include "header.h"
|
2013-10-25 15:24:53 +04:00
|
|
|
#include "color.h"
|
2013-10-11 09:15:38 +04:00
|
|
|
#include "ui/progress.h"
|
2009-09-28 17:32:55 +04:00
|
|
|
|
2009-12-14 18:10:39 +03:00
|
|
|
struct hist_entry;
|
|
|
|
struct addr_location;
|
|
|
|
struct symbol;
|
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,
|
2014-03-17 23:59:21 +04:00
|
|
|
};
|
|
|
|
|
2010-07-20 21:42:52 +04:00
|
|
|
enum hist_column {
|
|
|
|
HISTC_SYMBOL,
|
|
|
|
HISTC_DSO,
|
|
|
|
HISTC_THREAD,
|
|
|
|
HISTC_COMM,
|
|
|
|
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,
|
|
|
|
HISTC_MEM_LOCKED,
|
|
|
|
HISTC_MEM_TLB,
|
|
|
|
HISTC_MEM_LVL,
|
|
|
|
HISTC_MEM_SNOOP,
|
2014-06-01 17:38:29 +04:00
|
|
|
HISTC_MEM_DCACHELINE,
|
2013-09-20 18:40:43 +04:00
|
|
|
HISTC_TRANSACTION,
|
2015-07-18 18:24:46 +03:00
|
|
|
HISTC_CYCLES,
|
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 {
|
2011-10-06 00:50:23 +04:00
|
|
|
struct rb_root entries_in_array[2];
|
|
|
|
struct rb_root *entries_in;
|
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 rb_root entries;
|
2011-10-06 00:50:23 +04:00
|
|
|
struct rb_root 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;
|
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];
|
2015-09-04 17:45:44 +03:00
|
|
|
int socket_filter;
|
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
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
struct perf_evsel *evsel;
|
|
|
|
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
|
|
|
|
2013-11-05 22:32:36 +04:00
|
|
|
struct hist_entry *__hists__add_entry(struct hists *hists,
|
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 addr_location *al,
|
2013-10-31 10:56:03 +04:00
|
|
|
struct symbol *parent,
|
|
|
|
struct branch_info *bi,
|
|
|
|
struct mem_info *mi, u64 period,
|
2012-09-11 08:34:27 +04:00
|
|
|
u64 weight, u64 transaction,
|
|
|
|
bool sample_self);
|
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
|
|
|
|
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);
|
2014-12-19 18:31:40 +03:00
|
|
|
void hist_entry__delete(struct hist_entry *he);
|
2009-12-14 18:10:39 +03:00
|
|
|
|
2014-12-22 07:44:10 +03:00
|
|
|
void hists__output_resort(struct hists *hists, struct ui_progress *prog);
|
2013-11-05 22:32:36 +04:00
|
|
|
void 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);
|
|
|
|
|
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);
|
2012-12-18 23:24:46 +04:00
|
|
|
void events_stats__inc(struct events_stats *stats, u32 type);
|
2012-12-18 23:02:17 +04:00
|
|
|
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
|
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,
|
2013-05-14 06:09:04 +04:00
|
|
|
int max_cols, float min_pcnt, FILE *fp);
|
2014-10-10 22:49:21 +04:00
|
|
|
size_t perf_evlist__fprintf_nr_events(struct perf_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);
|
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);
|
2012-11-09 00:54:33 +04:00
|
|
|
|
2014-10-09 23:16:00 +04:00
|
|
|
struct hists_evsel {
|
|
|
|
struct perf_evsel evsel;
|
|
|
|
struct hists hists;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct perf_evsel *hists_to_evsel(struct hists *hists)
|
|
|
|
{
|
|
|
|
struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists);
|
|
|
|
return &hevsel->evsel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct hists *evsel__hists(struct perf_evsel *evsel)
|
|
|
|
{
|
|
|
|
struct hists_evsel *hevsel = (struct hists_evsel *)evsel;
|
|
|
|
return &hevsel->hists;
|
|
|
|
}
|
|
|
|
|
|
|
|
int hists__init(void);
|
|
|
|
|
2012-09-03 06:53:06 +04:00
|
|
|
struct perf_hpp {
|
|
|
|
char *buf;
|
|
|
|
size_t size;
|
|
|
|
const char *sep;
|
|
|
|
void *ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
struct perf_evsel *evsel);
|
|
|
|
int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
|
|
|
struct perf_evsel *evsel);
|
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);
|
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;
|
2012-09-03 06:53:06 +04:00
|
|
|
};
|
|
|
|
|
2012-10-13 02:06:16 +04:00
|
|
|
extern struct list_head perf_hpp__list;
|
2014-03-03 06:46:55 +04:00
|
|
|
extern struct list_head perf_hpp__sort_list;
|
2012-10-13 02:06:16 +04:00
|
|
|
|
|
|
|
#define perf_hpp__for_each_format(format) \
|
|
|
|
list_for_each_entry(format, &perf_hpp__list, list)
|
|
|
|
|
2014-05-07 13:42:24 +04:00
|
|
|
#define perf_hpp__for_each_format_safe(format, tmp) \
|
|
|
|
list_for_each_entry_safe(format, tmp, &perf_hpp__list, list)
|
|
|
|
|
2014-03-03 06:46:55 +04:00
|
|
|
#define perf_hpp__for_each_sort_list(format) \
|
|
|
|
list_for_each_entry(format, &perf_hpp__sort_list, sort_list)
|
|
|
|
|
2014-05-07 13:42:24 +04:00
|
|
|
#define perf_hpp__for_each_sort_list_safe(format, tmp) \
|
|
|
|
list_for_each_entry_safe(format, tmp, &perf_hpp__sort_list, sort_list)
|
|
|
|
|
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);
|
2012-10-13 02:06:16 +04:00
|
|
|
void perf_hpp__column_register(struct perf_hpp_fmt *format);
|
2013-12-16 11:55:13 +04:00
|
|
|
void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
|
2012-10-13 02:06:16 +04:00
|
|
|
void perf_hpp__column_enable(unsigned col);
|
2013-12-16 11:55:13 +04:00
|
|
|
void perf_hpp__column_disable(unsigned col);
|
|
|
|
void perf_hpp__cancel_cumulate(void);
|
|
|
|
|
2014-03-03 06:46:55 +04:00
|
|
|
void perf_hpp__register_sort_field(struct perf_hpp_fmt *format);
|
2014-03-03 11:16:20 +04:00
|
|
|
void perf_hpp__setup_output_field(void);
|
2014-05-07 13:42:24 +04:00
|
|
|
void perf_hpp__reset_output_field(void);
|
2014-03-04 05:46:34 +04:00
|
|
|
void perf_hpp__append_sort_keys(void);
|
|
|
|
|
|
|
|
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
|
|
|
|
bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
|
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
|
|
|
|
|
|
|
static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format)
|
|
|
|
{
|
|
|
|
return format->elide;
|
|
|
|
}
|
|
|
|
|
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);
|
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;
|
|
|
|
}
|
|
|
|
|
2011-03-06 03:40:06 +03:00
|
|
|
struct perf_evlist;
|
|
|
|
|
2012-11-02 09:50:05 +04:00
|
|
|
struct hist_browser_timer {
|
|
|
|
void (*timer)(void *arg);
|
|
|
|
void *arg;
|
|
|
|
int refresh;
|
|
|
|
};
|
|
|
|
|
2013-09-30 14:07:11 +04:00
|
|
|
#ifdef HAVE_SLANG_SUPPORT
|
2012-09-28 13:32:02 +04:00
|
|
|
#include "../ui/keysyms.h"
|
2015-03-18 00:27:28 +03:00
|
|
|
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
|
|
|
|
struct hist_browser_timer *hbt);
|
|
|
|
|
2013-03-05 09:53:21 +04:00
|
|
|
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
|
2012-11-02 09:50:05 +04:00
|
|
|
struct hist_browser_timer *hbt);
|
2012-09-28 13:32:02 +04:00
|
|
|
|
|
|
|
int perf_evlist__tui_browse_hists(struct perf_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,
|
2015-08-28 12:48:04 +03:00
|
|
|
struct perf_env *env);
|
2012-10-30 07:56:04 +04:00
|
|
|
int script_browse(const char *script_opt);
|
2012-09-28 13:32:02 +04:00
|
|
|
#else
|
2011-03-06 19:07:30 +03:00
|
|
|
static inline
|
2012-09-11 02:15:03 +04:00
|
|
|
int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
|
|
|
|
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,
|
2015-08-28 12:48:04 +03:00
|
|
|
struct perf_env *env __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,
|
|
|
|
struct perf_evsel *evsel __maybe_unused,
|
|
|
|
struct hist_browser_timer *hbt __maybe_unused)
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
struct perf_evsel *evsel __maybe_unused,
|
|
|
|
struct hist_browser_timer *hbt __maybe_unused)
|
2010-05-22 18:25:40 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-30 07:56:04 +04:00
|
|
|
|
2012-11-12 09:14:00 +04:00
|
|
|
static inline int script_browse(const char *script_opt __maybe_unused)
|
2012-10-30 07:56:04 +04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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);
|
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,
|
|
|
|
struct perf_sample *sample, bool nonany_branch_mode);
|
|
|
|
|
2014-02-07 07:06:07 +04:00
|
|
|
struct option;
|
|
|
|
int parse_filter_percentage(const struct option *opt __maybe_unused,
|
|
|
|
const char *arg, int unset __maybe_unused);
|
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
|
|
|
|
2009-09-28 17:32:55 +04:00
|
|
|
#endif /* __PERF_HIST_H */
|