All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Alex Snast <asnast@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH 1/2] perf tools: Use postorder rbtree iteration when removing symbols
Date: Sun, 20 Sep 2015 10:05:20 +0200	[thread overview]
Message-ID: <20150920080519.GA8234@gmail.com> (raw)
In-Reply-To: <1442667815-10749-1-git-send-email-asnast@gmail.com>


* Alex Snast <asnast@gmail.com> wrote:

> Avoid using rb_erase when removing symbols as it requires rbtree
> rebalancing, instead preform a post order iteration when deleting tree
> symbols.
> 
> Signed-off-by: Alex Snast <asnast@gmail.com>
> ---
>  tools/include/linux/rbtree.h | 14 ++++++++++++++
>  tools/perf/util/symbol.c     | 11 ++++-------
>  2 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/include/linux/rbtree.h b/tools/include/linux/rbtree.h
> index 1125822..14c646d 100644
> --- a/tools/include/linux/rbtree.h
> +++ b/tools/include/linux/rbtree.h
> @@ -90,6 +90,20 @@ static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
>  	   ____ptr ? rb_entry(____ptr, type, member) : NULL; \
>  	})
>  
> +/**
> + * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
> + * given type safe against removal of rb_node entry
> + *
> + * @pos:	the 'type *' to use as a loop cursor.
> + * @n:		another 'type *' to use as temporary storage
> + * @root:	'rb_root *' of the rbtree.
> + * @field:	the name of the rb_node field within 'type'.
> + */
> +#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
> +	for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), field); \
> +	     pos && ({ n = rb_entry_safe(rb_next_postorder(&pos->field), \
> +			typeof(*pos), field); 1; }); \
> +	     pos = n)

So looks like this is something that include/linux/rbtree.h already has, right?

I think we should strive to match the two implementations and generate a build 
time warning (but not a build time failure) if the two diverge.

There were checking facilities added recently for another kernel source code file, 
to make sure tools/perf/util/intel-pt-decoder/insn.c matches arch/x86/lib/insn.c.

Btw., side note, regarding insn.c, the remaining delta between the two files:

-#include <asm/inat.h>
-#include <asm/insn.h>
+#include "inat.h"
+#include "insn.h"

should be eliminated too I think, to make it more obvious when the two versions 
match.

Thanks,

	Ingo

  parent reply	other threads:[~2015-09-20  8:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-19 13:03 [PATCH 1/2] perf tools: Use postorder rbtree iteration when removing symbols Alex Snast
2015-09-19 13:03 ` [PATCH 2/2] perf tools: Use rb_entry_safe on first / next symbol lookup Alex Snast
2015-09-20  8:05 ` Ingo Molnar [this message]
     [not found]   ` <CAMqsXBcZAS6hCh8LdHjFGiji8dwHLQus1xf5OnK7CZEjrbx33w@mail.gmail.com>
2015-09-21  7:17     ` [PATCH 1/2] perf tools: Use postorder rbtree iteration when removing symbols 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=20150920080519.GA8234@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=asnast@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.