public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
Cc: linux-kernel@vger.kernel.org, systemtap@sources.redhat.com,
	ananth@in.ibm.com, prasanna@in.ibm.com
Subject: Re: [PATCH]kprobes fix bug when probed on task and isr functions
Date: Thu, 1 Sep 2005 14:42:11 -0700	[thread overview]
Message-ID: <20050901144211.5bf5ded6.akpm@osdl.org> (raw)
In-Reply-To: <20050901142734.A29448@unix-os.sc.intel.com>

Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com> wrote:
>
> > >  void __kprobes lock_kprobes(void)
> > >  {
> > > +	unsigned long flags = 0;
> > > +
> > > +	local_irq_save(flags);
> > >  	spin_lock(&kprobe_lock);
> > >  	kprobe_cpu = smp_processor_id();
> > > + 	local_irq_restore(flags);
> > >  }
> > 
> > what is this change trying to do?  If a lock is taken from both process and
> > irq contexts then local IRQs must be disabled for the entire period when the
> > lock is held, not just for a little blip like this.  If IRQ-context code is
> > running this function then the code is deadlockable.
> 
> In the kprobe exception handling we relay on kprobe_cpu = smp_processor_id() to determine
> whether we are inside the kprobe or not. It was so happeing that when we
> take the lock and before kprobe_cpu gets updated if an H/W interrupt happens
> and if kprobe is enabled on ISR routine, then in the kprobe execption handler
> for isr, we miss the indication that we are already in kprobes(since interrupt
> happened before we get to update kprobe_cpu) and we were trying to 
> take the lock again and there by causing the deadlock. This deadlock is avoided
> by disabling the ISR for a short period while we take the spin_lock() and update
> the kprobe_cpu.

OK.

Are you sure that other CPUs can safely read kprobe_cpu without taking the
lock?  I don't see any memory barriers in there...

> > 
> > 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 whole serialization will go away when we introduce the scalability patch.

Yes, it does look rather unscalable.

  reply	other threads:[~2005-09-01 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-01 20:49 [PATCH]kprobes fix bug when probed on task and isr functions Keshavamurthy Anil S
2005-09-01 21:09 ` Andrew Morton
2005-09-01 21:27   ` Keshavamurthy Anil S
2005-09-01 21:42     ` Andrew Morton [this message]
2005-09-01 22:18       ` Keshavamurthy Anil S
2005-09-01 23:12   ` [PATCH]kprobes comment patch around kprobes lock functions Keshavamurthy Anil S

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050901144211.5bf5ded6.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prasanna@in.ibm.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox