[PATCH 31/46] perf hists: Do not allocate space for callchains for evsels without them

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

This is another case were a big switch for callchains,
symbol_conf.use_callchain, is inconvenient, as we can have both events
with and without callchains, no point in checking a single switch to
decide to allocate space for callchains.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-62q64m7x7kqpb4g7boqc2...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/hist.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 34864c87cd3c..496913eeed75 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -461,14 +461,19 @@ static struct hist_entry *hist_entry__new(struct 
hist_entry *template,
  bool sample_self)
 {
struct hist_entry_ops *ops = template->ops;
+   struct perf_evsel *evsel = hists_to_evsel(template->hists);
size_t callchain_size = 0;
struct hist_entry *he;
int err = 0;
 
if (!ops)
ops = template->ops = _ops;
-
-   if (symbol_conf.use_callchain)
+   /*
+* It is possible to have callchains for some evsels but not for others,
+* e.g.:  'perf record -e cycles,cache-misses/max-stack=10/', so lets
+* not waste space for that.
+*/
+   if (symbol_conf.use_callchain && evsel__has_callchain(evsel))
callchain_size = sizeof(struct callchain_root);
 
he = ops->new(callchain_size);
-- 
2.14.3



[PATCH 31/46] perf hists: Do not allocate space for callchains for evsels without them

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

This is another case were a big switch for callchains,
symbol_conf.use_callchain, is inconvenient, as we can have both events
with and without callchains, no point in checking a single switch to
decide to allocate space for callchains.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-62q64m7x7kqpb4g7boqc2...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/hist.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 34864c87cd3c..496913eeed75 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -461,14 +461,19 @@ static struct hist_entry *hist_entry__new(struct 
hist_entry *template,
  bool sample_self)
 {
struct hist_entry_ops *ops = template->ops;
+   struct perf_evsel *evsel = hists_to_evsel(template->hists);
size_t callchain_size = 0;
struct hist_entry *he;
int err = 0;
 
if (!ops)
ops = template->ops = _ops;
-
-   if (symbol_conf.use_callchain)
+   /*
+* It is possible to have callchains for some evsels but not for others,
+* e.g.:  'perf record -e cycles,cache-misses/max-stack=10/', so lets
+* not waste space for that.
+*/
+   if (symbol_conf.use_callchain && evsel__has_callchain(evsel))
callchain_size = sizeof(struct callchain_root);
 
he = ops->new(callchain_size);
-- 
2.14.3