mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Anton Blanchard <anton@samba.org>,
	Eric B Munson <emunson@mgebm.net>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ian Munsie <imunsie@au1.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 08/12] perf sort: Fix symbol sort output by separating unresolved samples by type
Date: Fri, 23 Sep 2011 17:26:22 -0300	[thread overview]
Message-ID: <1316809586-28529-9-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1316809586-28529-1-git-send-email-acme@infradead.org>

From: Anton Blanchard <anton@samba.org>

I took a profile that suggested 60% of total CPU time was in the
hypervisor:

...
    60.20%  [H] 0x33d43c
     4.43%  [k] ._spin_lock_irqsave
     1.07%  [k] ._spin_lock

Using perf stat to get the user/kernel/hypervisor breakdown contradicted
this.

The problem is we merge all unresolved samples into the one unknown
bucket. If add a comparison by sample type to sort__sym_cmp we get the
real picture:

...
    57.11%  [.] 0x80fbf63c
     4.43%  [k] ._spin_lock_irqsave
     1.07%  [k] ._spin_lock
     0.65%  [H] 0x33d43c

So it was almost all userspace, not hypervisor as the initial profile
suggested.

I found another issue while adding this. Symbol sorting sometimes shows
multiple entries for the unknown bucket:

...
    16.65%  [.] 0x6cd3a8
     7.25%  [.] 0x422460
     5.37%  [.] yylex
     4.79%  [.] malloc
     4.78%  [.] _int_malloc
     4.03%  [.] _int_free
     3.95%  [.] hash_source_code_string
     2.82%  [.] 0x532908
     2.64%  [.] 0x36b538
     0.94%  [H] 0x8000000000e132a4
     0.82%  [H] 0x800000000000e8b0

This happens because we aren't consistent with our sorting. On
one hand we check to see if both symbols match and for two unresolved
samples sym is NULL so we match:

        if (left->ms.sym == right->ms.sym)
                return 0;

On the other hand we use sample IP for unresolved samples when
comparing against a symbol:

       ip_l = left->ms.sym ? left->ms.sym->start : left->ip;
       ip_r = right->ms.sym ? right->ms.sym->start : right->ip;

This means unresolved samples end up spread across the rbtree and we
can't merge them all.

If we use cmp_null all unresolved samples will end up in the one bucket
and the output makes more sense:

...
    39.12%  [.] 0x36b538
     5.37%  [.] yylex
     4.79%  [.] malloc
     4.78%  [.] _int_malloc
     4.03%  [.] _int_free
     3.95%  [.] hash_source_code_string
     2.26%  [H] 0x800000000000e8b0

Acked-by: Eric B Munson <emunson@mgebm.net>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ian Munsie <imunsie@au1.ibm.com>
Link: http://lkml.kernel.org/r/20110831115145.4f598ab2@kryten
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 401e220..1ee8f1e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -151,11 +151,17 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
 {
 	u64 ip_l, ip_r;
 
+	if (!left->ms.sym && !right->ms.sym)
+		return right->level - left->level;
+
+	if (!left->ms.sym || !right->ms.sym)
+		return cmp_null(left->ms.sym, right->ms.sym);
+
 	if (left->ms.sym == right->ms.sym)
 		return 0;
 
-	ip_l = left->ms.sym ? left->ms.sym->start : left->ip;
-	ip_r = right->ms.sym ? right->ms.sym->start : right->ip;
+	ip_l = left->ms.sym->start;
+	ip_r = right->ms.sym->start;
 
 	return (int64_t)(ip_r - ip_l);
 }
-- 
1.6.2.5


  parent reply	other threads:[~2011-09-23 20:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23 20:26 [GIT PULL 00/12] perf tools fixes Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 01/12] perf probe: Fix regression of variable finder Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 02/12] perf symbols: Fix ppc64 SEGV in dso__load_sym with debuginfo files Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 03/12] perf symbols: /proc/kallsyms does not sort module symbols Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 04/12] perf symbols: Preserve symbol scope when parsing /proc/kallsyms Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 05/12] perf symbols: Add some heuristics for choosing the best duplicate symbol Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 06/12] perf record: Create events initially disabled and enable after init Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 07/12] perf symbols: Synthesize anonymous mmap events Arnaldo Carvalho de Melo
2011-09-23 20:26 ` Arnaldo Carvalho de Melo [this message]
2011-09-23 20:26 ` [PATCH 09/12] perf tool: Fix endianness handling of u32 data in samples Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 10/12] perf symbols: Fix issue with binaries using 16-bytes buildids (v2) Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 11/12] perf top: Fix userspace sample addr map offset Arnaldo Carvalho de Melo
2011-09-23 20:26 ` [PATCH 12/12] perf tools: Add support for disabling -Werror via WERROR=0 Arnaldo Carvalho de Melo
2011-09-23 21:03 ` [GIT PULL 00/12] perf tools fixes Linus Torvalds
2011-09-23 21:05   ` Arnaldo Carvalho de Melo
2011-09-23 21:05   ` Linus Torvalds
2011-09-23 21:11     ` Arnaldo Carvalho de Melo
2011-09-23 21:25       ` Arnaldo Carvalho de Melo
2011-09-23 23:12         ` Linus Torvalds
2011-09-23 23:31           ` Arnaldo Carvalho de Melo
2011-09-23 23:46           ` Arnaldo Carvalho de Melo
2011-09-24  3:46             ` David Ahern

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=1316809586-28529-9-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=anton@samba.org \
    --cc=emunson@mgebm.net \
    --cc=fweisbec@gmail.com \
    --cc=imunsie@au1.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®