Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695286

[PATCH v1 03/15] perf, tools, stat: Fix saved values rbtree lookup

From Andi Kleen <andi@firstfloor.org>
Newsgroups linux.kernel
Subject [PATCH v1 03/15] perf, tools, stat: Fix saved values rbtree lookup
Date 2017-07-25 01:50 +0200
Message-ID <u6VgT-3zh-43@gated-at.bofh.it> (permalink)
References <u6VgR-3zh-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Andi Kleen <ak@linux.intel.com>

The stat shadow saved values rbtree is indexed by a pointer.
Fix the comparison function:

- We cannot return a pointer delta as an int because
that loses bits on 64bit.
- Doing pointer arithmetic on the struct pointer
only works if the objects are spaced by the multiple
of the object size, which is not guaranteed for individual
malloc'ed object

Replace it with a proper comparison.

This fixes various problems with values not being found.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/util/stat-shadow.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 719d6cb86952..a04cf56d3517 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -70,7 +70,11 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
 		return a->ctx - b->ctx;
 	if (a->cpu != b->cpu)
 		return a->cpu - b->cpu;
-	return a->evsel - b->evsel;
+	if (a->evsel == b->evsel)
+		return 0;
+	if ((char *)a->evsel < (char *)b->evsel)
+		return -1;
+	return +1;
 }
 
 static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused,
-- 
2.9.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Support standalone metrics and metric groups for perf Andi Kleen <andi@firstfloor.org> - 2017-07-25 01:50 +0200
  [PATCH v1 11/15] perf, tools, stat: Factor out generic metric printing Andi Kleen <andi@firstfloor.org> - 2017-07-25 01:50 +0200
  [PATCH v1 03/15] perf, tools, stat: Fix saved values rbtree lookup Andi Kleen <andi@firstfloor.org> - 2017-07-25 01:50 +0200
  [PATCH v1 15/15] perf, tools: Support duration_time Andi Kleen <andi@firstfloor.org> - 2017-07-25 01:50 +0200
  [PATCH v1 01/15] perf, tools, stat: Fix buffer overflow while freeing events Andi Kleen <andi@firstfloor.org> - 2017-07-25 01:50 +0200
  Re: Support standalone metrics and metric groups for perf Jiri Olsa <jolsa@redhat.com> - 2017-07-26 16:20 +0200
    Re: Support standalone metrics and metric groups for perf Andi Kleen <andi@firstfloor.org> - 2017-07-26 17:40 +0200
      Re: Support standalone metrics and metric groups for perf Jiri Olsa <jolsa@redhat.com> - 2017-07-28 10:50 +0200

csiph-web