callchain.h 1.3 KB

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