]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_PROFILE_H |
3 | #define _LINUX_PROFILE_H | |
4 | ||
1da177e4 | 5 | #include <linux/kernel.h> |
1da177e4 LT |
6 | #include <linux/init.h> |
7 | #include <linux/cpumask.h> | |
ece8a684 IM |
8 | #include <linux/cache.h> |
9 | ||
1da177e4 LT |
10 | #include <asm/errno.h> |
11 | ||
12 | #define CPU_PROFILING 1 | |
13 | #define SCHED_PROFILING 2 | |
ece8a684 | 14 | #define SLEEP_PROFILING 3 |
07031e14 | 15 | #define KVM_PROFILING 4 |
1da177e4 LT |
16 | |
17 | struct proc_dir_entry; | |
18 | struct pt_regs; | |
772a0dc5 | 19 | struct notifier_block; |
1da177e4 | 20 | |
b03f6489 | 21 | #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS) |
fbd387ae | 22 | void create_prof_cpu_mask(void); |
66f50ee3 | 23 | int create_proc_profile(void); |
b03f6489 | 24 | #else |
fbd387ae | 25 | static inline void create_prof_cpu_mask(void) |
cebbd3fb AM |
26 | { |
27 | } | |
66f50ee3 PM |
28 | |
29 | static inline int create_proc_profile(void) | |
30 | { | |
31 | return 0; | |
32 | } | |
b03f6489 AB |
33 | #endif |
34 | ||
35 | enum profile_type { | |
36 | PROFILE_TASK_EXIT, | |
37 | PROFILE_MUNMAP | |
38 | }; | |
39 | ||
40 | #ifdef CONFIG_PROFILING | |
41 | ||
42 | extern int prof_on __read_mostly; | |
43 | ||
1da177e4 | 44 | /* init basic kernel profiler */ |
22b8ce94 DH |
45 | int profile_init(void); |
46 | int profile_setup(char *str); | |
b03f6489 | 47 | void profile_tick(int type); |
d3091298 | 48 | int setup_profiling_timer(unsigned int multiplier); |
ece8a684 IM |
49 | |
50 | /* | |
51 | * Add multiple profiler hits to a given address: | |
52 | */ | |
b03f6489 | 53 | void profile_hits(int type, void *ip, unsigned int nr_hits); |
ece8a684 IM |
54 | |
55 | /* | |
56 | * Single profiler hit: | |
57 | */ | |
58 | static inline void profile_hit(int type, void *ip) | |
59 | { | |
60 | /* | |
61 | * Speedup for the common (no profiling enabled) case: | |
62 | */ | |
63 | if (unlikely(prof_on == type)) | |
64 | profile_hits(type, ip, 1); | |
65 | } | |
66 | ||
1da177e4 LT |
67 | struct task_struct; |
68 | struct mm_struct; | |
69 | ||
70 | /* task is in do_exit() */ | |
71 | void profile_task_exit(struct task_struct * task); | |
72 | ||
73 | /* task is dead, free task struct ? Returns 1 if | |
74 | * the task was taken, 0 if the task should be freed. | |
75 | */ | |
76 | int profile_handoff_task(struct task_struct * task); | |
77 | ||
78 | /* sys_munmap */ | |
79 | void profile_munmap(unsigned long addr); | |
80 | ||
81 | int task_handoff_register(struct notifier_block * n); | |
82 | int task_handoff_unregister(struct notifier_block * n); | |
83 | ||
84 | int profile_event_register(enum profile_type, struct notifier_block * n); | |
85 | int profile_event_unregister(enum profile_type, struct notifier_block * n); | |
86 | ||
1da177e4 LT |
87 | struct pt_regs; |
88 | ||
89 | #else | |
90 | ||
b03f6489 AB |
91 | #define prof_on 0 |
92 | ||
22b8ce94 | 93 | static inline int profile_init(void) |
b03f6489 | 94 | { |
22b8ce94 | 95 | return 0; |
b03f6489 AB |
96 | } |
97 | ||
98 | static inline void profile_tick(int type) | |
99 | { | |
100 | return; | |
101 | } | |
102 | ||
103 | static inline void profile_hits(int type, void *ip, unsigned int nr_hits) | |
104 | { | |
105 | return; | |
106 | } | |
107 | ||
108 | static inline void profile_hit(int type, void *ip) | |
109 | { | |
110 | return; | |
111 | } | |
112 | ||
1da177e4 LT |
113 | static inline int task_handoff_register(struct notifier_block * n) |
114 | { | |
115 | return -ENOSYS; | |
116 | } | |
117 | ||
118 | static inline int task_handoff_unregister(struct notifier_block * n) | |
119 | { | |
120 | return -ENOSYS; | |
121 | } | |
122 | ||
123 | static inline int profile_event_register(enum profile_type t, struct notifier_block * n) | |
124 | { | |
125 | return -ENOSYS; | |
126 | } | |
127 | ||
128 | static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n) | |
129 | { | |
130 | return -ENOSYS; | |
131 | } | |
132 | ||
133 | #define profile_task_exit(a) do { } while (0) | |
134 | #define profile_handoff_task(a) (0) | |
135 | #define profile_munmap(a) do { } while (0) | |
136 | ||
1da177e4 LT |
137 | #endif /* CONFIG_PROFILING */ |
138 | ||
1da177e4 | 139 | #endif /* _LINUX_PROFILE_H */ |