Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_PROFILE_H |
| 2 | #define _LINUX_PROFILE_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
| 6 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/init.h> |
| 8 | #include <linux/cpumask.h> |
| 9 | #include <asm/errno.h> |
| 10 | |
| 11 | #define CPU_PROFILING 1 |
| 12 | #define SCHED_PROFILING 2 |
| 13 | |
| 14 | struct proc_dir_entry; |
| 15 | struct pt_regs; |
Andrew Morton | 772a0dc | 2006-03-23 03:00:55 -0800 | [diff] [blame] | 16 | struct notifier_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | /* init basic kernel profiler */ |
| 19 | void __init profile_init(void); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 20 | void profile_tick(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | void profile_hit(int, void *); |
| 22 | #ifdef CONFIG_PROC_FS |
| 23 | void create_prof_cpu_mask(struct proc_dir_entry *); |
| 24 | #else |
| 25 | #define create_prof_cpu_mask(x) do { (void)(x); } while (0) |
| 26 | #endif |
| 27 | |
| 28 | enum profile_type { |
| 29 | PROFILE_TASK_EXIT, |
| 30 | PROFILE_MUNMAP |
| 31 | }; |
| 32 | |
| 33 | #ifdef CONFIG_PROFILING |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | struct task_struct; |
| 36 | struct mm_struct; |
| 37 | |
| 38 | /* task is in do_exit() */ |
| 39 | void profile_task_exit(struct task_struct * task); |
| 40 | |
| 41 | /* task is dead, free task struct ? Returns 1 if |
| 42 | * the task was taken, 0 if the task should be freed. |
| 43 | */ |
| 44 | int profile_handoff_task(struct task_struct * task); |
| 45 | |
| 46 | /* sys_munmap */ |
| 47 | void profile_munmap(unsigned long addr); |
| 48 | |
| 49 | int task_handoff_register(struct notifier_block * n); |
| 50 | int task_handoff_unregister(struct notifier_block * n); |
| 51 | |
| 52 | int profile_event_register(enum profile_type, struct notifier_block * n); |
| 53 | int profile_event_unregister(enum profile_type, struct notifier_block * n); |
| 54 | |
| 55 | int register_timer_hook(int (*hook)(struct pt_regs *)); |
| 56 | void unregister_timer_hook(int (*hook)(struct pt_regs *)); |
| 57 | |
| 58 | /* Timer based profiling hook */ |
| 59 | extern int (*timer_hook)(struct pt_regs *); |
| 60 | |
| 61 | struct pt_regs; |
| 62 | |
| 63 | #else |
| 64 | |
| 65 | static inline int task_handoff_register(struct notifier_block * n) |
| 66 | { |
| 67 | return -ENOSYS; |
| 68 | } |
| 69 | |
| 70 | static inline int task_handoff_unregister(struct notifier_block * n) |
| 71 | { |
| 72 | return -ENOSYS; |
| 73 | } |
| 74 | |
| 75 | static inline int profile_event_register(enum profile_type t, struct notifier_block * n) |
| 76 | { |
| 77 | return -ENOSYS; |
| 78 | } |
| 79 | |
| 80 | static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n) |
| 81 | { |
| 82 | return -ENOSYS; |
| 83 | } |
| 84 | |
| 85 | #define profile_task_exit(a) do { } while (0) |
| 86 | #define profile_handoff_task(a) (0) |
| 87 | #define profile_munmap(a) do { } while (0) |
| 88 | |
| 89 | static inline int register_timer_hook(int (*hook)(struct pt_regs *)) |
| 90 | { |
| 91 | return -ENOSYS; |
| 92 | } |
| 93 | |
| 94 | static inline void unregister_timer_hook(int (*hook)(struct pt_regs *)) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | #endif /* CONFIG_PROFILING */ |
| 100 | |
| 101 | #endif /* __KERNEL__ */ |
| 102 | |
| 103 | #endif /* _LINUX_PROFILE_H */ |