mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* perfctr questions
@ 2004-07-01 22:04 bert hubert
  2004-07-01 22:19 ` Bryan O'Sullivan
  0 siblings, 1 reply; 6+ messages in thread
From: bert hubert @ 2004-07-01 22:04 UTC (permalink / raw)
  To: Mikael.Pettersson; +Cc: linux-kernel

Mikael,

I'm trying to test your performance counters stuff, but I can't get it to do
anything remotely useful! Probably just me.

I have a very hard time understanding things like:

 *      perfex -e 0x00039000/0x04000204@0x8000000C some_program
 *
 *      Explanation: Program IQ_CCCR0 with required flags, ESCR select 4
 *      (== CRU_ESCR0), and Enable. Program CRU_ESCR0 with event 2
 *      (instr_retired), NBOGUSNTAG, CPL>0. Map this event to IQ_COUNTER0
 *      (0xC) with fast RDPMC enabled.

I'd love to author a small perfctr howto for people like me who just want to
know if their code is thrashing the cache. 

Do you have a pointer to tools that do this, or, how to calculate these
0x00039000 numbers for perfex? I can't find anything relevant. The best
information I found is in the 'hardmeter' sources.

I tried one very basic thing, perfex -e 0x00410005 ./null which I hoped
would measure unaligned memory accesses, but I can't get this counter raised
from 0. null.c:

int main(int argc, char **argv)
{
        char room[12];
        int i, n;

        for(n=0;n<1000000;++n) {
                i=*((int*)(room+n%4));  
        }
        
        printf("%d\n", i);
}

I'm on a Pentium M, 2.6.7-mm5. Not even sure if an Pentium M will measure
cache misses though.

Thanks

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: perfctr questions
@ 2004-07-02 10:21 Mikael Pettersson
  2004-07-02 11:04 ` bert hubert
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Pettersson @ 2004-07-02 10:21 UTC (permalink / raw)
  To: ahu; +Cc: linux-kernel

On Fri, 2 Jul 2004 00:04:48 +0200, bert hubert <ahu@ds9a.nl> wrote:
>I'm trying to test your performance counters stuff, but I can't get it to do
>anything remotely useful! Probably just me.
>
>I have a very hard time understanding things like:
>
> *      perfex -e 0x00039000/0x04000204@0x8000000C some_program
> *
> *      Explanation: Program IQ_CCCR0 with required flags, ESCR select 4
> *      (== CRU_ESCR0), and Enable. Program CRU_ESCR0 with event 2
> *      (instr_retired), NBOGUSNTAG, CPL>0. Map this event to IQ_COUNTER0
> *      (0xC) with fast RDPMC enabled.
>
>I'd love to author a small perfctr howto for people like me who just want to
>know if their code is thrashing the cache. 
>
>Do you have a pointer to tools that do this, or, how to calculate these
>0x00039000 numbers for perfex? I can't find anything relevant. The best
>information I found is in the 'hardmeter' sources.

Unfortunately, the corresponding hardware both varies
quite a lot between processor families and manufacturers,
and in some cases (P4) is highly complex to begin with.

perfctr provides the low-level interface to these things,
and therefore you must be familiar with the hardware in
order to use it. So reading the Intel "IA32 Volume 3"
and AMD "kernel & bios" manuals is a prerequisite.

I rely on others to provide user-friendly tools and libraries.
For libraries, you should use PAPI. For tools, there are
a few, including Bryan's modifications to my (raw) perfex.

Should the kernel driver directly support some user-friendly
model of the counters? No it should not, for several reasons:
- The complexity and variability of the hardware means that
  any model would be inaccurate. You'd both lose a lot of
  functionality, and have a lot of functionality which isn't
  supportable on any given processor. User-space stuff that
  tries this approach tends to also include a direct-access
  backdoor, which brings us back to the present situation.
- The implementation of such a model would be large and complex.
  It's better to do the complex stuff in user-space, allowing
  the kernel drivers to only validate control data and drive
  the hardware.
- The model is purely a user-convenience thing. The drivers
  don't need it.

>I tried one very basic thing, perfex -e 0x00410005 ./null which I hoped
>would measure unaligned memory accesses, but I can't get this counter raised
>from 0. null.c:
>
>int main(int argc, char **argv)
>{
>        char room[12];
>        int i, n;
>
>        for(n=0;n<1000000;++n) {
>                i=*((int*)(room+n%4));  
>        }
>        
>        printf("%d\n", i);
>}
>
>I'm on a Pentium M, 2.6.7-mm5. Not even sure if an Pentium M will measure
>cache misses though.

I get '2' on a Pentium-II. It may be that the event only
counts actual external memory references, in which case
the processor's internal caches will cancel most of them.

I've had similar questions before, where it turned out
that gcc had optimised away the code that was to be measured.
Synthetic benchmarks are tricky...

/Mikael

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-07-02 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-01 22:04 perfctr questions bert hubert
2004-07-01 22:19 ` Bryan O'Sullivan
2004-07-01 22:56   ` bert hubert
2004-07-01 23:26   ` bert hubert
2004-07-02 10:21 Mikael Pettersson
2004-07-02 11:04 ` bert hubert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®