profile.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /*
  38. * Add multiple profiler hits to a given address:
  39. */
  40. void profile_hits(int type, void *ip, unsigned int nr_hits);
  41. /*
  42. * Single profiler hit:
  43. */
  44. static inline void profile_hit(int type, void *ip)
  45. {
  46. /*
  47. * Speedup for the common (no profiling enabled) case:
  48. */
  49. if (unlikely(prof_on == type))
  50. profile_hits(type, ip, 1);
  51. }
  52. struct task_struct;
  53. struct mm_struct;
  54. /* task is in do_exit() */
  55. void profile_task_exit(struct task_struct * task);
  56. /* task is dead, free task struct ? Returns 1 if
  57. * the task was taken, 0 if the task should be freed.
  58. */
  59. int profile_handoff_task(struct task_struct * task);
  60. /* sys_munmap */
  61. void profile_munmap(unsigned long addr);
  62. int task_handoff_register(struct notifier_block * n);
  63. int task_handoff_unregister(struct notifier_block * n);
  64. int profile_event_register(enum profile_type, struct notifier_block * n);
  65. int profile_event_unregister(enum profile_type, struct notifier_block * n);
  66. struct pt_regs;
  67. #else
  68. #define prof_on 0
  69. static inline int profile_init(void)
  70. {
  71. return 0;
  72. }
  73. static inline void profile_tick(int type)
  74. {
  75. return;
  76. }
  77. static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
  78. {
  79. return;
  80. }
  81. static inline void profile_hit(int type, void *ip)
  82. {
  83. return;
  84. }
  85. static inline int task_handoff_register(struct notifier_block * n)
  86. {
  87. return -ENOSYS;
  88. }
  89. static inline int task_handoff_unregister(struct notifier_block * n)
  90. {
  91. return -ENOSYS;
  92. }
  93. static inline int profile_event_register(enum profile_type t, struct notifier_block * n)
  94. {
  95. return -ENOSYS;
  96. }
  97. static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n)
  98. {
  99. return -ENOSYS;
  100. }
  101. #define profile_task_exit(a) do { } while (0)
  102. #define profile_handoff_task(a) (0)
  103. #define profile_munmap(a) do { } while (0)
  104. #endif /* CONFIG_PROFILING */
  105. #endif /* _LINUX_PROFILE_H */