mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Jin Yao <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, yao.jin@linux.intel.com, ak@linux.intel.com,
	acme@redhat.com, tglx@linutronix.de, mingo@kernel.org,
	linux-kernel@vger.kernel.org, jolsa@kernel.org,
	kan.liang@intel.com, alexander.shishkin@linux.intel.com,
	peterz@infradead.org
Subject: [tip:perf/core] perf rblist: Create rblist__exit() function
Date: Wed, 6 Dec 2017 08:36:56 -0800	[thread overview]
Message-ID: <tip-33fec3e393dc1c55737cfb9c876b5c0da0d6f380@git.kernel.org> (raw)
In-Reply-To: <1512125856-22056-2-git-send-email-yao.jin@linux.intel.com>

Commit-ID:  33fec3e393dc1c55737cfb9c876b5c0da0d6f380
Gitweb:     https://git.kernel.org/tip/33fec3e393dc1c55737cfb9c876b5c0da0d6f380
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 1 Dec 2017 18:57:25 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 5 Dec 2017 10:24:31 -0300

perf rblist: Create rblist__exit() function

Currently we have a rblist__delete() which is used to delete a rblist.
While rblist__delete() will free the pointer of rblist at the end.

It's an inconvenience for the user to delete a rblist which is not
allocated by something like malloc(). For example, the rblist is
embedded in a larger data structure.

This patch creates a new function rblist__exit() which is similar to
rblist__delete() but it will not free the pointer of rblist.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512125856-22056-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/rblist.c | 19 ++++++++++++-------
 tools/perf/util/rblist.h |  1 +
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c
index 0dfe27d..0efc325 100644
--- a/tools/perf/util/rblist.c
+++ b/tools/perf/util/rblist.c
@@ -101,16 +101,21 @@ void rblist__init(struct rblist *rblist)
 	return;
 }
 
+void rblist__exit(struct rblist *rblist)
+{
+	struct rb_node *pos, *next = rb_first(&rblist->entries);
+
+	while (next) {
+		pos = next;
+		next = rb_next(pos);
+		rblist__remove_node(rblist, pos);
+	}
+}
+
 void rblist__delete(struct rblist *rblist)
 {
 	if (rblist != NULL) {
-		struct rb_node *pos, *next = rb_first(&rblist->entries);
-
-		while (next) {
-			pos = next;
-			next = rb_next(pos);
-			rblist__remove_node(rblist, pos);
-		}
+		rblist__exit(rblist);
 		free(rblist);
 	}
 }
diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h
index 4c8638a..76df15c 100644
--- a/tools/perf/util/rblist.h
+++ b/tools/perf/util/rblist.h
@@ -29,6 +29,7 @@ struct rblist {
 };
 
 void rblist__init(struct rblist *rblist);
+void rblist__exit(struct rblist *rblist);
 void rblist__delete(struct rblist *rblist);
 int rblist__add_node(struct rblist *rblist, const void *new_entry);
 void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);

  reply	other threads:[~2017-12-06 16:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 10:57 [PATCH v5 00/12] perf stat: Enable '--per-thread' on all thread Jin Yao
2017-12-01 10:57 ` [PATCH v5 01/12] perf util: Create rblist__exit() function Jin Yao
2017-12-06 16:36   ` tip-bot for Jin Yao [this message]
2017-12-01 10:57 ` [PATCH v5 02/12] perf util: Define a structure for runtime shadow stats Jin Yao
2017-12-01 14:02   ` Arnaldo Carvalho de Melo
2017-12-02  4:39     ` Jin, Yao
2017-12-01 10:57 ` [PATCH v5 03/12] perf util: Extend rbtree to support " Jin Yao
2017-12-01 14:10   ` Arnaldo Carvalho de Melo
2017-12-02  4:40     ` Jin, Yao
2017-12-01 10:57 ` [PATCH v5 04/12] perf util: Add rbtree node_delete ops Jin Yao
2017-12-01 14:14   ` Arnaldo Carvalho de Melo
2017-12-01 18:29     ` Andi Kleen
2017-12-06 16:37   ` [tip:perf/core] perf stat: Add rbtree node_delete op tip-bot for Jin Yao
2017-12-01 10:57 ` [PATCH v5 05/12] perf util: Create the runtime_stat init/exit function Jin Yao
2017-12-01 10:57 ` [PATCH v5 06/12] perf util: Update and print per-thread shadow stats Jin Yao
2017-12-01 14:21   ` Arnaldo Carvalho de Melo
2017-12-02  4:46     ` Jin, Yao
2017-12-01 10:57 ` [PATCH v5 07/12] perf util: Remove a set of shadow stats static variables Jin Yao
2017-12-01 10:57 ` [PATCH v5 08/12] perf stat: Allocate shadow stats buffer for threads Jin Yao
2017-12-01 10:57 ` [PATCH v5 09/12] perf stat: Update or print per-thread stats Jin Yao
2017-12-01 10:57 ` [PATCH v5 10/12] perf util: Reuse thread_map__new_by_uid to enumerate threads from /proc Jin Yao
2017-12-01 14:44   ` Arnaldo Carvalho de Melo
2017-12-01 15:02     ` Arnaldo Carvalho de Melo
2017-12-02  4:53       ` Jin, Yao
2017-12-02  4:47     ` Jin, Yao
2017-12-01 10:57 ` [PATCH v5 11/12] perf stat: Remove --per-thread pid/tid limitation Jin Yao
2017-12-01 10:57 ` [PATCH v5 12/12] perf stat: Resort '--per-thread' result Jin Yao

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=tip-33fec3e393dc1c55737cfb9c876b5c0da0d6f380@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=yao.jin@linux.intel.com \
    /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

Powered by JetHome