diff options
author | Ananth N Mavinakayanahalli <ananth@in.ibm.com> | 2005-11-07 04:00:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:45 -0500 |
commit | e65845235c8120be63001fc1a4ac00c819194bbe (patch) | |
tree | 209a081cc07375290743ceb45f52dc474f45382a /include/linux/kprobes.h | |
parent | 66ff2d0691e00e1e7bfdf398a970310c9a0fe671 (diff) |
[PATCH] Kprobes: Track kprobe on a per_cpu basis - base changes
Changes to the base kprobe infrastructure to track kprobe execution on a
per-cpu basis.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/kprobes.h')
-rw-r--r-- | include/linux/kprobes.h | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index e30afdca7917..6720305a31e8 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <linux/notifier.h> | 34 | #include <linux/notifier.h> |
35 | #include <linux/smp.h> | 35 | #include <linux/smp.h> |
36 | #include <linux/percpu.h> | ||
36 | 37 | ||
37 | #include <asm/kprobes.h> | 38 | #include <asm/kprobes.h> |
38 | 39 | ||
@@ -106,6 +107,9 @@ struct jprobe { | |||
106 | kprobe_opcode_t *entry; /* probe handling code to jump to */ | 107 | kprobe_opcode_t *entry; /* probe handling code to jump to */ |
107 | }; | 108 | }; |
108 | 109 | ||
110 | DECLARE_PER_CPU(struct kprobe *, current_kprobe); | ||
111 | DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); | ||
112 | |||
109 | #ifdef ARCH_SUPPORTS_KRETPROBES | 113 | #ifdef ARCH_SUPPORTS_KRETPROBES |
110 | extern void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs); | 114 | extern void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs); |
111 | #else /* ARCH_SUPPORTS_KRETPROBES */ | 115 | #else /* ARCH_SUPPORTS_KRETPROBES */ |
@@ -146,13 +150,6 @@ struct kretprobe_instance { | |||
146 | void lock_kprobes(void); | 150 | void lock_kprobes(void); |
147 | void unlock_kprobes(void); | 151 | void unlock_kprobes(void); |
148 | 152 | ||
149 | /* kprobe running now on this CPU? */ | ||
150 | static inline int kprobe_running(void) | ||
151 | { | ||
152 | extern unsigned int kprobe_cpu; | ||
153 | return kprobe_cpu == smp_processor_id(); | ||
154 | } | ||
155 | |||
156 | extern int arch_prepare_kprobe(struct kprobe *p); | 153 | extern int arch_prepare_kprobe(struct kprobe *p); |
157 | extern void arch_copy_kprobe(struct kprobe *p); | 154 | extern void arch_copy_kprobe(struct kprobe *p); |
158 | extern void arch_arm_kprobe(struct kprobe *p); | 155 | extern void arch_arm_kprobe(struct kprobe *p); |
@@ -167,6 +164,22 @@ extern void free_insn_slot(kprobe_opcode_t *slot); | |||
167 | struct kprobe *get_kprobe(void *addr); | 164 | struct kprobe *get_kprobe(void *addr); |
168 | struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk); | 165 | struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk); |
169 | 166 | ||
167 | /* kprobe_running() will just return the current_kprobe on this CPU */ | ||
168 | static inline struct kprobe *kprobe_running(void) | ||
169 | { | ||
170 | return (__get_cpu_var(current_kprobe)); | ||
171 | } | ||
172 | |||
173 | static inline void reset_current_kprobe(void) | ||
174 | { | ||
175 | __get_cpu_var(current_kprobe) = NULL; | ||
176 | } | ||
177 | |||
178 | static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void) | ||
179 | { | ||
180 | return (&__get_cpu_var(kprobe_ctlblk)); | ||
181 | } | ||
182 | |||
170 | int register_kprobe(struct kprobe *p); | 183 | int register_kprobe(struct kprobe *p); |
171 | void unregister_kprobe(struct kprobe *p); | 184 | void unregister_kprobe(struct kprobe *p); |
172 | int setjmp_pre_handler(struct kprobe *, struct pt_regs *); | 185 | int setjmp_pre_handler(struct kprobe *, struct pt_regs *); |
@@ -183,9 +196,9 @@ void add_rp_inst(struct kretprobe_instance *ri); | |||
183 | void kprobe_flush_task(struct task_struct *tk); | 196 | void kprobe_flush_task(struct task_struct *tk); |
184 | void recycle_rp_inst(struct kretprobe_instance *ri); | 197 | void recycle_rp_inst(struct kretprobe_instance *ri); |
185 | #else /* CONFIG_KPROBES */ | 198 | #else /* CONFIG_KPROBES */ |
186 | static inline int kprobe_running(void) | 199 | static inline struct kprobe *kprobe_running(void) |
187 | { | 200 | { |
188 | return 0; | 201 | return NULL; |
189 | } | 202 | } |
190 | static inline int register_kprobe(struct kprobe *p) | 203 | static inline int register_kprobe(struct kprobe *p) |
191 | { | 204 | { |