profile.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef _LINUX_PROFILE_H
  2. #define _LINUX_PROFILE_H
  3. #include <linux/kernel.h>
  4. #include <linux/init.h>
  5. #include <linux/cpumask.h>
  6. #include <linux/cache.h>
  7. #include <asm/errno.h>
  8. #define CPU_PROFILING 1
  9. #define SCHED_PROFILING 2
  10. #define SLEEP_PROFILING 3
  11. #define KVM_PROFILING 4
  12. struct proc_dir_entry;
  13. struct pt_regs;
  14. struct notifier_block;
  15. #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
  16. void create_prof_cpu_mask(void);
  17. int create_proc_profile(void);
  18. #else
  19. static inline void create_prof_cpu_mask(void)
  20. {
  21. }
  22. static inline int create_proc_profile(void)
  23. {
  24. return 0;
  25. }
  26. #endif
  27. enum profile_type {
  28. PROFILE_TASK_EXIT,
  29. PROFILE_MUNMAP
  30. };
  31. #ifdef CONFIG_PROFILING
  32. extern int prof_on __read_mostly;
  33. /* init basic kernel profiler */
  34. int profile_init(void);
  35. int profile_setup(char *str);
  36. void profile_tick(int type);
  37. int setup_profiling_timer(unsigned int multiplier);
  38. /*
  39. * Add multiple profiler hits to a given address:
  40. */
  41. void profile_hits(int type, void *ip, unsigned int nr_hits);
  42. /*
  43. * Single profiler hit:
  44. */
  45. static inline void profile_hit(int type, void *ip)
  46. {
  47. /*
  48. * Speedup for the common (no profiling enabled) case:
  49. */
  50. if (unlikely(prof_on == type))
  51. profile_hits(type, ip, 1);
  52. }
  53. struct task_struct;
  54. struct mm_struct;
  55. /* task is in do_exit() */
  56. void profile_task_exit(struct task_struct * task);
  57. /* task is dead, free task struct ? Returns 1 if
  58. * the task was taken, 0 if the task should be freed.
  59. */
  60. int profile_handoff_task(struct task_struct * task);
  61. /* sys_munmap */
  62. void profile_munmap(unsigned long addr);
  63. int task_handoff_register(struct notifier_block * n);
  64. int task_handoff_unregister(struct notifier_block * n);
  65. int profile_event_register(enum profile_type, struct notifier_block * n);
  66. int profile_event_unregister(enum profile_type, struct notifier_block * n);
  67. struct pt_regs;
  68. #else
  69. #define prof_on 0
  70. static inline int profile_init(void)
  71. {
  72. return 0;
  73. }
  74. static inline void profile_tick(int type)
  75. {
  76. return;
  77. }
  78. static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
  79. {
  80. return;
  81. }
  82. static inline void profile_hit(int type, void *ip)
  83. {
  84. return;
  85. }
  86. static inline int task_handoff_register(struct notifier_block * n)
  87. {
  88. return -ENOSYS;
  89. }
  90. static inline int task_handoff_unregister(struct notifier_block * n)
  91. {
  92. return -ENOSYS;
  93. }
  94. static inline int profile_event_register(enum profile_type t, struct notifier_block * n)
  95. {
  96. return -ENOSYS;
  97. }
  98. static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n)
  99. {
  100. return -ENOSYS;
  101. }
  102. #define profile_task_exit(a) do { } while (0)
  103. #define profile_handoff_task(a) (0)
  104. #define profile_munmap(a) do { } while (0)
  105. #endif /* CONFIG_PROFILING */
  106. #endif /* _LINUX_PROFILE_H */