From: Robert Richter Date: Thu, 5 Apr 2012 16:26:28 +0000 (+0200) Subject: perf record: Use sw counter only if hw pmu is not detected X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5a7ed29;p=linux-beck.git perf record: Use sw counter only if hw pmu is not detected Use cpu-clock-tick sw counter for cpu-cycles only if there is no hw pmu available. This is the case if the syscall reports ENOENT. In other cases (e.g. invalid attributes) we don't want the sw counter to be used. Cc: Ingo Molnar Link: http://lkml.kernel.org/r/1333643188-26895-5-git-send-email-robert.richter@amd.com Signed-off-by: Robert Richter Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index be4e1eee782e..10b1f1f25ed7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -245,7 +245,7 @@ try_again: * based cpu-clock-tick sw counter, which * is always available even if no PMU support: */ - if (attr->type == PERF_TYPE_HARDWARE + if (err == ENOENT && attr->type == PERF_TYPE_HARDWARE && attr->config == PERF_COUNT_HW_CPU_CYCLES) { if (verbose)