1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_PROFILE_H
3 #define _LINUX_PROFILE_H
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/cpumask.h>
8 #include <linux/cache.h>
10 #include <asm/errno.h>
12 #define CPU_PROFILING 1
13 #define SCHED_PROFILING 2
14 #define SLEEP_PROFILING 3
15 #define KVM_PROFILING 4
17 struct proc_dir_entry
;
19 struct notifier_block
;
21 #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
22 void create_prof_cpu_mask(void);
23 int create_proc_profile(void);
25 static inline void create_prof_cpu_mask(void)
29 static inline int create_proc_profile(void)
40 #ifdef CONFIG_PROFILING
42 extern int prof_on __read_mostly
;
44 /* init basic kernel profiler */
45 int profile_init(void);
46 int profile_setup(char *str
);
47 void profile_tick(int type
);
48 int setup_profiling_timer(unsigned int multiplier
);
51 * Add multiple profiler hits to a given address:
53 void profile_hits(int type
, void *ip
, unsigned int nr_hits
);
56 * Single profiler hit:
58 static inline void profile_hit(int type
, void *ip
)
61 * Speedup for the common (no profiling enabled) case:
63 if (unlikely(prof_on
== type
))
64 profile_hits(type
, ip
, 1);
70 /* task is in do_exit() */
71 void profile_task_exit(struct task_struct
* task
);
73 /* task is dead, free task struct ? Returns 1 if
74 * the task was taken, 0 if the task should be freed.
76 int profile_handoff_task(struct task_struct
* task
);
79 void profile_munmap(unsigned long addr
);
81 int task_handoff_register(struct notifier_block
* n
);
82 int task_handoff_unregister(struct notifier_block
* n
);
84 int profile_event_register(enum profile_type
, struct notifier_block
* n
);
85 int profile_event_unregister(enum profile_type
, struct notifier_block
* n
);
93 static inline int profile_init(void)
98 static inline void profile_tick(int type
)
103 static inline void profile_hits(int type
, void *ip
, unsigned int nr_hits
)
108 static inline void profile_hit(int type
, void *ip
)
113 static inline int task_handoff_register(struct notifier_block
* n
)
118 static inline int task_handoff_unregister(struct notifier_block
* n
)
123 static inline int profile_event_register(enum profile_type t
, struct notifier_block
* n
)
128 static inline int profile_event_unregister(enum profile_type t
, struct notifier_block
* n
)
133 #define profile_task_exit(a) do { } while (0)
134 #define profile_handoff_task(a) (0)
135 #define profile_munmap(a) do { } while (0)
137 #endif /* CONFIG_PROFILING */
139 #endif /* _LINUX_PROFILE_H */