This is the mail archive of the systemtap@sources.redhat.com mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC PATCH 6/6] kprobes: remove global kprobe_lock - x86_64 changes


Changes for x86_64 kprobes. Compile tested only.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>

 arch/x86_64/kernel/kprobes.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

Index: linux-2.6.13-rc3/arch/x86_64/kernel/kprobes.c
===================================================================
--- linux-2.6.13-rc3.orig/arch/x86_64/kernel/kprobes.c	2005-07-28 16:31:55.000000000 -0400
+++ linux-2.6.13-rc3/arch/x86_64/kernel/kprobes.c	2005-07-28 16:32:12.000000000 -0400
@@ -34,7 +34,6 @@
 #include <linux/config.h>
 #include <linux/kprobes.h>
 #include <linux/ptrace.h>
-#include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/preempt.h>
@@ -283,6 +282,7 @@ static void __kprobes prepare_singlestep
 		regs->rip = (unsigned long)p->ainsn.insn;
 }
 
+/* Called with kretprobe_lock held */
 void __kprobes arch_prepare_kretprobe(struct kretprobe *rp,
 				      struct pt_regs *regs)
 {
@@ -323,7 +323,7 @@ int __kprobes kprobe_handler(struct pt_r
 			if (kcb->kprobe_status == KPROBE_HIT_SS) {
 				regs->eflags &= ~TF_MASK;
 				regs->eflags |= kcb->kprobe_saved_rflags;
-				unlock_kprobes();
+				read_lock(&kprobe_lock);
 				goto no_kprobe;
 			} else if (kcb->kprobe_status == KPROBE_HIT_SSDONE) {
 				/* TODO: Provide re-entrancy from
@@ -360,10 +360,10 @@ int __kprobes kprobe_handler(struct pt_r
 		goto no_kprobe;
 	}
 
-	lock_kprobes();
+	read_lock(&kprobe_lock);
 	p = get_kprobe(addr);
 	if (!p) {
-		unlock_kprobes();
+		read_unlock(&kprobe_lock);
 		if (*addr != BREAKPOINT_INSTRUCTION) {
 			/*
 			 * The breakpoint instruction was removed right
@@ -423,6 +423,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);
 
 	/*
@@ -461,7 +462,8 @@ int __kprobes trampoline_probe_handler(s
 	BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
 	regs->rip = orig_ret_address;
 
-	unlock_kprobes();
+	spin_unlock(&kretprobe_lock);
+	read_unlock(&kprobe_lock);
 
         /*
          * By returning a non-zero value, we are telling
@@ -573,7 +575,7 @@ int __kprobes post_kprobe_handler(struct
 		restore_previous_kprobe(kcb);
 		goto out;
 	} else {
-		unlock_kprobes();
+		read_unlock(&kprobe_lock);
 	}
 out:
 	preempt_enable_no_resched();
@@ -603,7 +605,7 @@ int __kprobes kprobe_fault_handler(struc
 		regs->eflags |= kcb->kprobe_old_rflags;
 
 		reset_current_kprobe();
-		unlock_kprobes();
+		read_unlock(&kprobe_lock);
 		preempt_enable_no_resched();
 	}
 	return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]