~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/callchain.h

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __PERF_CALLCHAIN_H
  2 #define __PERF_CALLCHAIN_H
  3 
  4 #include "../perf.h"
  5 #include <linux/list.h>
  6 #include <linux/rbtree.h>
  7 #include "event.h"
  8 #include "symbol.h"
  9 
 10 enum chain_mode {
 11         CHAIN_NONE,
 12         CHAIN_FLAT,
 13         CHAIN_GRAPH_ABS,
 14         CHAIN_GRAPH_REL
 15 };
 16 
 17 enum chain_order {
 18         ORDER_CALLER,
 19         ORDER_CALLEE
 20 };
 21 
 22 struct callchain_node {
 23         struct callchain_node   *parent;
 24         struct list_head        siblings;
 25         struct list_head        children;
 26         struct list_head        val;
 27         struct rb_node          rb_node; /* to sort nodes in an rbtree */
 28         struct rb_root          rb_root; /* sorted tree of children */
 29         unsigned int            val_nr;
 30         u64                     hit;
 31         u64                     children_hit;
 32 };
 33 
 34 struct callchain_root {
 35         u64                     max_depth;
 36         struct callchain_node   node;
 37 };
 38 
 39 struct callchain_param;
 40 
 41 typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *,
 42                                  u64, struct callchain_param *);
 43 
 44 struct callchain_param {
 45         enum chain_mode         mode;
 46         u32                     print_limit;
 47         double                  min_percent;
 48         sort_chain_func_t       sort;
 49         enum chain_order        order;
 50 };
 51 
 52 struct callchain_list {
 53         u64                     ip;
 54         struct map_symbol       ms;
 55         struct list_head        list;
 56 };
 57 
 58 /*
 59  * A callchain cursor is a single linked list that
 60  * let one feed a callchain progressively.
 61  * It keeps persitent allocated entries to minimize
 62  * allocations.
 63  */
 64 struct callchain_cursor_node {
 65         u64                             ip;
 66         struct map                      *map;
 67         struct symbol                   *sym;
 68         struct callchain_cursor_node    *next;
 69 };
 70 
 71 struct callchain_cursor {
 72         u64                             nr;
 73         struct callchain_cursor_node    *first;
 74         struct callchain_cursor_node    **last;
 75         u64                             pos;
 76         struct callchain_cursor_node    *curr;
 77 };
 78 
 79 extern __thread struct callchain_cursor callchain_cursor;
 80 
 81 static inline void callchain_init(struct callchain_root *root)
 82 {
 83         INIT_LIST_HEAD(&root->node.siblings);
 84         INIT_LIST_HEAD(&root->node.children);
 85         INIT_LIST_HEAD(&root->node.val);
 86 
 87         root->node.parent = NULL;
 88         root->node.hit = 0;
 89         root->node.children_hit = 0;
 90         root->max_depth = 0;
 91 }
 92 
 93 static inline u64 callchain_cumul_hits(struct callchain_node *node)
 94 {
 95         return node->hit + node->children_hit;
 96 }
 97 
 98 int callchain_register_param(struct callchain_param *param);
 99 int callchain_append(struct callchain_root *root,
100                      struct callchain_cursor *cursor,
101                      u64 period);
102 
103 int callchain_merge(struct callchain_cursor *cursor,
104                     struct callchain_root *dst, struct callchain_root *src);
105 
106 struct ip_callchain;
107 union perf_event;
108 
109 bool ip_callchain__valid(struct ip_callchain *chain,
110                          const union perf_event *event);
111 /*
112  * Initialize a cursor before adding entries inside, but keep
113  * the previously allocated entries as a cache.
114  */
115 static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
116 {
117         cursor->nr = 0;
118         cursor->last = &cursor->first;
119 }
120 
121 int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
122                             struct map *map, struct symbol *sym);
123 
124 /* Close a cursor writing session. Initialize for the reader */
125 static inline void callchain_cursor_commit(struct callchain_cursor *cursor)
126 {
127         cursor->curr = cursor->first;
128         cursor->pos = 0;
129 }
130 
131 /* Cursor reading iteration helpers */
132 static inline struct callchain_cursor_node *
133 callchain_cursor_current(struct callchain_cursor *cursor)
134 {
135         if (cursor->pos == cursor->nr)
136                 return NULL;
137 
138         return cursor->curr;
139 }
140 
141 static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
142 {
143         cursor->curr = cursor->curr->next;
144         cursor->pos++;
145 }
146 #endif  /* __PERF_CALLCHAIN_H */
147 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp