Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932947AbbKMPkU (ORCPT ); Fri, 13 Nov 2015 10:40:20 -0500 Received: from mail.kernel.org ([198.145.29.136]:51931 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932567AbbKMPkT (ORCPT ); Fri, 13 Nov 2015 10:40:19 -0500 Date: Fri, 13 Nov 2015 12:40:14 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: masami.hiramatsu.pt@hitachi.com, ast@kernel.org, lizefan@huawei.com, pi3orama@163.com, linux-kernel@vger.kernel.org, Brendan Gregg , Daniel Borkmann , David Ahern , He Kuang , Jiri Olsa , Kaixu Xia , Namhyung Kim , Paul Mackerras , Peter Zijlstra Subject: Re: [PATCH 04/12] perf tools: Allow BPF program attach to modules Message-ID: <20151113154014.GK7160@kernel.org> References: <1447417761-156094-1-git-send-email-wangnan0@huawei.com> <1447417761-156094-5-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447417761-156094-5-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2355 Lines: 80 Em Fri, Nov 13, 2015 at 12:29:13PM +0000, Wang Nan escreveu: > 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(+) > > 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; > +} check strdup return > + > 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, > + } Named initializers, please. > }; > > static int > -- > 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/