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
create_prof_cpu_mask(void)24 static inline void create_prof_cpu_mask(void)
25 {
26 }
27 
create_proc_profile(void)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  */
profile_hit(int type,void * ip)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 #else
65 
66 #define prof_on 0
67 
profile_init(void)68 static inline int profile_init(void)
69 {
70 	return 0;
71 }
72 
profile_tick(int type)73 static inline void profile_tick(int type)
74 {
75 	return;
76 }
77 
profile_hits(int type,void * ip,unsigned int nr_hits)78 static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
79 {
80 	return;
81 }
82 
profile_hit(int type,void * ip)83 static inline void profile_hit(int type, void *ip)
84 {
85 	return;
86 }
87 
88 
89 #endif /* CONFIG_PROFILING */
90 
91 #endif /* _LINUX_PROFILE_H */
92