Skip to content

Commit d8871ea

Browse files
WangNan0acmel
authored andcommitted
perf record: Use WARN_ONCE to replace 'if' condition
Commits in a BPF patchkit will extract kernel and module synthesizing code into a separated function and call it multiple times. This patch replace 'if (err < 0)' using WARN_ONCE, makes sure the error message show one time. Signed-off-by: Wang Nan <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: He Kuang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Li Zefan <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Zefan Li <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f8dd2d5 commit d8871ea

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tools/perf/builtin-record.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "util/parse-regs-options.h"
3434
#include "util/llvm-utils.h"
3535
#include "util/bpf-loader.h"
36+
#include "asm/bug.h"
3637

3738
#include <unistd.h>
3839
#include <sched.h>
@@ -615,17 +616,15 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
615616

616617
err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
617618
machine);
618-
if (err < 0)
619-
pr_err("Couldn't record kernel reference relocation symbol\n"
620-
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
621-
"Check /proc/kallsyms permission or run as root.\n");
619+
WARN_ONCE(err < 0, "Couldn't record kernel reference relocation symbol\n"
620+
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
621+
"Check /proc/kallsyms permission or run as root.\n");
622622

623623
err = perf_event__synthesize_modules(tool, process_synthesized_event,
624624
machine);
625-
if (err < 0)
626-
pr_err("Couldn't record kernel module information.\n"
627-
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
628-
"Check /proc/modules permission or run as root.\n");
625+
WARN_ONCE(err < 0, "Couldn't record kernel module information.\n"
626+
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
627+
"Check /proc/modules permission or run as root.\n");
629628

630629
if (perf_guest) {
631630
machines__process_guests(&session->machines,

0 commit comments

Comments
 (0)