callchain.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. node->children_hit = 0;
  45. node->parent = NULL;
  46. node->hit = 0;
  47. }
  48. static inline u64 cumul_hits(struct callchain_node *node)
  49. {
  50. return node->hit + node->children_hit;
  51. }
  52. int register_callchain_param(struct callchain_param *param);
  53. int append_chain(struct callchain_node *root, struct ip_callchain *chain,
  54. struct map_symbol *syms, u64 period);
  55. bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event);
  56. #endif /* __PERF_CALLCHAIN_H */