Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934624AbbEOIP2 (ORCPT ); Fri, 15 May 2015 04:15:28 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:14459 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934436AbbEOIPM (ORCPT ); Fri, 15 May 2015 04:15:12 -0400 From: Wang Nan To: , , , , , , , , , , , CC: , , , Subject: [RFC PATCH v2 33/37] tools perf bpf: load eBPF object into kernel. Date: Fri, 15 May 2015 07:51:26 +0000 Message-ID: <1431676290-1230-34-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1431676290-1230-1-git-send-email-wangnan0@huawei.com> References: <1431676290-1230-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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1852 Lines: 72 This patch utilizes bpf_load_object() provided by libbpf to load all objects into kernel. Signed-off-by: Wang Nan --- tools/perf/builtin-bpf.c | 5 +++++ tools/perf/util/bpf-loader.c | 16 ++++++++++++++++ tools/perf/util/bpf-loader.h | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-bpf.c b/tools/perf/builtin-bpf.c index 95e0c65..8155f39 100644 --- a/tools/perf/builtin-bpf.c +++ b/tools/perf/builtin-bpf.c @@ -162,6 +162,11 @@ static int cmd_bpf_record(int argc, const char **argv, goto errout; } + if (bpf_load()) { + pr_err("bpf: failed to load\n"); + goto errout; + } + return start_bpf_record(argc, argv); usage: usage_with_options(bpf_record_usage, options); diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index c820d1a..7295a3b 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -214,3 +214,19 @@ int bpf_probe(void) return err < 0 ? err : 0; } + +int bpf_load(void) +{ + size_t i; + int err; + + for (i = 0; i < params.nr_objects; i++) { + err = bpf_load_object(params.objects[i]); + if (err) { + pr_err("failed to load object\n"); + return err; + } + } + + return 0; +} diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 30dea2e..1ccebdf 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -9,7 +9,8 @@ int bpf_prepare_load(const char *filename); int bpf_probe(void); -int bpf_unprobe(void); +int bpf_load(void); +int bpf_unprobe(void); void bpf_clear(void); #endif -- 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/