Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+15 -7
+15 -7
tools/perf/bench/mem-functions.c
··· 6 6 * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> 7 7 */ 8 8 9 + #include "debug.h" 9 10 #include "../perf.h" 10 11 #include "../util/util.h" 11 12 #include <subcmd/parse-options.h> ··· 64 63 .config = PERF_COUNT_HW_CPU_CYCLES 65 64 }; 66 65 67 - static void init_cycles(void) 66 + static int init_cycles(void) 68 67 { 69 68 cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag()); 70 69 71 - if (cycles_fd < 0 && errno == ENOSYS) 72 - die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); 73 - else 74 - BUG_ON(cycles_fd < 0); 70 + if (cycles_fd < 0 && errno == ENOSYS) { 71 + pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); 72 + return -1; 73 + } 74 + 75 + return cycles_fd; 75 76 } 76 77 77 78 static u64 get_cycles(void) ··· 158 155 159 156 argc = parse_options(argc, argv, options, info->usage, 0); 160 157 161 - if (use_cycles) 162 - init_cycles(); 158 + if (use_cycles) { 159 + i = init_cycles(); 160 + if (i < 0) { 161 + fprintf(stderr, "Failed to open cycles counter\n"); 162 + return i; 163 + } 164 + } 163 165 164 166 size = (size_t)perf_atoll((char *)size_str); 165 167 size_total = (double)size * nr_loops;