All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Frederic Weisbecker <fweisbec@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com,
	mingo@redhat.com, fweisbec@gmail.com, peterz@infradead.org,
	tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perfcounters/core] perf tools: Librarize idle thread registration
Date: Mon, 31 Aug 2009 08:37:18 GMT	[thread overview]
Message-ID: <tip-5b447a6a13ea823b698bf4c01193654fd7ebf4ec@git.kernel.org> (raw)
In-Reply-To: <1251693921-6579-1-git-send-email-fweisbec@gmail.com>

Commit-ID:  5b447a6a13ea823b698bf4c01193654fd7ebf4ec
Gitweb:     http://git.kernel.org/tip/5b447a6a13ea823b698bf4c01193654fd7ebf4ec
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Mon, 31 Aug 2009 06:45:18 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 31 Aug 2009 10:04:48 +0200

perf tools: Librarize idle thread registration

Librarize register_idle_thread() used by annotate and report.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <1251693921-6579-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 tools/perf/builtin-annotate.c |   13 +------------
 tools/perf/builtin-report.c   |   32 +++++++++++++++-----------------
 tools/perf/util/thread.c      |   13 +++++++++++++
 tools/perf/util/thread.h      |    2 ++
 4 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 4c7bc44..043d85b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -472,17 +472,6 @@ static void output__resort(void)
 	}
 }
 
-static void register_idle_thread(void)
-{
-	struct thread *thread = threads__findnew(0, &threads, &last_match);
-
-	if (thread == NULL ||
-			thread__set_comm(thread, "[idle]")) {
-		fprintf(stderr, "problem inserting idle task.\n");
-		exit(-1);
-	}
-}
-
 static unsigned long total = 0,
 		     total_mmap = 0,
 		     total_comm = 0,
@@ -970,7 +959,7 @@ static int __cmd_annotate(void)
 	uint32_t size;
 	char *buf;
 
-	register_idle_thread();
+	register_idle_thread(&threads, &last_match);
 
 	input = open(input_name, O_RDONLY);
 	if (input < 0) {
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index cdd46ab..cdf9a8d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -666,12 +666,9 @@ static void dso__calc_col_width(struct dso *self)
 	self->slen_calculated = 1;
 }
 
-static int thread__set_comm_adjust(struct thread *self, const char *comm)
+static void thread__comm_adjust(struct thread *self)
 {
-	int ret = thread__set_comm(self, comm);
-
-	if (ret)
-		return ret;
+	char *comm = self->comm;
 
 	if (!col_width_list_str && !field_sep &&
 	    (!comm_list || strlist__has_entry(comm_list, comm))) {
@@ -682,6 +679,16 @@ static int thread__set_comm_adjust(struct thread *self, const char *comm)
 			threads__col_width = slen + 6;
 		}
 	}
+}
+
+static int thread__set_comm_adjust(struct thread *self, const char *comm)
+{
+	int ret = thread__set_comm(self, comm);
+
+	if (ret)
+		return ret;
+
+	thread__comm_adjust(self);
 
 	return 0;
 }
@@ -1073,17 +1080,6 @@ print_entries:
 	return ret;
 }
 
-static void register_idle_thread(void)
-{
-	struct thread *thread = threads__findnew(0, &threads, &last_match);
-
-	if (thread == NULL ||
-			thread__set_comm_adjust(thread, "[idle]")) {
-		fprintf(stderr, "problem inserting idle task.\n");
-		exit(-1);
-	}
-}
-
 static unsigned long total = 0,
 		     total_mmap = 0,
 		     total_comm = 0,
@@ -1381,11 +1377,13 @@ static int __cmd_report(void)
 	unsigned long offset = 0;
 	unsigned long head, shift;
 	struct stat input_stat;
+	struct thread *idle;
 	event_t *event;
 	uint32_t size;
 	char *buf;
 
-	register_idle_thread();
+	idle = register_idle_thread(&threads, &last_match);
+	thread__comm_adjust(idle);
 
 	if (show_threads)
 		perf_read_values_init(&show_threads_values);
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index f98032c..3acd37f 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -80,6 +80,19 @@ threads__findnew(pid_t pid, struct rb_root *threads, struct thread **last_match)
 	return th;
 }
 
+struct thread *
+register_idle_thread(struct rb_root *threads, struct thread **last_match)
+{
+	struct thread *thread = threads__findnew(0, threads, last_match);
+
+	if (!thread || thread__set_comm(thread, "[idle]")) {
+		fprintf(stderr, "problem inserting idle task.\n");
+		exit(-1);
+	}
+
+	return thread;
+}
+
 void thread__insert_map(struct thread *self, struct map *map)
 {
 	struct map *pos, *tmp;
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index b1c6671..634f280 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -13,6 +13,8 @@ struct thread {
 int thread__set_comm(struct thread *self, const char *comm);
 struct thread *
 threads__findnew(pid_t pid, struct rb_root *threads, struct thread **last_match);
+struct thread *
+register_idle_thread(struct rb_root *threads, struct thread **last_match);
 void thread__insert_map(struct thread *self, struct map *map);
 int thread__fork(struct thread *self, struct thread *parent);
 struct map *thread__find_map(struct thread *self, u64 ip);

  reply	other threads:[~2009-08-31  8:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31  1:32 [PATCH] perf tools: Add missing parameters documentation Frederic Weisbecker
2009-08-31  4:45 ` [PATCH 1/4] perf tools: Librarize idle thread registration Frederic Weisbecker
2009-08-31  8:37   ` tip-bot for Frederic Weisbecker [this message]
2009-08-31  4:45 ` [PATCH 2/4] perf tools: Resolve idle thread cmdline for perf trace Frederic Weisbecker
2009-08-31  8:37   ` [tip:perfcounters/core] " tip-bot for Frederic Weisbecker
2009-08-31  4:45 ` [PATCH 3/4] perf tools: Unify swapper tasks naming Frederic Weisbecker
2009-08-31  4:52   ` Frederic Weisbecker
2009-08-31  8:37   ` [tip:perfcounters/core] " tip-bot for Frederic Weisbecker
2009-08-31  4:45 ` [PATCH 4/4] perf tools: Complete support for dynamic strings Frederic Weisbecker
2009-08-31  8:11   ` Ingo Molnar
2009-08-31 16:59     ` Frederic Weisbecker
2009-09-03 16:13       ` Ingo Molnar
2009-08-31  8:37   ` [tip:perfcounters/core] " tip-bot for Frederic Weisbecker
2009-08-31  8:37 ` [tip:perfcounters/core] perf tools: Add missing parameters documentation tip-bot for Frederic Weisbecker

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-5b447a6a13ea823b698bf4c01193654fd7ebf4ec@git.kernel.org \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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.