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/cpumask.h> 8 #include <linux/cache.h> 9 10 #include <asm/errno.h> 11 12 #define CPU_PROFILING 1 13 #define SCHED_PROFILING 2 14 #define SLEEP_PROFILING 3 15 #define KVM_PROFILING 4 16 17 struct proc_dir_entry; 18 struct notifier_block; 19 20 #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS) 21 int create_proc_profile(void); 22 #else 23 static inline int create_proc_profile(void) 24 { 25 return 0; 26 } 27 #endif 28 29 #ifdef CONFIG_PROFILING 30 31 extern int prof_on __read_mostly; 32 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 /* 40 * Add multiple profiler hits to a given address: 41 */ 42 void profile_hits(int type, void *ip, unsigned int nr_hits); 43 44 /* 45 * Single profiler hit: 46 */ 47 static inline void profile_hit(int type, void *ip) 48 { 49 /* 50 * Speedup for the common (no profiling enabled) case: 51 */ 52 if (unlikely(prof_on == type)) 53 profile_hits(type, ip, 1); 54 } 55 56 struct task_struct; 57 struct mm_struct; 58 59 #else 60 61 #define prof_on 0 62 63 static inline int profile_init(void) 64 { 65 return 0; 66 } 67 68 static inline void profile_tick(int type) 69 { 70 return; 71 } 72 73 static inline void profile_hits(int type, void *ip, unsigned int nr_hits) 74 { 75 return; 76 } 77 78 static inline void profile_hit(int type, void *ip) 79 { 80 return; 81 } 82 83 84 #endif /* CONFIG_PROFILING */ 85 86 #endif /* _LINUX_PROFILE_H */ 87