callchain.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "symbol.h"
  7. enum chain_mode {
  8. CHAIN_NONE,
  9. CHAIN_FLAT,
  10. CHAIN_GRAPH_ABS,
  11. CHAIN_GRAPH_REL
  12. };
  13. struct callchain_node {
  14. struct callchain_node *parent;
  15. struct list_head brothers;
  16. struct list_head children;
  17. struct list_head val;
  18. struct rb_node rb_node; /* to sort nodes in an rbtree */
  19. struct rb_root rb_root; /* sorted tree of children */
  20. unsigned int val_nr;
  21. u64 hit;
  22. u64 children_hit;
  23. };
  24. struct callchain_param;
  25. typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
  26. u64, struct callchain_param *);
  27. struct callchain_param {
  28. enum chain_mode mode;
  29. double min_percent;
  30. sort_chain_func_t sort;
  31. };
  32. struct callchain_list {
  33. u64 ip;
  34. struct symbol *sym;
  35. struct list_head list;
  36. };
  37. static inline void callchain_init(struct callchain_node *node)
  38. {
  39. INIT_LIST_HEAD(&node->brothers);
  40. INIT_LIST_HEAD(&node->children);
  41. INIT_LIST_HEAD(&node->val);
  42. }
  43. static inline u64 cumul_hits(struct callchain_node *node)
  44. {
  45. return node->hit + node->children_hit;
  46. }
  47. int register_callchain_param(struct callchain_param *param);
  48. void append_chain(struct callchain_node *root, struct ip_callchain *chain,
  49. struct symbol **syms);
  50. #endif