From: Jiri Olsa <jolsa@redhat.com>
To: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Namhyung Kim <namhyung@kernel.org>,
Eric Saint-Etienne <eric.saintetienne@gmail.com>
Subject: Re: [PATCH] perf map: remove extra indirection from map__find()
Date: Fri, 23 Nov 2018 17:14:25 +0100 [thread overview]
Message-ID: <20181123161416.GB5575@krava> (raw)
In-Reply-To: <1542969759-24346-1-git-send-email-eric.saint.etienne@oracle.com>
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
>
next prev parent reply other threads:[~2018-11-23 16:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-23 10:42 [PATCH] perf map: remove extra indirection from map__find() Eric Saint-Etienne
2018-11-23 16:14 ` Jiri Olsa [this message]
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
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=20181123161416.GB5575@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eric.saint.etienne@oracle.com \
--cc=eric.saintetienne@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.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