Re: [PATCH] Remove Powerpc OProfile events the kernel will reject

"Carl E. Love" <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <1448403583.5606.26.camel@oc3328482554>
On Tue, 2015-11-24 at 22:19 +0100, Michael Petlan wrote:
> On Tue, 2015-11-24 at 08:28 -0800, Carl E. Love wrote:
> 
> > The event code for  PM_DATA_ALL_FROM_RL2L3_MOD is 0x62c046.  Bits 22:20
> > are 2. According to the note 1 in the patch the kernel will reject any
> > event with non zero bits in 22:20.  Hence it was included.  I tried the
> > event on my Power 8 machine:
> > 
> > ocount -e PM_DATA_ALL_FROM_RL2L3_MOD ls
> > Cannot find event PM_DATA_ALL_FROM_RL2L3_MOD
> > Error retrieving info for event PM_DATA_ALL_FROM_RL2L3_MOD
> > 
> > and it was rejected.  
> > 
> > I have not tracked down exactly when the change went into the kernel.  I
> > have 3.13.0-35 on my Ubuntu 14.04 system.  What distro/kernel version
> > are you running?
> > 
> >        Carl Love
> 
> 
> Hi Carl,
> 
> I have tested it and all the PM_DATA_ALL_* events work for me. The
> testing environment is:
> 
> cpu             : POWER8E (raw), altivec supported
> clock           : 3690.000000MHz
> revision        : 2.1 (pvr 004b 0201)
> 
> Running the RHEL-7 kernel and also upstream 4.4.0-rc2+ version and older
> oprofile-0.9.9. The machine is a bare metal one, so no POWERPC
> virtualization is used. But when quickly checking PowerKVM, KVM and LPAR
> guests, the behaviour is the same.

I am running the latest git version of OProfile on a virtualized
machine.  

processor	: 124
cpu		: POWER8E (raw), altivec supported
clock		: 3957.000000MHz
revision	: 2.0 (pvr 004b 0200)

with kernel 

Linux genoa 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:57:29 UTC 2014 ppc64le GNU/Linux


You said you are running oprofile-0.9.9.  The older version of OProfile,
used the oprofile kernel support.  Starting with verison 1.0, oprofile
started using the underlying perf kernel support instead of its own
kernel support. 

So, with the 1.0.0 version of oprofile, OProfile sends the event to the
underlying perf interface.  If you look at the perf kernel code in
linux-4.4-rc2/arch/powerpc/perf/power8-pmu.c at line 74 you will see the
documentation on the cache bits in position 22:20.

At line 327 you will see:

        if (unit >= 6 && unit <= 9) {
                /*                                                                                                              
                 * L2/L3 events contain a cache selector field, which is                                                        
                 * supposed to be programmed into MMCRC. However MMCRC is only                                                  
                 * HV writable, and there is no API for guest kernels to modify                                                 
                 * it. The solution is for the hypervisor to initialise the                                                     
                 * field to zeroes, and for us to only ever allow events that                                                   
                 * have a cache selector of zero. The bank selector (bit 3) is                                                  
                 * irrelevant, as long as the rest of the value is 0.                                                           
                 */
                if (cache & 0x7)
                        return -1;

Which checks the unit and the cache bits and rejects the event
independent of the machine being bare metal or virtualized. 

So, if you are using the older OProfile, the cache bits are still not
set as there is no interface for the kernel to talk to the hypervisor to
request the bits be set.  On a bare metal system the kernel is running
as the hypervisor, but there still is no code to write the cache bits.
So the event might be accepted by the older OProfile but since the cache
bits are not set, you are not counting the event you requested.

That said, I think if you install the latest OProfile code and test the
event with OProfile or ocount, you should see it rejected by the
underlying perf interface.

The other thing you can do is make sure the perf power 8 performance
monitoring support has been registered by grepping for "POWER8
performance monitor hardware support registered" in dmesg after the
system boots.  

         Carl Love


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.