linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Livio Soares <livio@eecg.toronto.edu>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH] Fix performance monitor exception in 2.6.20-series
Date: Sat, 13 Jan 2007 10:40:29 -0500	[thread overview]
Message-ID: <20070113154029.GA32292@eecg.toronto.edu> (raw)


  Hi all,

[  I hope this is the correct mailing list for this sort of patch. Also, I am not
   subscribed; please Cc: with responses.  ]

  To the issue: some point  during 2.6.20 development, Paul Mackerras introduced
the  "lazy IRQ  disabling" patch  (very  cool work,  BTW).  In  that patch,  the
performance monitor unit exception was marked as "maskable", in the sense the if
interrupts were  soft-disabled, that exception  could be ignored. This  broke my
PowerPC  profiling code. The  sympton that  I see  is that  a varying  number of
interrupts  (from 0  to $n$,  typically  closer to  0) get  delivered, when,  in
reality, it should always be very close to $n$.

  The issue stems  from the way masking is being done.   Masking in this fashion
seems to  work well with the  decrementer and external  interrupts, because they
are raised  again until "really"  handled. For the  PMU, however, this  does not
apply  (at least on  my Xserver  machine with  a 970FX  processor).  If  the PMU
exception  is  not  handled,  it  will  _not_  be  re-raised  (at  least  on  my
machine). The documentation states  that the PMXE bit in MMCR0 is  set to 0 when
the PMU exception is raised. However,  software must re-set the bit to re-enable
PMU exceptions.   If the exception  is ignored (as  currently) not only  is that
interrupt lost, but because software does  not reset PMXE, the PMU registers are
"frozen" forever.

  Although I  do not use Oprofile  for performance monitoring, I  suspect it, as
well, will be affected. There are 2 options, as far as I can see, for fixing the
problem:

  1) Just let the PMU exception through, even with interrupts disabled. 

  2) When  hard-disabling   interrupts  (masked_interrupt:  in   head_64.S,  for
     example), if the  exception is a PMU exception, remember  to set PMXE back,
     so that the interrupt will be raised in the future.

     I don't like this option; specifically, I am pretty sure the actual bit for
     enabling PMU interrupts can vary from  one PowerPC chip to the next. Custom
     CPU code will be needed to make this work.

     However, I tested this option #2 on  my 970, and it made my profiling works
     again. 


  IMHO, option  #1 is very  nice, as long  as the PMU interrupt  handler behaves
itself.  One reason option #1 is desirable is, with PC-sampling, we are now able
to  sample  regions _inside_  interrupt-disabled  sections  (assuming an  actual
external interrupt  hasn't really occured yet). Before,  with hardware disabling
of  interrupts,  the  PMU  exceptions  were  necessarily  delivered  outside  of
interrupt disabled sections. 

  Anyways, does anyone see a problem with the following patch? 

  regards,


				Livio


--- linux-2.6.20-rc4/arch/powerpc/kernel/head_64.S	2007-01-07 00:45:51.000000000 -0500
+++ linux-2.6.20-rc4.pmu/arch/powerpc/kernel/head_64.S	2007-01-13 10:28:49.894734542 -0500
@@ -613,7 +613,7 @@ system_call_pSeries:
 /*** pSeries interrupt support ***/
 
 	/* moved from 0xf00 */
-	MASKABLE_EXCEPTION_PSERIES(., performance_monitor)
+	STD_EXCEPTION_PSERIES(., performance_monitor)
 
 /*
  * An interrupt came in while soft-disabled; clear EE in SRR1,

             reply	other threads:[~2007-01-13 16:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-13 15:40 Livio Soares [this message]
2007-01-14  0:29 ` [PATCH] Fix performance monitor exception in 2.6.20-series Benjamin Herrenschmidt
2007-01-14  0:39   ` Segher Boessenkool
2007-01-14 17:56   ` Livio Soares
2007-01-15  2:40   ` David Woodhouse
2007-01-15  2:53     ` Paul Mackerras
2007-01-15  3:14       ` David Woodhouse

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=20070113154029.GA32292@eecg.toronto.edu \
    --to=livio@eecg.toronto.edu \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).