This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH]kprobes comment patch around kprobes lock functions
- From: Keshavamurthy Anil S <anil dot s dot keshavamurthy at intel dot com>
- To: Andrew Morton <akpm at osdl dot org>
- Cc: Keshavamurthy Anil S <anil dot s dot keshavamurthy at intel dot com>, linux-kernel at vger dot kernel dot org, systemtap at sources dot redhat dot com, ananth at in dot ibm dot com, prasanna at in dot ibm dot com
- Date: Thu, 1 Sep 2005 16:12:18 -0700
- Subject: [PATCH]kprobes comment patch around kprobes lock functions
- References: <20050901134937.A29041@unix-os.sc.intel.com> <20050901140938.69909683.akpm@osdl.org>
- Reply-to: Keshavamurthy Anil S <anil dot s dot keshavamurthy at intel dot com>
On Thu, Sep 01, 2005 at 02:09:38PM -0700, Andrew Morton wrote:
> Now, probably there's deep magic happening here and I'm wrong. If so then
> please explain the code's magic via a comment patch so the question doesn't
> arise again, thanks.
>
This is a comment patch around lock_kprobes() and unlock_kprobes() functions.
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
===================================================================
kernel/kprobes.c | 14 ++++++++++++++
1 files changed, 14 insertions(+)
Index: linux-2.6.13-mm1/kernel/kprobes.c
===================================================================
--- linux-2.6.13-mm1.orig/kernel/kprobes.c
+++ linux-2.6.13-mm1/kernel/kprobes.c
@@ -157,9 +157,16 @@ void __kprobes lock_kprobes(void)
{
unsigned long flags = 0;
+ /* Avoiding local interrupts to happen right after we take the kprobe_lock
+ * and before we get a chance to update kprobe_cpu, this to prevent
+ * deadlock when we have a kprobe on ISR routine and a kprobe on task
+ * routine
+ */
local_irq_save(flags);
+
spin_lock(&kprobe_lock);
kprobe_cpu = smp_processor_id();
+
local_irq_restore(flags);
}
@@ -167,9 +174,16 @@ void __kprobes unlock_kprobes(void)
{
unsigned long flags = 0;
+ /* Avoiding local interrupts to happen right after we update
+ * kprobe_cpu and before we get a a chance to release kprobe_lock,
+ * this to prevent deadlock when we have a kprobe on ISR routine and
+ * a kprobe on task routine
+ */
local_irq_save(flags);
+
kprobe_cpu = NR_CPUS;
spin_unlock(&kprobe_lock);
+
local_irq_restore(flags);
}