linux-kernel.vger.kernel.org archive mirror
 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

* Re: [PATCH] perf map: remove extra indirection from map__find()
  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
  2 siblings, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2018-11-23 16:14 UTC (permalink / raw)
  To: Eric Saint-Etienne
  Cc: Linux Kernel, Alexander Shishkin, Arnaldo Carvalho de Melo,
	Ingo Molnar, Peter Zijlstra, Namhyung Kim, Eric Saint-Etienne

On Fri, Nov 23, 2018 at 02:42:39AM -0800, Eric Saint-Etienne wrote:
> 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>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  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	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf map: remove extra indirection from map__find()
  2018-11-23 16:14 ` Jiri Olsa
@ 2018-11-26 18:53   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-26 18:53 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Eric Saint-Etienne, Linux Kernel, Alexander Shishkin,
	Ingo Molnar, Peter Zijlstra, Namhyung Kim, Eric Saint-Etienne

Em Fri, Nov 23, 2018 at 05:14:25PM +0100, Jiri Olsa escreveu:
> On Fri, Nov 23, 2018 at 02:42:39AM -0800, Eric Saint-Etienne wrote:
> > 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>
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

- Arnaldo
 
> thanks,
> jirka
> 
> > ---
> >  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
> > 

-- 

- Arnaldo

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

* [tip:perf/core] perf map: Remove extra indirection from map__find()
  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-12-14 20:20 ` tip-bot for Eric Saint-Etienne
  2018-12-18 13:47 ` tip-bot for Eric Saint-Etienne
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Eric Saint-Etienne @ 2018-12-14 20:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: alexander.shishkin, linux-kernel, namhyung, peterz, tglx, jolsa,
	eric.saint.etienne, eric.saintetienne, hpa, acme, mingo

Commit-ID:  97dfc3423ca701212802a02994d1ec3e688f4891
Gitweb:     https://git.kernel.org/tip/97dfc3423ca701212802a02994d1ec3e688f4891
Author:     Eric Saint-Etienne <eric.saint.etienne@oracle.com>
AuthorDate: Fri, 23 Nov 2018 02:42:39 -0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 29 Nov 2018 20:42:46 -0300

perf map: Remove extra indirection from map__find()

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>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Eric Saint-Etienne <eric.saintetienne@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1542969759-24346-1-git-send-email-eric.saint.etienne@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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 781eed8e3265..a0d58b4d9c32 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -873,19 +873,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;
 	}

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

* [tip:perf/core] perf map: Remove extra indirection from map__find()
  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-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
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Eric Saint-Etienne @ 2018-12-18 13:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: alexander.shishkin, jolsa, tglx, eric.saintetienne, hpa,
	namhyung, mingo, eric.saint.etienne, acme, peterz, linux-kernel

Commit-ID:  b18e088825883bcb8dc4c4a641494049cf8ccec3
Gitweb:     https://git.kernel.org/tip/b18e088825883bcb8dc4c4a641494049cf8ccec3
Author:     Eric Saint-Etienne <eric.saint.etienne@oracle.com>
AuthorDate: Fri, 23 Nov 2018 02:42:39 -0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 17 Dec 2018 14:53:57 -0300

perf map: Remove extra indirection from map__find()

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>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Eric Saint-Etienne <eric.saintetienne@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1542969759-24346-1-git-send-email-eric.saint.etienne@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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 781eed8e3265..a0d58b4d9c32 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -873,19 +873,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;
 	}

^ 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;
as well as URLs for NNTP newsgroup(s).