From patchwork Fri Nov 13 12:29:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 56512 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1008047lbb; Fri, 13 Nov 2015 04:32:53 -0800 (PST) X-Received: by 10.66.168.171 with SMTP id zx11mr31280622pab.125.1447417973093; Fri, 13 Nov 2015 04:32:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jw6si27227596pbc.214.2015.11.13.04.32.52; Fri, 13 Nov 2015 04:32:53 -0800 (PST) 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 S932799AbbKMMcv (ORCPT + 28 others); Fri, 13 Nov 2015 07:32:51 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:24839 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754887AbbKMMcs (ORCPT ); Fri, 13 Nov 2015 07:32:48 -0500 Received: from 172.24.1.47 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BQY85703; Fri, 13 Nov 2015 20:29:47 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Fri, 13 Nov 2015 20:29:35 +0800 From: Wang Nan To: , , CC: , , , Wang Nan , Brendan Gregg , Daniel Borkmann , David Ahern , "He Kuang" , Jiri Olsa , Kaixu Xia , Namhyung Kim , Paul Mackerras , Peter Zijlstra , "Arnaldo Carvalho de Melo" Subject: [PATCH 04/12] perf tools: Allow BPF program attach to modules Date: Fri, 13 Nov 2015 12:29:13 +0000 Message-ID: <1447417761-156094-5-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1447417761-156094-1-git-send-email-wangnan0@huawei.com> References: <1447417761-156094-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5645D82B.02D5, 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: 15438a032a251c4648cd0d84bcc464fb 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/1445915248-175553-1-git-send-email-wangnan0@huawei.com --- tools/perf/util/bpf-loader.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 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 5f5505d..8d78785 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -117,6 +117,14 @@ config__exec(const char *value, struct perf_probe_event *pev) return 0; } +static int +config__module(const char *value, struct perf_probe_event *pev) +{ + pev->uprobes = false; + pev->target = strdup(value); + return 0; +} + static struct { const char *key; const char *usage; @@ -129,6 +137,12 @@ static struct { "Set uprobe target", config__exec, }, + { + "module", + "module= ", + "Set kprobe module", + config__module, + } }; static int