profile.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef _LINUX_PROFILE_H
  2. #define _LINUX_PROFILE_H
  3. #ifdef __KERNEL__
  4. #include <linux/kernel.h>
  5. #include <linux/config.h>
  6. #include <linux/init.h>
  7. #include <linux/cpumask.h>
  8. #include <asm/errno.h>
  9. #define CPU_PROFILING 1
  10. #define SCHED_PROFILING 2
  11. struct proc_dir_entry;
  12. struct pt_regs;
  13. /* init basic kernel profiler */
  14. void __init profile_init(void);
  15. void profile_tick(int, struct pt_regs *);
  16. void profile_hit(int, void *);
  17. #ifdef CONFIG_PROC_FS
  18. void create_prof_cpu_mask(struct proc_dir_entry *);
  19. #else
  20. #define create_prof_cpu_mask(x) do { (void)(x); } while (0)
  21. #endif
  22. enum profile_type {
  23. PROFILE_TASK_EXIT,
  24. PROFILE_MUNMAP
  25. };
  26. #ifdef CONFIG_PROFILING
  27. struct notifier_block;
  28. struct task_struct;
  29. struct mm_struct;
  30. /* task is in do_exit() */
  31. void profile_task_exit(struct task_struct * task);
  32. /* task is dead, free task struct ? Returns 1 if
  33. * the task was taken, 0 if the task should be freed.
  34. */
  35. int profile_handoff_task(struct task_struct * task);
  36. /* sys_munmap */
  37. void profile_munmap(unsigned long addr);
  38. int task_handoff_register(struct notifier_block * n);
  39. int task_handoff_unregister(struct notifier_block * n);
  40. int profile_event_register(enum profile_type, struct notifier_block * n);
  41. int profile_event_unregister(enum profile_type, struct notifier_block * n);
  42. int register_timer_hook(int (*hook)(struct pt_regs *));
  43. void unregister_timer_hook(int (*hook)(struct pt_regs *));
  44. /* Timer based profiling hook */
  45. extern int (*timer_hook)(struct pt_regs *);
  46. struct pt_regs;
  47. #else
  48. static inline int task_handoff_register(struct notifier_block * n)
  49. {
  50. return -ENOSYS;
  51. }
  52. static inline int task_handoff_unregister(struct notifier_block * n)
  53. {
  54. return -ENOSYS;
  55. }
  56. static inline int profile_event_register(enum profile_type t, struct notifier_block * n)
  57. {
  58. return -ENOSYS;
  59. }
  60. static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n)
  61. {
  62. return -ENOSYS;
  63. }
  64. #define profile_task_exit(a) do { } while (0)
  65. #define profile_handoff_task(a) (0)
  66. #define profile_munmap(a) do { } while (0)
  67. static inline int register_timer_hook(int (*hook)(struct pt_regs *))
  68. {
  69. return -ENOSYS;
  70. }
  71. static inline void unregister_timer_hook(int (*hook)(struct pt_regs *))
  72. {
  73. return;
  74. }
  75. #endif /* CONFIG_PROFILING */
  76. #endif /* __KERNEL__ */
  77. #endif /* _LINUX_PROFILE_H */