[PATCH]kprobes comment patch around kprobes lock functions

Keshavamurthy Anil S
2005-09-01T23:12:29Z

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);
}