Skip to content

Commit 0fd112e

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf_counter tools: remove glib dependency and fix bugs in kerneltop.c, fix poll()
Paul Mackerras wrote: > I noticed the poll stuff is bogus - we have a 2D array of struct > pollfds (MAX_NR_CPUS x MAX_COUNTERS), we fill in a sub-array (with the > rest being uninitialized, since the array is on the stack) and then > pass the first nr_cpus elements to poll. Not what we really meant, I > suspect. :) Not even if we only have one counter, since it's the > counter dimension that varies fastest. This should fix the most obvious poll fubar.. not enough to fix the full problem though.. Reported-by: Paul Mackerras <[email protected]> Reported-by: Mike Galbraith <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Cc: Arjan van de Ven <[email protected]> Orig-LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent cbe4655 commit 0fd112e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Documentation/perf_counter/kerneltop.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,10 +1157,10 @@ static void mmap_read(struct mmap_data *md)
11571157

11581158
int main(int argc, char *argv[])
11591159
{
1160-
struct pollfd event_array[MAX_NR_CPUS][MAX_COUNTERS];
1160+
struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
11611161
struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
11621162
struct perf_counter_hw_event hw_event;
1163-
int i, counter, group_fd;
1163+
int i, counter, group_fd, nr_poll = 0;
11641164
unsigned int cpu;
11651165
int ret;
11661166

@@ -1214,8 +1214,9 @@ int main(int argc, char *argv[])
12141214
if (group && group_fd == -1)
12151215
group_fd = fd[i][counter];
12161216

1217-
event_array[i][counter].fd = fd[i][counter];
1218-
event_array[i][counter].events = POLLIN;
1217+
event_array[nr_poll].fd = fd[i][counter];
1218+
event_array[nr_poll].events = POLLIN;
1219+
nr_poll++;
12191220

12201221
mmap_array[i][counter].counter = counter;
12211222
mmap_array[i][counter].prev = 0;
@@ -1247,7 +1248,7 @@ int main(int argc, char *argv[])
12471248
}
12481249

12491250
if (hits == events)
1250-
ret = poll(event_array[0], nr_cpus, 1000);
1251+
ret = poll(event_array, nr_poll, 1000);
12511252
hits = events;
12521253
}
12531254

0 commit comments

Comments
 (0)