[RFC PATCH 2/6] kprobes: remove global kprobe_lock - i386 changes
Ananth N Mavinakayanahalli
ananth@in.ibm.com
Fri Jul 29 18:54:00 GMT 2005
i386 specific locking changes.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
arch/i386/kernel/kprobes.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
Index: linux-2.6.13-rc3/arch/i386/kernel/kprobes.c
===================================================================
--- linux-2.6.13-rc3.orig/arch/i386/kernel/kprobes.c 2005-07-29 12:55:57.000000000 -0400
+++ linux-2.6.13-rc3/arch/i386/kernel/kprobes.c 2005-07-29 12:57:31.000000000 -0400
@@ -31,7 +31,6 @@
#include <linux/config.h>
#include <linux/kprobes.h>
#include <linux/ptrace.h>
-#include <linux/spinlock.h>
#include <linux/preempt.h>
#include <asm/cacheflush.h>
#include <asm/kdebug.h>
@@ -139,6 +138,7 @@ static inline void prepare_singlestep(st
regs->eip = (unsigned long)&p->ainsn.insn;
}
+/* Called with kretprobe_lock held */
void __kprobes arch_prepare_kretprobe(struct kretprobe *rp,
struct pt_regs *regs)
{
@@ -191,7 +191,7 @@ static int __kprobes kprobe_handler(stru
if (kcb->kprobe_status == KPROBE_HIT_SS) {
regs->eflags &= ~TF_MASK;
regs->eflags |= kcb->kprobe_saved_eflags;
- unlock_kprobes();
+ read_unlock(&kprobe_lock);
goto no_kprobe;
}
/* We have reentered the kprobe_handler(), since
@@ -216,10 +216,10 @@ static int __kprobes kprobe_handler(stru
goto no_kprobe;
}
- lock_kprobes();
+ read_lock(&kprobe_lock);
p = get_kprobe(addr);
if (!p) {
- unlock_kprobes();
+ read_unlock(&kprobe_lock);
if (regs->eflags & VM_MASK) {
/* We are in virtual-8086 mode. Return 0 */
goto no_kprobe;
@@ -284,6 +284,7 @@ int __kprobes trampoline_probe_handler(s
unsigned long orig_ret_address = 0;
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
+ spin_lock(&kretprobe_lock);
head = kretprobe_inst_table_head(current);
/*
@@ -322,7 +323,8 @@ int __kprobes trampoline_probe_handler(s
BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
regs->eip = orig_ret_address;
- unlock_kprobes();
+ spin_unlock(&kretprobe_lock);
+ read_unlock(&kprobe_lock);
/*
* By returning a non-zero value, we are telling
@@ -430,7 +432,7 @@ static inline int post_kprobe_handler(st
goto out;
}
reset_current_kprobe();
- unlock_kprobes();
+ read_unlock(&kprobe_lock);
out:
preempt_enable_no_resched();
@@ -459,7 +461,7 @@ static inline int kprobe_fault_handler(s
regs->eflags |= kcb->kprobe_old_eflags;
reset_current_kprobe();
- unlock_kprobes();
+ read_unlock(&kprobe_lock);
preempt_enable_no_resched();
}
return 0;
More information about the Systemtap
mailing list