callchain.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __PERF_CALLCHAIN_H
  2. #define __PERF_CALLCHAIN_H
  3. #include "../perf.h"
  4. #include <linux/list.h>
  5. #include <linux/rbtree.h>
  6. #include "event.h"
  7. #include "util.h"
  8. #include "symbol.h"
  9. enum chain_mode {
  10. CHAIN_NONE,
  11. CHAIN_FLAT,
  12. CHAIN_GRAPH_ABS,
  13. CHAIN_GRAPH_REL
  14. };
  15. struct callchain_node {
  16. struct callchain_node *parent;
  17. struct list_head brothers;
  18. struct list_head children;
  19. struct list_head val;
  20. struct rb_node rb_node; /* to sort nodes in an rbtree */
  21. struct rb_root rb_root; /* sorted tree of children */
  22. unsigned int val_nr;
  23. u64 hit;
  24. u64 children_hit;
  25. };
  26. struct callchain_param;
  27. typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
  28. u64, struct callchain_param *);
  29. struct callchain_param {
  30. enum chain_mode mode;
  31. u32 print_limit;
  32. double min_percent;
  33. sort_chain_func_t sort;
  34. };
  35. struct callchain_list {
  36. u64 ip;
  37. struct map_symbol ms;
  38. struct list_head list;
  39. };
  40. static inline void callchain_init(struct callchain_node *node)
  41. {
  42. INIT_LIST_HEAD(&node->brothers);
  43. INIT_LIST_HEAD(&node->children);
  44. INIT_LIST_HEAD(&node->val);
  45. }
  46. static inline u64 cumul_hits(struct callchain_node *node)
  47. {
  48. return node->hit + node->children_hit;
  49. }
  50. int register_callchain_param(struct callchain_param *param);
  51. int append_chain(struct callchain_node *root, struct ip_callchain *chain,
  52. struct map_symbol *syms);
  53. bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
  54. #endif /* __PERF_CALLCHAIN_H */