callchain.h 1.2 KB

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