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 void create_prof_cpu_mask(void); 22 int create_proc_profile(void); 23 #else 24 static inline void create_prof_cpu_mask(void) 25 { 26 } 27 28 static inline int create_proc_profile(void) 29 { 30 return 0; 31 } 32 #endif 33 34 #ifdef CONFIG_PROFILING 35 36 extern int prof_on __read_mostly; 37 38 /* init basic kernel profiler */ 39 int profile_init(void); 40 int profile_setup(char *str); 41 void profile_tick(int type); 42 int setup_profiling_timer(unsigned int multiplier); 43 44 /* 45 * Add multiple profiler hits to a given address: 46 */ 47 void profile_hits(int type, void *ip, unsigned int nr_hits); 48 49 /* 50 * Single profiler hit: 51 */ 52 static inline void profile_hit(int type, void *ip) 53 { 54 /* 55 * Speedup for the common (no profiling enabled) case: 56 */ 57 if (unlikely(prof_on == type)) 58 profile_hits(type, ip, 1); 59 } 60 61 struct task_struct; 62 struct mm_struct; 63 64 /* task is dead, free task struct ? Returns 1 if 65 * the task was taken, 0 if the task should be freed. 66 */ 67 int profile_handoff_task(struct task_struct * task); 68 69 int task_handoff_register(struct notifier_block * n); 70 int task_handoff_unregister(struct notifier_block * n); 71 72 #else 73 74 #define prof_on 0 75 76 static inline int profile_init(void) 77 { 78 return 0; 79 } 80 81 static inline void profile_tick(int type) 82 { 83 return; 84 } 85 86 static inline void profile_hits(int type, void *ip, unsigned int nr_hits) 87 { 88 return; 89 } 90 91 static inline void profile_hit(int type, void *ip) 92 { 93 return; 94 } 95 96 static inline int task_handoff_register(struct notifier_block * n) 97 { 98 return -ENOSYS; 99 } 100 101 static inline int task_handoff_unregister(struct notifier_block * n) 102 { 103 return -ENOSYS; 104 } 105 106 #define profile_handoff_task(a) (0) 107 108 #endif /* CONFIG_PROFILING */ 109 110 #endif /* _LINUX_PROFILE_H */ 111