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