[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1433829036-23687-26-git-send-email-wangnan0@huawei.com>
Date: Tue, 9 Jun 2015 05:50:29 +0000
From: Wang Nan <wangnan0@...wei.com>
To: <acme@...nel.org>, <ast@...mgrid.com>, <brendan.d.gregg@...il.com>,
<daniel@...earbox.net>, <namhyung@...nel.org>,
<masami.hiramatsu.pt@...achi.com>, <paulus@...ba.org>,
<a.p.zijlstra@...llo.nl>, <mingo@...hat.com>, <jolsa@...nel.org>,
<dsahern@...il.com>
CC: <linux-kernel@...r.kernel.org>, <lizefan@...wei.com>,
<hekuang@...wei.com>, <xiakaixu@...wei.com>, <pi3orama@....com>
Subject: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
perf_bpf_config() is added to parse 'bpf' section in perf config file.
Following is an example:
[bpf]
clang-path = /llvm/bin/x86_64-linux-clang"
llc-path = /llvm/bin/x86_64-linux-llc"
clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..."
llc-opt = ""
Error messages are updated to hint user about these options.
Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
tools/perf/util/bpf-loader.c | 24 +++++++++++++++++++++++-
tools/perf/util/bpf-loader.h | 1 +
tools/perf/util/config.c | 3 +++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index e5c03e9..f33fd47 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -8,6 +8,7 @@
#include <bpf/libbpf.h>
#include "perf.h"
#include "debug.h"
+#include "util.h"
#include "bpf-loader.h"
#define DEFINE_PRINT_FN(name, level) \
@@ -39,6 +40,25 @@ struct bpf_param bpf_param = {
.llc_opt = "",
};
+int perf_bpf_config(const char *var, const char *value)
+{
+ if (prefixcmp(var, "bpf."))
+ return 0;
+ var += sizeof("bpf.") - 1;
+
+ if (!strcmp(var, "clang-path"))
+ bpf_param.clang_path = strdup(value);
+ else if (!strcmp(var, "llc-path"))
+ bpf_param.llc_path = strdup(value);
+ else if (!strcmp(var, "clang-opt"))
+ bpf_param.clang_opt = strdup(value);
+ else if (!strcmp(var, "llc-opt"))
+ bpf_param.llc_opt = strdup(value);
+ else
+ return -1;
+ return 0;
+}
+
static int search_program(const char *def, const char *name,
char *output)
{
@@ -111,7 +131,8 @@ static int bpf__compile(const char *filename, void **p_obj_buf,
if (err) {
err = -ENOENT;
pr_err("Error:\tunable to find clang or llc in $PATH\n");
- pr_err("Hint:\tTry install LLVM with BPF backend.\n");
+ pr_err("Hint:\tTry install LLVM with BPF backend,\n");
+ pr_err(" \tthen setup [bpf.clang-path] and [bpf.llc-path] in ~/.perfconfig\n");
goto out;
}
@@ -175,6 +196,7 @@ static int bpf__compile(const char *filename, void **p_obj_buf,
err = -EINVAL;
pr_err("Error:\tsomething went wrong when compiling %s\n",
filename);
+ pr_err("Hint:\tTry to set correct [bpf.clang-opt] and [bpf.llc-opt] in ~/.perfconfig\n");
pr_err("Hint:\tTry manually run following command and check:\n");
pr_err(" # " CMD_FMT "\n\n",
clang_path, bpf_param.clang_opt, filename,
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index 5fd015c..edc211e 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -15,6 +15,7 @@ struct bpf_param {
const char *llc_opt;
};
extern struct bpf_param bpf_param;
+extern int perf_bpf_config(const char *var, const char *value);
#ifdef HAVE_LIBBPF_SUPPORT
int bpf__prepare_load(const char *filename, bool source);
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index e18f653..def2b59 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -12,6 +12,7 @@
#include "cache.h"
#include "exec_cmd.h"
#include "util/hist.h" /* perf_hist_config */
+#include "util/bpf-loader.h" /* perf_bpf_config */
#define MAXNAME (256)
@@ -408,6 +409,8 @@ int perf_default_config(const char *var, const char *value,
if (!prefixcmp(var, "call-graph."))
return perf_callchain_config(var, value);
+ if (!prefixcmp(var, "bpf."))
+ return perf_bpf_config(var, value);
/* Add other config variables here. */
return 0;
}
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists