File Index
Files and directories
Sign in
FILE

hist.h

File preview with syntax highlighting.

linux-6.19.14/tools/perf/util/hist.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __PERF_HIST_H
  3#define __PERF_HIST_H
  4
  5#include <linux/rbtree.h>
  6#include <linux/types.h>
  7#include "callchain.h"
  8#include "color.h"
  9#include "events_stats.h"
 10#include "evsel.h"
 11#include "map_symbol.h"
 12#include "mem-events.h"
 13#include "mutex.h"
 14#include "sample.h"
 15#include "spark.h"
 16#include "stat.h"
 17
 18struct addr_location;
 19struct mem_info;
 20struct kvm_info;
 21struct branch_info;
 22struct branch_stack;
 23struct block_info;
 24struct ui_progress;
 25
 26enum hist_filter {
 27	HIST_FILTER__DSO,
 28	HIST_FILTER__THREAD,
 29	HIST_FILTER__PARENT,
 30	HIST_FILTER__SYMBOL,
 31	HIST_FILTER__GUEST,
 32	HIST_FILTER__HOST,
 33	HIST_FILTER__SOCKET,
 34	HIST_FILTER__C2C,
 35	HIST_FILTER__PARALLELISM,
 36};
 37
 38typedef u16 filter_mask_t;
 39
 40enum hist_column {
 41	HISTC_SYMBOL,
 42	HISTC_TIME,
 43	HISTC_DSO,
 44	HISTC_THREAD,
 45	HISTC_TGID,
 46	HISTC_COMM,
 47	HISTC_CGROUP_ID,
 48	HISTC_CGROUP,
 49	HISTC_PARENT,
 50	HISTC_PARALLELISM,
 51	HISTC_CPU,
 52	HISTC_SOCKET,
 53	HISTC_SRCLINE,
 54	HISTC_SRCFILE,
 55	HISTC_MISPREDICT,
 56	HISTC_IN_TX,
 57	HISTC_ABORT,
 58	HISTC_SYMBOL_FROM,
 59	HISTC_SYMBOL_TO,
 60	HISTC_DSO_FROM,
 61	HISTC_DSO_TO,
 62	HISTC_LOCAL_WEIGHT,
 63	HISTC_GLOBAL_WEIGHT,
 64	HISTC_CODE_PAGE_SIZE,
 65	HISTC_MEM_DADDR_SYMBOL,
 66	HISTC_MEM_DADDR_DSO,
 67	HISTC_MEM_PHYS_DADDR,
 68	HISTC_MEM_DATA_PAGE_SIZE,
 69	HISTC_MEM_LOCKED,
 70	HISTC_MEM_TLB,
 71	HISTC_MEM_LVL,
 72	HISTC_MEM_SNOOP,
 73	HISTC_MEM_DCACHELINE,
 74	HISTC_MEM_IADDR_SYMBOL,
 75	HISTC_TRANSACTION,
 76	HISTC_CYCLES,
 77	HISTC_SRCLINE_FROM,
 78	HISTC_SRCLINE_TO,
 79	HISTC_TRACE,
 80	HISTC_SYM_SIZE,
 81	HISTC_DSO_SIZE,
 82	HISTC_SYMBOL_IPC,
 83	HISTC_MEM_BLOCKED,
 84	HISTC_LOCAL_INS_LAT,
 85	HISTC_GLOBAL_INS_LAT,
 86	HISTC_LOCAL_P_STAGE_CYC,
 87	HISTC_GLOBAL_P_STAGE_CYC,
 88	HISTC_ADDR_FROM,
 89	HISTC_ADDR_TO,
 90	HISTC_ADDR,
 91	HISTC_SIMD,
 92	HISTC_TYPE,
 93	HISTC_TYPE_OFFSET,
 94	HISTC_SYMBOL_OFFSET,
 95	HISTC_TYPE_CACHELINE,
 96	HISTC_CALLCHAIN_BRANCH_PREDICTED,
 97	HISTC_CALLCHAIN_BRANCH_ABORT,
 98	HISTC_CALLCHAIN_BRANCH_CYCLES,
 99	HISTC_NR_COLS, /* Last entry */
100};
101
102struct thread;
103struct dso;
104
105#define MEM_STAT_LEN  8
106
107struct he_mem_stat {
108	/* meaning of entries depends on enum mem_stat_type */
109	u64			entries[MEM_STAT_LEN];
110};
111
112struct hists {
113	struct rb_root_cached	entries_in_array[2];
114	struct rb_root_cached	*entries_in;
115	struct rb_root_cached	entries;
116	struct rb_root_cached	entries_collapsed;
117	u64			nr_entries;
118	u64			nr_non_filtered_entries;
119	u64			callchain_period;
120	u64			callchain_non_filtered_period;
121	u64			callchain_latency;
122	u64			callchain_non_filtered_latency;
123	struct thread		*thread_filter;
124	const struct dso	*dso_filter;
125	const char		*uid_filter_str;
126	const char		*symbol_filter_str;
127	unsigned long		*parallelism_filter;
128	struct mutex		lock;
129	struct hists_stats	stats;
130	u64			event_stream;
131	u16			col_len[HISTC_NR_COLS];
132	bool			has_callchains;
133	int			socket_filter;
134	struct perf_hpp_list	*hpp_list;
135	struct list_head	hpp_formats;
136	int			nr_hpp_node;
137	int			nr_mem_stats;
138	enum mem_stat_type	*mem_stat_types;
139	struct he_mem_stat	*mem_stat_total;
140};
141
142#define hists__has(__h, __f) (__h)->hpp_list->__f
143
144struct hist_entry_iter;
145
146struct hist_iter_ops {
147	int (*prepare_entry)(struct hist_entry_iter *, struct addr_location *);
148	int (*add_single_entry)(struct hist_entry_iter *, struct addr_location *);
149	int (*next_entry)(struct hist_entry_iter *, struct addr_location *);
150	int (*add_next_entry)(struct hist_entry_iter *, struct addr_location *);
151	int (*finish_entry)(struct hist_entry_iter *, struct addr_location *);
152};
153
154struct hist_entry_iter {
155	int total;
156	int curr;
157
158	struct evsel *evsel;
159	struct perf_sample *sample;
160	struct hist_entry *he;
161	struct symbol *parent;
162
163	struct mem_info *mi;
164	struct branch_info *bi;
165	struct hist_entry **he_cache;
166
167	const struct hist_iter_ops *ops;
168	/* user-defined callback function (optional) */
169	int (*add_entry_cb)(struct hist_entry_iter *iter,
170			    struct addr_location *al, bool single, void *arg);
171	bool hide_unresolved;
172};
173
174extern const struct hist_iter_ops hist_iter_normal;
175extern const struct hist_iter_ops hist_iter_branch;
176extern const struct hist_iter_ops hist_iter_mem;
177extern const struct hist_iter_ops hist_iter_cumulative;
178
179struct res_sample {
180	u64 time;
181	int cpu;
182	int tid;
183};
184
185struct he_stat {
186	u64			period;
187	/*
188	 * Period re-scaled from CPU time to wall-clock time (divided by the
189	 * parallelism at the time of the sample). This represents effect of
190	 * the event on latency rather than CPU consumption.
191	 */
192	u64			latency;
193	u64			period_sys;
194	u64			period_us;
195	u64			period_guest_sys;
196	u64			period_guest_us;
197	u64			weight1;
198	u64			weight2;
199	u64			weight3;
200	u32			nr_events;
201};
202
203struct namespace_id {
204	u64			dev;
205	u64			ino;
206};
207
208struct hist_entry_diff {
209	bool	computed;
210	union {
211		/* PERF_HPP__DELTA */
212		double	period_ratio_delta;
213
214		/* PERF_HPP__RATIO */
215		double	period_ratio;
216
217		/* HISTC_WEIGHTED_DIFF */
218		s64	wdiff;
219
220		/* PERF_HPP_DIFF__CYCLES */
221		s64	cycles;
222	};
223	struct stats	stats;
224	unsigned long	svals[NUM_SPARKS];
225};
226
227struct hist_entry_ops {
228	void	*(*new)(size_t size);
229	void	(*free)(void *ptr);
230};
231
232/**
233 * struct hist_entry - histogram entry
234 *
235 * @row_offset - offset from the first callchain expanded to appear on screen
236 * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
237 */
238struct hist_entry {
239	struct rb_node		rb_node_in;
240	struct rb_node		rb_node;
241	union {
242		struct list_head node;
243		struct list_head head;
244	} pairs;
245	struct he_stat		stat;
246	struct he_stat		*stat_acc;
247	struct he_mem_stat	*mem_stat;
248	struct map_symbol	ms;
249	struct thread		*thread;
250	struct comm		*comm;
251	struct namespace_id	cgroup_id;
252	u64			cgroup;
253	u64			ip;
254	u64			transaction;
255	u64			code_page_size;
256	u64			weight;
257	u64			ins_lat;
258	/** @weight3: On x86 holds retire_lat, on powerpc holds p_stage_cyc. */
259	u64			weight3;
260	s32			socket;
261	s32			cpu;
262	int			parallelism;
263	int			mem_type_off;
264	u8			cpumode;
265	u8			depth;
266	struct simd_flags	simd_flags;
267
268	/* We are added by hists__add_dummy_entry. */
269	bool			dummy;
270	bool			leaf;
271
272	char			level;
273	filter_mask_t		filtered;
274
275	u16			callchain_size;
276	union {
277		/*
278		 * Since perf diff only supports the stdio output, TUI
279		 * fields are only accessed from perf report (or perf
280		 * top).  So make it a union to reduce memory usage.
281		 */
282		struct hist_entry_diff	diff;
283		struct /* for TUI */ {
284			u16	row_offset;
285			u16	nr_rows;
286			bool	init_have_children;
287			bool	unfolded;
288			bool	has_children;
289			bool	has_no_entry;
290		};
291	};
292	char			*srcline;
293	char			*srcfile;
294	struct symbol		*parent;
295	struct branch_info	*branch_info;
296	long			time;
297	struct hists		*hists;
298	struct mem_info		*mem_info;
299	struct block_info	*block_info;
300	struct kvm_info		*kvm_info;
301	void			*raw_data;
302	u32			raw_size;
303	int			num_res;
304	struct res_sample	*res_samples;
305	void			*trace_output;
306	struct perf_hpp_list	*hpp_list;
307	struct hist_entry	*parent_he;
308	struct hist_entry_ops	*ops;
309	struct annotated_data_type *mem_type;
310	union {
311		/* this is for hierarchical entry structure */
312		struct {
313			struct rb_root_cached	hroot_in;
314			struct rb_root_cached   hroot_out;
315		};				/* non-leaf entries */
316		struct rb_root	sorted_chain;	/* leaf entry has callchains */
317	};
318	struct callchain_root	callchain[0]; /* must be last member */
319};
320
321static __pure inline bool hist_entry__has_callchains(struct hist_entry *he)
322{
323	return he->callchain_size != 0;
324}
325
326static inline bool hist_entry__has_pairs(struct hist_entry *he)
327{
328	return !list_empty(&he->pairs.node);
329}
330
331static inline struct hist_entry *hist_entry__next_pair(struct hist_entry *he)
332{
333	if (hist_entry__has_pairs(he))
334		return list_entry(he->pairs.node.next, struct hist_entry, pairs.node);
335	return NULL;
336}
337
338static inline void hist_entry__add_pair(struct hist_entry *pair,
339					struct hist_entry *he)
340{
341	list_add_tail(&pair->pairs.node, &he->pairs.head);
342}
343
344struct hist_entry *hists__add_entry(struct hists *hists,
345				    struct addr_location *al,
346				    struct symbol *parent,
347				    struct branch_info *bi,
348				    struct mem_info *mi,
349				    struct kvm_info *ki,
350				    struct perf_sample *sample,
351				    bool sample_self);
352
353struct hist_entry *hists__add_entry_ops(struct hists *hists,
354					struct hist_entry_ops *ops,
355					struct addr_location *al,
356					struct symbol *sym_parent,
357					struct branch_info *bi,
358					struct mem_info *mi,
359					struct kvm_info *ki,
360					struct perf_sample *sample,
361					bool sample_self);
362
363struct hist_entry *hists__add_entry_block(struct hists *hists,
364					  struct addr_location *al,
365					  struct block_info *bi);
366
367int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
368			 int max_stack_depth, void *arg);
369
370struct perf_hpp;
371struct perf_hpp_fmt;
372
373int hist_entry__transaction_len(void);
374int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
375			      struct hists *hists);
376int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
377				   struct perf_hpp_fmt *fmt, int printed);
378int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, size_t size,
379			     unsigned int width);
380void hist_entry__delete(struct hist_entry *he);
381
382typedef int (*hists__resort_cb_t)(struct hist_entry *he, void *arg);
383
384void evsel__output_resort_cb(struct evsel *evsel, struct ui_progress *prog,
385			     hists__resort_cb_t cb, void *cb_arg);
386void evsel__output_resort(struct evsel *evsel, struct ui_progress *prog);
387void hists__output_resort(struct hists *hists, struct ui_progress *prog);
388void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
389			     hists__resort_cb_t cb);
390int hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
391
392void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
393void hists__delete_entries(struct hists *hists);
394void hists__output_recalc_col_len(struct hists *hists, int max_rows);
395
396struct hist_entry *hists__get_entry(struct hists *hists, int idx);
397
398u64 hists__total_period(struct hists *hists);
399u64 hists__total_latency(struct hists *hists);
400void hists__reset_stats(struct hists *hists);
401void hists__inc_stats(struct hists *hists, struct hist_entry *h);
402void hists__inc_nr_events(struct hists *hists);
403void hists__inc_nr_samples(struct hists *hists, bool filtered);
404void hists__inc_nr_lost_samples(struct hists *hists, u32 lost);
405void hists__inc_nr_dropped_samples(struct hists *hists, u32 lost);
406
407size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
408		      int max_cols, float min_pcnt, FILE *fp,
409		      bool ignore_callchains);
410size_t evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp);
411
412void hists__filter_by_dso(struct hists *hists);
413void hists__filter_by_thread(struct hists *hists);
414void hists__filter_by_symbol(struct hists *hists);
415void hists__filter_by_socket(struct hists *hists);
416void hists__filter_by_parallelism(struct hists *hists);
417
418static inline bool hists__has_filter(struct hists *hists)
419{
420	return hists->thread_filter || hists->dso_filter ||
421		hists->symbol_filter_str || (hists->socket_filter > -1) ||
422		hists->parallelism_filter;
423}
424
425u16 hists__col_len(struct hists *hists, enum hist_column col);
426void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len);
427bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len);
428void hists__reset_col_len(struct hists *hists);
429void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
430
431void hists__match(struct hists *leader, struct hists *other);
432int hists__link(struct hists *leader, struct hists *other);
433int hists__unlink(struct hists *hists);
434
435static inline float hist_entry__get_percent_limit(struct hist_entry *he)
436{
437	u64 period = he->stat.period;
438	u64 total_period = hists__total_period(he->hists);
439
440	if (unlikely(total_period == 0))
441		return 0;
442
443	if (symbol_conf.cumulate_callchain)
444		period = he->stat_acc->period;
445
446	return period * 100.0 / total_period;
447}
448
449struct hists_evsel {
450	struct evsel evsel;
451	struct hists	  hists;
452};
453
454static inline struct evsel *hists_to_evsel(struct hists *hists)
455{
456	struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists);
457	return &hevsel->evsel;
458}
459
460static inline struct hists *evsel__hists(struct evsel *evsel)
461{
462	struct hists_evsel *hevsel = (struct hists_evsel *)evsel;
463	return &hevsel->hists;
464}
465
466static __pure inline bool hists__has_callchains(struct hists *hists)
467{
468	return hists->has_callchains;
469}
470
471int hists__init(void);
472int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
473
474struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists);
475
476struct perf_hpp {
477	char *buf;
478	size_t size;
479	const char *sep;
480	void *ptr;
481	bool skip;
482};
483
484typedef int64_t (*perf_hpp_fmt_cmp_t)(
485	struct perf_hpp_fmt *, struct hist_entry *, struct hist_entry *);
486
487struct perf_hpp_fmt {
488	const char *name;
489	int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
490		      struct hists *hists, int line, int *span);
491	int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
492		     struct hists *hists);
493	void (*init)(struct perf_hpp_fmt *fmt, struct hist_entry *he);
494	int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
495		     struct hist_entry *he);
496	int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
497		     struct hist_entry *he);
498	perf_hpp_fmt_cmp_t cmp;
499	perf_hpp_fmt_cmp_t collapse;
500	perf_hpp_fmt_cmp_t sort;
501	bool (*equal)(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
502	void (*free)(struct perf_hpp_fmt *fmt);
503
504	struct list_head list;
505	struct list_head sort_list;
506	bool elide;
507	int len;
508	int user_len;
509	int idx;
510	int level;
511};
512
513struct perf_hpp_list {
514	struct list_head fields;
515	struct list_head sorts;
516
517	int nr_header_lines;
518	int need_collapse;
519	int parent;
520	int sym;
521	int dso;
522	int socket;
523	int thread;
524	int comm;
525};
526
527extern struct perf_hpp_list perf_hpp_list;
528
529struct perf_hpp_list_node {
530	struct list_head	list;
531	struct perf_hpp_list	hpp;
532	int			level;
533	bool			skip;
534};
535
536void perf_hpp_list__column_register(struct perf_hpp_list *list,
537				    struct perf_hpp_fmt *format);
538void perf_hpp_list__register_sort_field(struct perf_hpp_list *list,
539					struct perf_hpp_fmt *format);
540void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
541				       struct perf_hpp_fmt *format);
542
543static inline void perf_hpp__column_register(struct perf_hpp_fmt *format)
544{
545	perf_hpp_list__column_register(&perf_hpp_list, format);
546}
547
548static inline void perf_hpp__register_sort_field(struct perf_hpp_fmt *format)
549{
550	perf_hpp_list__register_sort_field(&perf_hpp_list, format);
551}
552
553static inline void perf_hpp__prepend_sort_field(struct perf_hpp_fmt *format)
554{
555	perf_hpp_list__prepend_sort_field(&perf_hpp_list, format);
556}
557
558#define perf_hpp_list__for_each_format(_list, format) \
559	list_for_each_entry(format, &(_list)->fields, list)
560
561#define perf_hpp_list__for_each_format_safe(_list, format, tmp)	\
562	list_for_each_entry_safe(format, tmp, &(_list)->fields, list)
563
564#define perf_hpp_list__for_each_sort_list(_list, format) \
565	list_for_each_entry(format, &(_list)->sorts, sort_list)
566
567#define perf_hpp_list__for_each_sort_list_safe(_list, format, tmp)	\
568	list_for_each_entry_safe(format, tmp, &(_list)->sorts, sort_list)
569
570#define hists__for_each_format(hists, format) \
571	perf_hpp_list__for_each_format((hists)->hpp_list, format)
572
573#define hists__for_each_sort_list(hists, format) \
574	perf_hpp_list__for_each_sort_list((hists)->hpp_list, format)
575
576extern struct perf_hpp_fmt perf_hpp__format[];
577
578enum {
579	/* Matches perf_hpp__format array. */
580	PERF_HPP__OVERHEAD,
581	PERF_HPP__LATENCY,
582	PERF_HPP__OVERHEAD_SYS,
583	PERF_HPP__OVERHEAD_US,
584	PERF_HPP__OVERHEAD_GUEST_SYS,
585	PERF_HPP__OVERHEAD_GUEST_US,
586	PERF_HPP__OVERHEAD_ACC,
587	PERF_HPP__LATENCY_ACC,
588	PERF_HPP__SAMPLES,
589	PERF_HPP__PERIOD,
590	PERF_HPP__WEIGHT1,
591	PERF_HPP__WEIGHT2,
592	PERF_HPP__WEIGHT3,
593	PERF_HPP__MEM_STAT_OP,
594	PERF_HPP__MEM_STAT_CACHE,
595	PERF_HPP__MEM_STAT_MEMORY,
596	PERF_HPP__MEM_STAT_SNOOP,
597	PERF_HPP__MEM_STAT_DTLB,
598
599	PERF_HPP__MAX_INDEX
600};
601
602void perf_hpp__init(void);
603void perf_hpp__cancel_cumulate(struct evlist *evlist);
604void perf_hpp__cancel_latency(struct evlist *evlist);
605void perf_hpp__setup_output_field(struct perf_hpp_list *list);
606void perf_hpp__reset_output_field(struct perf_hpp_list *list);
607void perf_hpp__append_sort_keys(struct perf_hpp_list *list);
608int perf_hpp__setup_hists_formats(struct perf_hpp_list *list,
609				  struct evlist *evlist);
610int perf_hpp__alloc_mem_stats(struct perf_hpp_list *list,
611			      struct evlist *evlist);
612
613
614bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
615bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *format);
616bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt, struct hists *hists);
617bool perf_hpp__is_trace_entry(struct perf_hpp_fmt *fmt);
618bool perf_hpp__is_srcline_entry(struct perf_hpp_fmt *fmt);
619bool perf_hpp__is_srcfile_entry(struct perf_hpp_fmt *fmt);
620bool perf_hpp__is_thread_entry(struct perf_hpp_fmt *fmt);
621bool perf_hpp__is_comm_entry(struct perf_hpp_fmt *fmt);
622bool perf_hpp__is_dso_entry(struct perf_hpp_fmt *fmt);
623bool perf_hpp__is_sym_entry(struct perf_hpp_fmt *fmt);
624bool perf_hpp__is_parallelism_entry(struct perf_hpp_fmt *fmt);
625
626struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt);
627
628int hist_entry__filter(struct hist_entry *he, int type, const void *arg);
629
630static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format,
631					 struct hists *hists)
632{
633	if (format->elide)
634		return true;
635
636	if (perf_hpp__is_dynamic_entry(format) &&
637	    !perf_hpp__defined_dynamic_entry(format, hists))
638		return true;
639
640	return false;
641}
642
643void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
644void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists);
645void perf_hpp__set_user_width(const char *width_list_str);
646void hists__reset_column_width(struct hists *hists);
647
648enum perf_hpp_fmt_type {
649	PERF_HPP_FMT_TYPE__RAW,
650	PERF_HPP_FMT_TYPE__PERCENT,
651	PERF_HPP_FMT_TYPE__LATENCY,
652	PERF_HPP_FMT_TYPE__AVERAGE,
653};
654
655typedef u64 (*hpp_field_fn)(struct hist_entry *he);
656typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
657typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...);
658
659int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
660	     struct hist_entry *he, hpp_field_fn get_field,
661	     const char *fmtstr, hpp_snprint_fn print_fn,
662	     enum perf_hpp_fmt_type fmtype);
663int hpp__fmt_acc(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
664		 struct hist_entry *he, hpp_field_fn get_field,
665		 const char *fmtstr, hpp_snprint_fn print_fn,
666		 enum perf_hpp_fmt_type fmtype);
667int hpp__fmt_mem_stat(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
668		      struct hist_entry *he, enum mem_stat_type mst,
669		      const char *fmtstr, hpp_snprint_fn print_fn);
670
671static inline void advance_hpp(struct perf_hpp *hpp, int inc)
672{
673	hpp->buf  += inc;
674	hpp->size -= inc;
675}
676
677static inline size_t perf_hpp__use_color(void)
678{
679	return !symbol_conf.field_sep;
680}
681
682static inline size_t perf_hpp__color_overhead(void)
683{
684	return perf_hpp__use_color() ?
685	       (COLOR_MAXLEN + sizeof(PERF_COLOR_RESET)) * PERF_HPP__MAX_INDEX
686	       : 0;
687}
688
689struct evlist;
690
691struct hist_browser_timer {
692	void (*timer)(void *arg);
693	void *arg;
694	int refresh;
695};
696
697enum rstype {
698	A_NORMAL,
699	A_ASM,
700	A_SOURCE
701};
702
703struct block_hist {
704	struct hists		block_hists;
705	struct perf_hpp_list	block_list;
706	struct perf_hpp_fmt	block_fmt;
707	int			block_idx;
708	bool			valid;
709	struct hist_entry	he;
710};
711
712#define NO_ADDR 0
713
714#ifdef HAVE_SLANG_SUPPORT
715#include "../ui/keysyms.h"
716void attr_to_script(char *buf, struct perf_event_attr *attr);
717
718int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *ms,
719			       struct evsel *evsel,
720			       struct hist_browser_timer *hbt, u64 al_addr);
721
722int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel,
723			     struct hist_browser_timer *hbt, u64 al_addr);
724
725int evlist__tui_browse_hists(struct evlist *evlist, const char *help, struct hist_browser_timer *hbt,
726			     float min_pcnt, struct perf_env *env, bool warn_lost_event);
727
728int script_browse(const char *script_opt, struct evsel *evsel);
729
730void run_script(char *cmd);
731int res_sample_browse(struct res_sample *res_samples, int num_res,
732		      struct evsel *evsel, enum rstype rstype);
733void res_sample_init(void);
734
735int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
736			   float min_percent, struct perf_env *env);
737#else
738static inline
739int evlist__tui_browse_hists(struct evlist *evlist __maybe_unused,
740			     const char *help __maybe_unused,
741			     struct hist_browser_timer *hbt __maybe_unused,
742			     float min_pcnt __maybe_unused,
743			     struct perf_env *env __maybe_unused,
744			     bool warn_lost_event __maybe_unused)
745{
746	return 0;
747}
748static inline int __hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
749					     struct map_symbol *ms __maybe_unused,
750					     struct evsel *evsel __maybe_unused,
751					     struct hist_browser_timer *hbt __maybe_unused,
752					     u64 al_addr __maybe_unused)
753{
754	return 0;
755}
756
757static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
758					   struct evsel *evsel __maybe_unused,
759					   struct hist_browser_timer *hbt __maybe_unused,
760					   u64 al_addr __maybe_unused)
761{
762	return 0;
763}
764
765static inline int script_browse(const char *script_opt __maybe_unused,
766				struct evsel *evsel __maybe_unused)
767{
768	return 0;
769}
770
771static inline int res_sample_browse(struct res_sample *res_samples __maybe_unused,
772				    int num_res __maybe_unused,
773				    struct evsel *evsel __maybe_unused,
774				    enum rstype rstype __maybe_unused)
775{
776	return 0;
777}
778
779static inline void res_sample_init(void) {}
780
781static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused,
782					 struct evsel *evsel __maybe_unused,
783					 float min_percent __maybe_unused,
784					 struct perf_env *env __maybe_unused)
785{
786	return 0;
787}
788
789#define K_LEFT  -1000
790#define K_RIGHT -2000
791#define K_SWITCH_INPUT_DATA -3000
792#define K_RELOAD -4000
793#endif
794
795unsigned int hists__sort_list_width(struct hists *hists);
796unsigned int hists__overhead_width(struct hists *hists);
797
798void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
799			  struct perf_sample *sample, bool nonany_branch_mode,
800			  u64 *total_cycles, struct evsel *evsel);
801
802struct option;
803int parse_filter_percentage(const struct option *opt, const char *arg, int unset);
804int perf_hist_config(const char *var, const char *value);
805
806void perf_hpp_list__init(struct perf_hpp_list *list);
807
808enum hierarchy_move_dir {
809	HMD_NORMAL,
810	HMD_FORCE_SIBLING,
811	HMD_FORCE_CHILD,
812};
813
814struct rb_node *rb_hierarchy_last(struct rb_node *node);
815struct rb_node *__rb_hierarchy_next(struct rb_node *node,
816				    enum hierarchy_move_dir hmd);
817struct rb_node *rb_hierarchy_prev(struct rb_node *node);
818
819static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)
820{
821	return __rb_hierarchy_next(node, HMD_NORMAL);
822}
823
824#define HIERARCHY_INDENT  3
825
826bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit);
827int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...);
828int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...);
829int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
830			   struct perf_hpp_list *hpp_list);
831int hists__fprintf_headers(struct hists *hists, FILE *fp);
832int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq);
833
834static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t size)
835{
836	return __hists__scnprintf_title(hists, bf, size, true);
837}
838
839#endif	/* __PERF_HIST_H */
~/ Read-only file preview.