Skip to contentSkip to conversation

perf top: fix segfault

tip:perfcounters/core tip-bot for Mike Galbraith 1 participant 1 message May 24, 2009 Documentation

lore
Share & tools
lore
#0 lore raw
Commit-ID:  c2990a2a582d73562d4dcf2502c39892a19a691d
Gitweb:     http://git.kernel.org/tip/c2990a2a582d73562d4dcf2502c39892a19a691d
Author:     Mike Galbraith <[email protected]>
AuthorDate: Sun, 24 May 2009 08:35:49 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 24 May 2009 08:57:08 +0200

perf top: fix segfault

c6eb13 increased stack usage such that perf-top now croaks on startup.

Take event_array and mmap_array off the stack to prevent segfault on boxen with smallish ulimit -s setting.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc John Kacur <[email protected]>

LKML-Reference: <new-submission>

---
 Documentation/perf_counter/builtin-top.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Documentation/perf_counter/builtin-top.c +3 -2
index a3216a6..74021ac 100644
@@ -1035,10 +1035,11 @@ static void mmap_read(struct mmap_data *md)
 	md->prev = old;
 }
 
+static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
+static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
+
 int cmd_top(int argc, char **argv, const char *prefix)
 {
-	struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
-	struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
 	struct perf_counter_hw_event hw_event;
 	pthread_t thread;
 	int i, counter, group_fd, nr_poll = 0;