mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	David Miller <davem@davemloft.net>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sorin Dumitru <dumitru.sorin87@gmail.com>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 8/9] perf annotate: Fix off by one symbol hist size allocation and hit accounting
Date: Fri, 30 Mar 2012 13:09:23 -0300	[thread overview]
Message-ID: <1333123764-15662-9-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1333123764-15662-1-git-send-email-acme@infradead.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We were not noticing it because symbol__inc_addr_samples was erroneously
dropping samples that hit the last byte in a function.

Working on a fix for a problem reported by David Miller, Stephane
Eranian and Sorin Dumitru, where addresses < sym->start were causing
problems, I noticed this other problem.

Cc: David Ahern <dsahern@gmail.com>
Cc: David Miller <davem@davemloft.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sorin Dumitru <dumitru.sorin87@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-pqjaq4cr1xs2xen73pjhbav4@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 31ba2a2..199f69e 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -28,8 +28,8 @@ int symbol__annotate_init(struct map *map __used, struct symbol *sym)
 int symbol__alloc_hist(struct symbol *sym)
 {
 	struct annotation *notes = symbol__annotation(sym);
-	size_t sizeof_sym_hist = (sizeof(struct sym_hist) +
-				  (sym->end - sym->start) * sizeof(u64));
+	const size_t size = sym->end - sym->start + 1;
+	size_t sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
 
 	notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist);
 	if (notes->src == NULL)
@@ -64,7 +64,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
 
 	pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
 
-	if (addr >= sym->end)
+	if (addr > sym->end)
 		return 0;
 
 	offset = addr - sym->start;
-- 
1.7.9.2.358.g22243


  parent reply	other threads:[~2012-03-30 16:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 16:09 [GIT PULL 0/9] perf/urgent fixes Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 1/9] perf tools: Fix display of first level of callchains Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 2/9] perf tools: Fix bug in raw sample parsing Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 3/9] perf symbols: Do not include libgen.h Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 4/9] perf symbols: Handle NULL dso in dso__name_len Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 5/9] perf probe: Finder fails to resolve function name to address Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 6/9] perf annotate: addr2line wants addresses in same format as objdump Arnaldo Carvalho de Melo
2012-03-30 16:09 ` [PATCH 7/9] perf tools: Add missing ref-cycles event back to event parser Arnaldo Carvalho de Melo
2012-03-30 16:09 ` Arnaldo Carvalho de Melo [this message]
2012-03-30 16:09 ` [PATCH 9/9] perf tools: Remove auto-generated bison/flex files Arnaldo Carvalho de Melo
2012-03-30 16:43   ` Namhyung Kim
2012-03-30 17:09     ` David Daney
2012-03-30 22:01     ` Arnaldo Carvalho de Melo
2012-03-31  7:31 ` [GIT PULL 0/9] perf/urgent fixes Ingo Molnar

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=1333123764-15662-9-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=dumitru.sorin87@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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®