1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_PROFILE_H 3 #define _LINUX_PROFILE_H 4 5 #include <linux/kernel.h> 6 #include <linux/init.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 notifier_block; 18 19 #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS) 20 int create_proc_profile(void); 21 #else 22 static inline int create_proc_profile(void) 23 { 24 return 0; 25 } 26 #endif 27 28 #ifdef CONFIG_PROFILING 29 30 extern int prof_on __read_mostly; 31 32 /* init basic kernel profiler */ 33 int profile_init(void); 34 int profile_setup(char *str); 35 void profile_tick(int type); 36 int setup_profiling_timer(unsigned int multiplier); 37 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 /* 44 * Single profiler hit: 45 */ 46 static inline void profile_hit(int type, void *ip) 47 { 48 /* 49 * Speedup for the common (no profiling enabled) case: 50 */ 51 if (unlikely(prof_on == type)) 52 profile_hits(type, ip, 1); 53 } 54 55 struct task_struct; 56 struct mm_struct; 57 58 #else 59 60 #define prof_on 0 61 62 static inline int profile_init(void) 63 { 64 return 0; 65 } 66 67 static inline void profile_tick(int type) 68 { 69 return; 70 } 71 72 static inline void profile_hits(int type, void *ip, unsigned int nr_hits) 73 { 74 return; 75 } 76 77 static inline void profile_hit(int type, void *ip) 78 { 79 return; 80 } 81 82 83 #endif /* CONFIG_PROFILING */ 84 85 #endif /* _LINUX_PROFILE_H */ 86