callchain.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "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. u32 print_limit;
  31. double min_percent;
  32. sort_chain_func_t sort;
  33. };
  34. struct callchain_list {
  35. u64 ip;
  36. struct map_symbol ms;
  37. struct list_head list;
  38. };
  39. static inline void callchain_init(struct callchain_node *node)
  40. {
  41. INIT_LIST_HEAD(&node->brothers);
  42. INIT_LIST_HEAD(&node->children);
  43. INIT_LIST_HEAD(&node->val);
  44. }
  45. static inline u64 cumul_hits(struct callchain_node *node)
  46. {
  47. return node->hit + node->children_hit;
  48. }
  49. int register_callchain_param(struct callchain_param *param);
  50. int append_chain(struct callchain_node *root, struct ip_callchain *chain,
  51. struct map_symbol *syms);
  52. bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
  53. #endif /* __PERF_CALLCHAIN_H */