Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147695
b: refs/heads/master
c: 2f01190
h: refs/heads/master
i:
  147693: c4d7fc6
  147691: 6df842f
  147687: 1aa5ea5
  147679: 7d036f7
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Jun 7, 2009
1 parent f532117 commit a2b1964
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23b87116c7c4f73597965218b66041acbdb4e79f
refs/heads/master: 2f01190aa62fe9dd0a98205927b9f09fd191c017
22 changes: 17 additions & 5 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a2b1964

Please sign in to comment.