File paflib.fix_broken_EBB_sample_period.patch of Package paflib

commit 2138795d4b23884b21c34f789d0450f6ad15e7e4
Author: Maynard Johnson <maynardj@us.ibm.com>
Date:   Tue Jun 10 14:24:41 2014 -0500

    ebb: Fix broken EBB sample period
    
    The current implementation of reset_pmcs() in ebb/ebb-priv.h takes
    the stored sample_period (passed by the user) and does the following:
    
            mtspr(PMC<n>, sample_period)
    
    for each PMC, 1-6.  Performance monitor interrupts are generated wheni
    the value in an enabled PMC transitions to where the most significant
    bit becomes '1'.  If a user wants to get an event based interrupt, say,
    every 1,000,000 cycles, then the PMC should be configured to count the
    cycles event and its initial value should be set to 0x80000000 - 1000000.
    
    With an initial value set this way, after 1 million cycles events occur,
    the PMC value will transition to the value 0x80000000 and generate an
    interrupt.  The patch fixes the library code to perform this calculation,
    instead of expecting clients of the library to do it (which most would
    not know, and it's certainly not documented that it's required).

diff --git a/ebb/ebb-priv.h b/ebb/ebb-priv.h
index ec5b127..65f9863 100644
--- a/ebb/ebb-priv.h
+++ b/ebb/ebb-priv.h
@@ -180,6 +180,13 @@ static inline
 attribute_alwaysinline
 void reset_pmcs (uint32_t sample_period)
 {
+  /* Performance monitor interrupts are generated when the value in an enabled
+     PMC transitions to where the most significant bit becomes '1'.  If a useri
+     wants to get an event based interrupt, say, every 1,000,000 cycles, then
+     the PMC should be configured to count the cycles event and its initial
+     value should be set to 0x80000000 - 1000000.  */
+  sample_period = 0x80000000UL - sample_period;
+
   mtspr (PMC1, sample_period);
   mtspr (PMC2, sample_period);
   mtspr (PMC3, sample_period);
openSUSE Build Service is sponsored by