Re: [patch] Performance Counters for Linux, v2

From: Zhang, Yanmin
Date: Wed Jan 07 2009 - 02:43:59 EST


On Mon, 2008-12-08 at 12:49 +0100, Ingo Molnar wrote:
> * Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:
>
> > On Mon, 8 Dec 2008 02:22:12 +0100
> > Ingo Molnar <mingo@xxxxxxx> wrote:
> >
> > >
> > > [ Performance counters are special hardware registers available on
> > > most modern CPUs. These register count the number of certain types of
> > > hw events: such as instructions executed, cachemisses suffered, or
> > > branches mis-predicted, without slowing down the kernel or
> > > applications. These registers can also trigger interrupts when a
> > > threshold number of events have passed - and can thus be used to
> > > profile the code that runs on that CPU. ]
> > >
> > > This is version 2 of our Performance Counters subsystem
> > > implementation.
> > >
> > > The biggest user-visible change in this release is a new user-space
> > > text-mode profiling utility that is based on this code: KernelTop.
> > >
> > > KernelTop can be downloaded from:
> > >
> > > http://redhat.com/~mingo/perfcounters/kerneltop.c
> > >
> > > It's a standalone .c file that needs no extra libraries - it only
> > > needs a CONFIG_PERF_COUNTERS=y kernel to run on.
> > >
> > > This utility is intended for kernel developers - it's basically a
> > > dynamic kernel profiler that gets hardware counter events dispatched
> > > to it continuously, which it feeds into a histogram and outputs it
> > > periodically.
> > >
> >
> > I played with this a little, and while it works neat, I wanted a
> > feature added where it shows a detailed profile for the top function.
>
> ah, very nice idea!
>
> > I've hacked this in quickly (the usability isn't all that great yet)
> > and put the source code up at
> >
> > http://www.tglx.de/~arjan/kerneltop-0.02.tar.gz
>
> ok, picked it up :-)
Ingo,

I try to use patch V5 and the latest kerneltop to collect some cachemiss data.

It seems kerneltop just shows the first instruction ip address of functions. Does
the latest kerneltop include the enhancement from Arjan? As you know, with oprofile,
we can get detailed instrument ip address which causes the cache miss although the ip
address should go back one instruction mostly.

>
> > with this it looks like this:
> >
> > $ sudo ./kerneltop --vmlinux=/home/arjan/linux-2.6.git/vmlinux
> >
> > ------------------------------------------------------------------------------
> > KernelTop: 274 irqs/sec [NMI, 1000000 cycles], (all, 2 CPUs)
> > ------------------------------------------------------------------------------
> >
> > events RIP kernel function
> > ______ ________________ _______________
> >
> > 230 - 00000000c04189e9 : read_hpet
> > 82 - 00000000c0409439 : mwait_idle_with_hints
> > 77 - 00000000c051a7b7 : acpi_os_read_port
> > 52 - 00000000c053cb3a : acpi_idle_enter_bm
> > 38 - 00000000c0418d93 : hpet_next_event
> > 19 - 00000000c051a802 : acpi_os_write_port
> > 14 - 00000000c04f8704 : __copy_to_user_ll
> > 13 - 00000000c0460c20 : get_page_from_freelist
> > 7 - 00000000c041c96c : kunmap_atomic
> > 5 - 00000000c06a30d2 : _spin_lock [joydev]
> > 4 - 00000000c04f79b7 : vsnprintf [snd_seq]
> > 4 - 00000000c06a3048 : _spin_lock_irqsave [pcspkr]
> > 3 - 00000000c0403b3c : irq_entries_start
> > 3 - 00000000c0423fee : run_rebalance_domains
> > 3 - 00000000c0425e2c : scheduler_tick
> > 3 - 00000000c0430938 : get_next_timer_interrupt
> > 3 - 00000000c043cdfa : __update_sched_clock
> > 3 - 00000000c0448b14 : update_iter
> > 2 - 00000000c04304bd : run_timer_softirq
> >
> > Showing details for read_hpet
> > 0 c04189e9 <read_hpet>:
> > 2 c04189e9: a1 b0 e0 89 c0 mov 0xc089e0b0,%eax
> > 0
> > 0 /*
> > 0 * Clock source related code
> > 0 */
> > 0 static cycle_t read_hpet(void)
> > 0 {
> > 1 c04189ee: 55 push %ebp
> > 0 c04189ef: 89 e5 mov %esp,%ebp
> > 1 c04189f1: 05 f0 00 00 00 add $0xf0,%eax
> > 0 c04189f6: 8b 00 mov (%eax),%eax
> > 0 return (cycle_t)hpet_readl(HPET_COUNTER);
> > 0 }
> > 300 c04189f8: 31 d2 xor %edx,%edx
> > 0 c04189fa: 5d pop %ebp
> > 0 c04189fb: c3 ret
> > 0
>
Just like above detailed information.

Thanks,
Yanmin


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/