From: tip-bot for David Ahern <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org,
eranian@google.com, hpa@zytor.com, mingo@kernel.org,
a.p.zijlstra@chello.nl, namhyung.kim@lge.com, jolsa@redhat.com,
fweisbec@gmail.com, dsahern@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf machine: Add method to loop over threads and invoke handler
Date: Mon, 14 Oct 2013 22:30:43 -0700 [thread overview]
Message-ID: <tip-35feee19f9fda7447f51073b5be3f6d082b508f5@git.kernel.org> (raw)
In-Reply-To: <1380395584-9025-2-git-send-email-dsahern@gmail.com>
Commit-ID: 35feee19f9fda7447f51073b5be3f6d082b508f5
Gitweb: http://git.kernel.org/tip/35feee19f9fda7447f51073b5be3f6d082b508f5
Author: David Ahern <dsahern@gmail.com>
AuthorDate: Sat, 28 Sep 2013 13:12:58 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 11 Oct 2013 12:17:51 -0300
perf machine: Add method to loop over threads and invoke handler
Loop over all threads within a machine - including threads moved to the
dead threads list -- and invoked a function.
This allows commands to run some specific function on each thread (eg.,
dump statistics) yet hides how the threads are maintained within the
machine.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1380395584-9025-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/machine.c | 23 +++++++++++++++++++++++
tools/perf/util/machine.h | 4 ++++
2 files changed, 27 insertions(+)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index fc14f9b..901397a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1393,3 +1393,26 @@ int machine__resolve_callchain(struct machine *machine,
sample);
}
+
+int machine__for_each_thread(struct machine *machine,
+ int (*fn)(struct thread *thread, void *p),
+ void *priv)
+{
+ struct rb_node *nd;
+ struct thread *thread;
+ int rc = 0;
+
+ for (nd = rb_first(&machine->threads); nd; nd = rb_next(nd)) {
+ thread = rb_entry(nd, struct thread, rb_node);
+ rc = fn(thread, priv);
+ if (rc != 0)
+ return rc;
+ }
+
+ list_for_each_entry(thread, &machine->dead_threads, node) {
+ rc = fn(thread, priv);
+ if (rc != 0)
+ return rc;
+ }
+ return rc;
+}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 5150d5e..d44c09b 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -166,4 +166,8 @@ void machines__destroy_kernel_maps(struct machines *machines);
size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
+int machine__for_each_thread(struct machine *machine,
+ int (*fn)(struct thread *thread, void *p),
+ void *priv);
+
#endif /* __PERF_MACHINE_H */
next prev parent reply other threads:[~2013-10-15 5:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-28 19:12 [PATCH 0/7] perf trace enhancements David Ahern
2013-09-28 19:12 ` [PATCH 1/7] perf util: Add machine method to loop over threads and invoke handler David Ahern
2013-10-15 5:30 ` tip-bot for David Ahern [this message]
2013-09-28 19:12 ` [PATCH 2/7] perf trace: Use new machine method to loop over threads David Ahern
2013-10-15 5:30 ` [tip:perf/core] " tip-bot for David Ahern
2013-09-28 19:13 ` [PATCH 3/7] perf trace: Fix comm resolution when reading events from file David Ahern
2013-10-15 5:30 ` [tip:perf/core] " tip-bot for David Ahern
2013-09-28 19:13 ` [PATCH 4/7] perf trace: Add record option David Ahern
2013-10-15 5:30 ` [tip:perf/core] " tip-bot for David Ahern
2013-09-28 19:13 ` [PATCH 5/7] perf util: Add priv variable to intlist David Ahern
2013-10-15 5:31 ` [tip:perf/core] perf intlist: Add priv member tip-bot for David Ahern
2013-09-28 19:13 ` [PATCH 6/7] perf util: Add findnew method to intlist David Ahern
2013-10-08 13:22 ` Arnaldo Carvalho de Melo
2013-09-28 19:13 ` [PATCH 7/7] perf trace: Add summary option to dump syscall statistics David Ahern
2013-10-08 1:44 ` [PATCH 0/7] perf trace enhancements David Ahern
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-35feee19f9fda7447f51073b5be3f6d082b508f5@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--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 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).