Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932943AbbFIFyp (ORCPT ); Tue, 9 Jun 2015 01:54:45 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:40910 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932260AbbFIFvd (ORCPT ); Tue, 9 Jun 2015 01:51:33 -0400 From: Wang Nan To: , , , , , , , , , , CC: , , , , Subject: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config Date: Tue, 9 Jun 2015 05:50:29 +0000 Message-ID: <1433829036-23687-26-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1433829036-23687-1-git-send-email-wangnan0@huawei.com> References: <1433829036-23687-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.55767ED7.0138,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 88327d39d3251d362a2ad6a526d209ba Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3724 Lines: 115 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 --- 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 #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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/