perf evsel: Handle ENOMEM for perf_event_max_stack + PERF_SAMPLE_CALLCHAIN
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Apr 2016 20:51:45 +0000 (17:51 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 Apr 2016 12:58:58 +0000 (09:58 -0300)
commitde46d5268c4ec5c5b473c96fbf56ece188a6ba85
treeec43e9d2bc049dc14ca6906128e05b8c110389ec
parent1a71476e4f2693ed93523c80ff1e2d4a8634717c
perf evsel: Handle ENOMEM for perf_event_max_stack + PERF_SAMPLE_CALLCHAIN

When the kernel allows tweaking perf_event_max_stack and the event being
setup has PERF_SAMPLE_CALLCHAIN in its perf_event_attr.sample_type, tell
the user that tweaking /proc/sys/kernel/perf_event_max_stack may solve
the problem.

Before:

  # echo 32000 > /proc/sys/kernel/perf_event_max_stack
  # perf record -g usleep 1
  Error:
  The sys_perf_event_open() syscall returned with 12 (Cannot allocate memory) for event (cycles:ppp).
  /bin/dmesg may provide additional information.
  No CONFIG_PERF_EVENTS=y kernel support configured?

  #

After:

  # echo 64000 > /proc/sys/kernel/perf_event_max_stack
  # perf record -g usleep 1
  Error:
  Not enough memory to setup event with callchain.
  Hint: Try tweaking /proc/sys/kernel/perf_event_max_stack
  Hint: Current value: 64000
  #

Suggested-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ebv0orelj1s1ye857vhb82ov@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c