mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
042a181086
commit
c2a218c63b
|
@ -6,6 +6,7 @@
|
||||||
* Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
|
* Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
#include "../perf.h"
|
#include "../perf.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
#include <subcmd/parse-options.h>
|
#include <subcmd/parse-options.h>
|
||||||
|
@ -63,14 +64,16 @@ static struct perf_event_attr cycle_attr = {
|
||||||
.config = PERF_COUNT_HW_CPU_CYCLES
|
.config = PERF_COUNT_HW_CPU_CYCLES
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_cycles(void)
|
static int init_cycles(void)
|
||||||
{
|
{
|
||||||
cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
|
cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
|
||||||
|
|
||||||
if (cycles_fd < 0 && errno == ENOSYS)
|
if (cycles_fd < 0 && errno == ENOSYS) {
|
||||||
die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
|
pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
|
||||||
else
|
return -1;
|
||||||
BUG_ON(cycles_fd < 0);
|
}
|
||||||
|
|
||||||
|
return cycles_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 get_cycles(void)
|
static u64 get_cycles(void)
|
||||||
|
@ -155,8 +158,13 @@ static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *
|
||||||
|
|
||||||
argc = parse_options(argc, argv, options, info->usage, 0);
|
argc = parse_options(argc, argv, options, info->usage, 0);
|
||||||
|
|
||||||
if (use_cycles)
|
if (use_cycles) {
|
||||||
init_cycles();
|
i = init_cycles();
|
||||||
|
if (i < 0) {
|
||||||
|
fprintf(stderr, "Failed to open cycles counter\n");
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size = (size_t)perf_atoll((char *)size_str);
|
size = (size_t)perf_atoll((char *)size_str);
|
||||||
size_total = (double)size * nr_loops;
|
size_total = (double)size * nr_loops;
|
||||||
|
|
Loading…
Reference in New Issue