LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@hpl.hp.com>
To: Sonny Rao <sonny@burdell.org>
Cc: mikey@neuling.org, miltonm@bga.com, dwg@au1.ibm.com,
	linuxppc-dev@ozlabs.org, paulus@samba.org, anton@samba.org,
	cjashfor@us.ibm.com, perfmon2-devel@lists.sourceforge.net
Subject: Re: perfmon2 needs hard_irq_disable() for powerpc
Date: Mon, 26 Nov 2007 00:55:13 -0800	[thread overview]
Message-ID: <20071126085513.GB16663@frankl.hpl.hp.com> (raw)
In-Reply-To: <20071126074438.GA27499@kevlar.boston.burdell.org>

Hello Sonny,

On Mon, Nov 26, 2007 at 02:44:38AM -0500, Sonny Rao wrote:
> Hi, I've been reading through the perfmon2 patch for 2.6.23 and it
> dawned on me that in the powerpc architecture we have the notion of
> lazy-disabling of interrupts where we don't actually disable
> interrupts unless we see one come in and then turn them off.  I believe
> a notable exception is the performance monitor interrupt which we
> allow to break into our critical sections.  This is desirable because
> we want to profile those sections  and right now, no in-kernel user of
> the performance monitor interrupt in powerpc does any synchronization
> across cpus inside the interrupt handler (oprofile seems to use
> per-cpu buffers/state for everything).  We use hard_irq_disable() when
> we _really_ have to disable interrupts because we're switching out the
> kernel stack, etc. 
> 
> Perfmon2 is more demanding in its synchronization requirements and it
> uses spin_lock_irqsave() in the generic arch-neutral code in several
> places, I think this will break on powerpc the way we're handling
> things now.
> 
We use spinlocks to serialize access to the perfmon context. The irq masking
is here to avoid a race between a user calling into perfmon and a counter
interrupt. 

Allowing PMU interrupts in critical sections is useful, yet it gets
complicated very quickly because of locking issues, including within
the perfmon code. For instance, a consequence of a interrupt could be
that a SIGIO message is posted. If counter interrupts were allowed in the
signal code, then we could potentially get dedlock situations.

>From what you are saying it seems on powerpc, there may be a way to
differentiate interrupts and thus possibly allow a less restrictive
locking policy.

> I'm copying a few people to solicit opinions on how best to deal with
> this.  I think it's desirable to keep the property of letting us
> profile critical sections in the kernel wherever possible. So we would
> need to add hard_irq_disable/enable calls to the generic code, but want to
> check with you guys first.   
> 
I am open to suggestions. If we can enable monitoring in critical sections
and still avoid races and dealocks, at least on powerpc, then I'll be happy
to allow this.

Thanks.

-- 

-Stephane

      reply	other threads:[~2007-11-26  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26  7:44 perfmon2 needs hard_irq_disable() for powerpc Sonny Rao
2007-11-26  8:55 ` Stephane Eranian [this message]

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=20071126085513.GB16663@frankl.hpl.hp.com \
    --to=eranian@hpl.hp.com \
    --cc=anton@samba.org \
    --cc=cjashfor@us.ibm.com \
    --cc=dwg@au1.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=miltonm@bga.com \
    --cc=paulus@samba.org \
    --cc=perfmon2-devel@lists.sourceforge.net \
    --cc=sonny@burdell.org \
    /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