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