From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Frederic Weisbecker <fweisbeec@gmail.com>
Subject: [PATCH] perf-top: Wait for a minimal set of events before reading first snapshot
Date: Sat, 6 Jun 2009 23:10:43 +0200 [thread overview]
Message-ID: <1244322643-6447-1-git-send-email-fweisbec@gmail.com> (raw)
The first snapshot reading often occur before any events have been
read in the mapped perfcounter files.
Just wait until we have at least one event before starting the
snapshot, or the delay before the first set of entries to be
displayed may be long in case of low refresh rate.
Note: we could also use a semaphore to wait before "print_entries"
number of eveents is reached, but again this value is tunable
and we can't ensure we will even reach it. Also we could base
on a default mimimum set of entries for the first refresh, say 15,
but again, the minimal sample is tunable, and we could end up
displaying nothing until we have a minimal default set of events,
which can take some time in case of high samples filters.
Hence this simple solution which partially covers the default case.
[ Impact: display first events once they are available on perf top ]
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbeec@gmail.com>
---
tools/perf/builtin-top.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index f2e7312..fdc1d58 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -420,7 +420,7 @@ static unsigned int mmap_read_head(struct mmap_data *md)
struct timeval last_read, this_read;
-static void mmap_read(struct mmap_data *md)
+static void mmap_read_counter(struct mmap_data *md)
{
unsigned int head = mmap_read_head(md);
unsigned int old = md->prev;
@@ -517,6 +517,16 @@ static void mmap_read(struct mmap_data *md)
static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
+static void mmap_read(void)
+{
+ int i, counter;
+
+ for (i = 0; i < nr_cpus; i++) {
+ for (counter = 0; counter < nr_counters; counter++)
+ mmap_read_counter(&mmap_array[i][counter]);
+ }
+}
+
static int __cmd_top(void)
{
struct perf_counter_attr *attr;
@@ -571,6 +581,11 @@ static int __cmd_top(void)
}
}
+ /* Wait for a minimal set of events before starting the snapshot */
+ poll(event_array, nr_poll, 100);
+
+ mmap_read();
+
if (pthread_create(&thread, NULL, display_thread, NULL)) {
printf("Could not create display thread.\n");
exit(-1);
@@ -589,10 +604,7 @@ static int __cmd_top(void)
while (1) {
int hits = samples;
- for (i = 0; i < nr_cpus; i++) {
- for (counter = 0; counter < nr_counters; counter++)
- mmap_read(&mmap_array[i][counter]);
- }
+ mmap_read();
if (hits == samples)
ret = poll(event_array, nr_poll, 100);
--
1.6.2.3
next reply other threads:[~2009-06-06 21:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-06 21:10 Frederic Weisbecker [this message]
2009-06-07 7:36 ` [tip:perfcounters/core] perf top: " 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=1244322643-6447-1-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=efault@gmx.de \
--cc=fweisbeec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@redhat.com \
--cc=paulus@samba.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
all inboxes | Powered by JetHome®