From patchwork Tue Oct 27 03:07:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 55580 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1535947lbq; Mon, 26 Oct 2015 20:08:29 -0700 (PDT) X-Received: by 10.50.4.65 with SMTP id i1mr24080640igi.0.1445915308913; Mon, 26 Oct 2015 20:08:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si18253022ioo.131.2015.10.26.20.08.28; Mon, 26 Oct 2015 20:08:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753543AbbJ0DI0 (ORCPT + 28 others); Mon, 26 Oct 2015 23:08:26 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:48010 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751594AbbJ0DIZ (ORCPT ); Mon, 26 Oct 2015 23:08:25 -0400 Received: from 172.24.1.49 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CVC52452; Tue, 27 Oct 2015 11:07:43 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Tue, 27 Oct 2015 11:07:33 +0800 From: Wang Nan To: , CC: , , , Wang Nan , Alexei Starovoitov , Brendan Gregg , Daniel Borkmann , David Ahern , He Kuang , Jiri Olsa , Kaixu Xia , Masami Hiramatsu , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH] perf tools: Allow BPF program attach to modules Date: Tue, 27 Oct 2015 03:07:28 +0000 Message-ID: <1445915248-175553-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <562EE139.8060500@huawei.com> References: <562EE139.8060500@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By extending the syntax of BPF object section names, this patch allows user to attach BPF programs to symbol in modules. For example: SEC("module=i915\n" "parse_cmds=i915_parse_cmds") int parse_cmds(void *ctx) { return 1; } Implementation is very simple: like what 'perf probe' does, for module, fill 'uprobe' field in 'struct perf_probe_event'. Other parts would be done automatically. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Cc: Arnaldo Carvalho de Melo Link: http://lkml.kernel.org/n/ebpf-x1mxko3tby054o573zd575qp@git.kernel.org --- This patch is based on commit ad14ba45236a496a7ce25f4ea947d245b1406e40 in my git tree[1], and will be appear in the next pull request of this perf eBPF support patchset. [1] https://git.kernel.org/cgit/linux/kernel/git/pi3orama/linux.git --- tools/perf/util/bpf-loader.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 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/ diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index b14aff4..a85caae 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -120,10 +120,17 @@ do_config(const char *key, const char *value, pev->target = strdup(value); return 0; } + if (strcmp(key, "module") == 0) { + pev->uprobes = false; + pev->target = strdup(value); + return 0; + } pr_warning("BPF: WARNING: invalid config option in object: %s=%s\n", key, value); - pr_warning("\tHint: Currently only valid option is 'exec='\n"); + pr_warning("\tHint: Currently valid options are:\n"); + pr_warning("\t 'exec='\n"); + pr_warning("\t 'module='\n"); return 0; }