callchain.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. FLAT,
  9. GRAPH
  10. };
  11. struct callchain_node {
  12. struct callchain_node *parent;
  13. struct list_head brothers;
  14. struct list_head children;
  15. struct list_head val;
  16. struct rb_node rb_node; /* to sort nodes in an rbtree */
  17. struct rb_root rb_root; /* sorted tree of children */
  18. unsigned int val_nr;
  19. u64 hit;
  20. u64 cumul_hit; /* hit + hits of children */
  21. };
  22. struct callchain_list {
  23. u64 ip;
  24. struct symbol *sym;
  25. struct list_head list;
  26. };
  27. static inline void callchain_init(struct callchain_node *node)
  28. {
  29. INIT_LIST_HEAD(&node->brothers);
  30. INIT_LIST_HEAD(&node->children);
  31. INIT_LIST_HEAD(&node->val);
  32. }
  33. void append_chain(struct callchain_node *root, struct ip_callchain *chain,
  34. struct symbol **syms);
  35. void sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
  36. u64 min_hit);
  37. void sort_chain_graph(struct rb_root *rb_root, struct callchain_node *node,
  38. u64 min_hit);
  39. #endif