diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-26 12:27:23 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-26 12:28:40 -0400 |
commit | c2a218c63ba36946aca5943c0c8ebd3a42e3dc4b (patch) | |
tree | 1c428ee55eb4d9dc48e7026ad0841c519b016235 | |
parent | 042a181086077bdb83e38626b35fb96adbe45039 (diff) |
perf bench: Remove one more die() call
Propagate the error instead.
Cc: David Ahern <dsahern@gmail.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-z6erjg35d1gekevwujoa0223@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/bench/mem-functions.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c index a91aa85d80ff..2b54d0f2672a 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> | 6 | * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "debug.h" | ||
9 | #include "../perf.h" | 10 | #include "../perf.h" |
10 | #include "../util/util.h" | 11 | #include "../util/util.h" |
11 | #include <subcmd/parse-options.h> | 12 | #include <subcmd/parse-options.h> |
@@ -63,14 +64,16 @@ static struct perf_event_attr cycle_attr = { | |||
63 | .config = PERF_COUNT_HW_CPU_CYCLES | 64 | .config = PERF_COUNT_HW_CPU_CYCLES |
64 | }; | 65 | }; |
65 | 66 | ||
66 | static void init_cycles(void) | 67 | static int init_cycles(void) |
67 | { | 68 | { |
68 | cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag()); | 69 | cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag()); |
69 | 70 | ||
70 | if (cycles_fd < 0 && errno == ENOSYS) | 71 | if (cycles_fd < 0 && errno == ENOSYS) { |
71 | die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); | 72 | pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); |
72 | else | 73 | return -1; |
73 | BUG_ON(cycles_fd < 0); | 74 | } |
75 | |||
76 | return cycles_fd; | ||
74 | } | 77 | } |
75 | 78 | ||
76 | static u64 get_cycles(void) | 79 | static u64 get_cycles(void) |
@@ -155,8 +158,13 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info * | |||
155 | 158 | ||
156 | argc = parse_options(argc, argv, options, info->usage, 0); | 159 | argc = parse_options(argc, argv, options, info->usage, 0); |
157 | 160 | ||
158 | if (use_cycles) | 161 | if (use_cycles) { |
159 | init_cycles(); | 162 | i = init_cycles(); |
163 | if (i < 0) { | ||
164 | fprintf(stderr, "Failed to open cycles counter\n"); | ||
165 | return i; | ||
166 | } | ||
167 | } | ||
160 | 168 | ||
161 | size = (size_t)perf_atoll((char *)size_str); | 169 | size = (size_t)perf_atoll((char *)size_str); |
162 | size_total = (double)size * nr_loops; | 170 | size_total = (double)size * nr_loops; |