From: Arjan van de Ven <arjan@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
linux-arch@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Stephane Eranian <eranian@googlemail.com>,
Eric Dumazet <dada1@cosmosbay.com>,
Robert Richter <robert.richter@amd.com>,
Peter Anvin <hpa@zytor.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Steven Rostedt <rostedt@goodmis.org>,
David Miller <davem@davemloft.net>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [patch] Performance Counters for Linux, v2
Date: Sun, 7 Dec 2008 17:49:32 -0800 [thread overview]
Message-ID: <20081207174932.09673cae@infradead.org> (raw)
In-Reply-To: <20081208012211.GA23106@elte.hu>
On Mon, 8 Dec 2008 02:22:12 +0100
Ingo Molnar <mingo@elte.hu> 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.
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
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\x19
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
As is usual with profile outputs, the cost for the function always gets added to the instruction after
the really guilty one. I'd move the count one back, but this is hard if the previous instruction was a
(conditional) jump...
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
next prev parent reply other threads:[~2008-12-08 1:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-08 1:22 [patch] Performance Counters for Linux, v2 Ingo Molnar
2008-12-08 1:49 ` Arjan van de Ven [this message]
2008-12-08 11:49 ` Ingo Molnar
2009-01-07 7:43 ` Zhang, Yanmin
2009-01-09 1:07 ` Zhang, Yanmin
2008-12-08 3:24 ` Paul Mackerras
2008-12-08 11:33 ` Ingo Molnar
2008-12-08 12:02 ` David Miller
2008-12-08 14:41 ` Andi Kleen
2008-12-08 22:03 ` Paul Mackerras
2008-12-09 13:00 ` Ingo Molnar
2008-12-09 23:00 ` Paul Mackerras
2008-12-08 8:32 ` Corey J Ashford
2008-12-09 6:37 ` stephane eranian
2008-12-09 11:02 ` Ingo Molnar
2008-12-09 11:11 ` David Miller
2008-12-09 11:22 ` Ingo Molnar
2008-12-09 11:29 ` David Miller
2008-12-09 12:14 ` Paolo Ciarrocchi
2008-12-09 13:46 ` Ingo Molnar
2008-12-09 16:39 ` Chris Friesen
2008-12-09 19:02 ` Ingo Molnar
2008-12-09 19:51 ` Chris Friesen
2008-12-09 16:46 ` Will Newton
2008-12-09 17:35 ` Chris Friesen
2008-12-09 21:16 ` stephane eranian
2008-12-09 21:16 ` stephane eranian
2008-12-09 22:19 ` Paul Mackerras
2008-12-09 22:40 ` Andi Kleen
2008-12-10 4:44 ` Paul Mackerras
2008-12-10 5:03 ` stephane eranian
2008-12-10 5:03 ` stephane eranian
2008-12-10 10:26 ` Andi Kleen
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=20081207174932.09673cae@infradead.org \
--to=arjan@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=eranian@googlemail.com \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=robert.richter@amd.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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).