aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-17 15:38:01 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-19 00:03:40 -0500
commit5a8e5a3065bf04b7673262fd6c46123e4b888d2b (patch)
treeefd85b86b8904a2a551f603a45e3ec0199ec7539 /tools/perf
parent51a472decb845e920137284a5cfef51fb7d61206 (diff)
perf top: Allocate space only for the number of counters used
Reducing memory consumption on a typical desktop machine: From: 32710 root 20 0 172m 142m 1056 S 0.0 4.7 0:00.37 perf To: 420 root 20 0 47528 16m 1056 R 0.3 0.5 0:00.24 perf Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1258490282-1821-2-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-top.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0d60c517c0ba..49cf87680fe3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -111,7 +111,6 @@ static int display_weighted = -1;
111struct sym_entry { 111struct sym_entry {
112 struct rb_node rb_node; 112 struct rb_node rb_node;
113 struct list_head node; 113 struct list_head node;
114 unsigned long count[MAX_COUNTERS];
115 unsigned long snap_count; 114 unsigned long snap_count;
116 double weight; 115 double weight;
117 int skip; 116 int skip;
@@ -122,6 +121,7 @@ struct sym_entry {
122 struct source_line *lines; 121 struct source_line *lines;
123 struct source_line **lines_tail; 122 struct source_line **lines_tail;
124 pthread_mutex_t source_lock; 123 pthread_mutex_t source_lock;
124 unsigned long count[0];
125}; 125};
126 126
127/* 127/*
@@ -130,7 +130,7 @@ struct sym_entry {
130 130
131static inline struct symbol *sym_entry__symbol(struct sym_entry *self) 131static inline struct symbol *sym_entry__symbol(struct sym_entry *self)
132{ 132{
133 return (struct symbol *)(self + 1); 133 return ((void *)self) + symbol__priv_size;
134} 134}
135 135
136static void get_term_dimensions(struct winsize *ws) 136static void get_term_dimensions(struct winsize *ws)
@@ -1314,8 +1314,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1314{ 1314{
1315 int counter; 1315 int counter;
1316 1316
1317 symbol__init(sizeof(struct sym_entry));
1318
1319 page_size = sysconf(_SC_PAGE_SIZE); 1317 page_size = sysconf(_SC_PAGE_SIZE);
1320 1318
1321 argc = parse_options(argc, argv, options, top_usage, 0); 1319 argc = parse_options(argc, argv, options, top_usage, 0);
@@ -1332,6 +1330,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1332 if (!nr_counters) 1330 if (!nr_counters)
1333 nr_counters = 1; 1331 nr_counters = 1;
1334 1332
1333 symbol__init(sizeof(struct sym_entry) +
1334 (nr_counters + 1) * sizeof(unsigned long));
1335
1335 if (delay_secs < 1) 1336 if (delay_secs < 1)
1336 delay_secs = 1; 1337 delay_secs = 1;
1337 1338