public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf map: remove extra indirection from map__find()
@ 2018-11-23 10:42 Eric Saint-Etienne
  2018-11-23 16:14 ` Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eric Saint-Etienne @ 2018-11-23 10:42 UTC (permalink / raw)
  To: Linux Kernel
  Cc: Alexander Shishkin, Arnaldo Carvalho de Melo, Ingo Molnar,
	Jiri Olsa, Peter Zijlstra, Namhyung Kim, Eric Saint-Etienne

A double pointer is used in map__find() where a single pointer is enough
because the function doesn't affect the rbtree and the rbtree is locked.

Signed-off-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
---
 tools/perf/util/map.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 354e545..3dac766 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -846,19 +846,18 @@ void maps__remove(struct maps *maps, struct map *map)
 
 struct map *maps__find(struct maps *maps, u64 ip)
 {
-	struct rb_node **p, *parent = NULL;
+	struct rb_node *p;
 	struct map *m;
 
 	down_read(&maps->lock);
 
-	p = &maps->entries.rb_node;
-	while (*p != NULL) {
-		parent = *p;
-		m = rb_entry(parent, struct map, rb_node);
+	p = maps->entries.rb_node;
+	while (p != NULL) {
+		m = rb_entry(p, struct map, rb_node);
 		if (ip < m->start)
-			p = &(*p)->rb_left;
+			p = p->rb_left;
 		else if (ip >= m->end)
-			p = &(*p)->rb_right;
+			p = p->rb_right;
 		else
 			goto out;
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-18 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-23 10:42 [PATCH] perf map: remove extra indirection from map__find() Eric Saint-Etienne
2018-11-23 16:14 ` Jiri Olsa
2018-11-26 18:53   ` Arnaldo Carvalho de Melo
2018-12-14 20:20 ` [tip:perf/core] perf map: Remove " tip-bot for Eric Saint-Etienne
2018-12-18 13:47 ` tip-bot for Eric Saint-Etienne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox