From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbbCTVJQ (ORCPT ); Fri, 20 Mar 2015 17:09:16 -0400 Received: from smtprelay0149.hostedemail.com ([216.40.44.149]:48015 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751755AbbCTVJM (ORCPT ); Fri, 20 Mar 2015 17:09:12 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:967:973:988:989:1042:1260:1263:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2525:2538:2553:2560:2563:2682:2685:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3747:3865:3866:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:5007:6119:6120:6261:6742:7875:7901:7903:8660:9025:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12740:13019:13148:13149:13161:13229:13230:14096:14097:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: beef51_6cfd65d3abd34 X-Filterd-Recvd-Size: 3312 Date: Fri, 20 Mar 2015 17:09:07 -0400 From: Steven Rostedt To: Alexei Starovoitov Cc: Ingo Molnar , Namhyung Kim , Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , "David S. Miller" , Daniel Borkmann , Peter Zijlstra , linux-api@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 tip 3/9] tracing: attach BPF programs to kprobes Message-ID: <20150320170907.388d8c33@gandalf.local.home> In-Reply-To: <1426816787-5001-4-git-send-email-ast@plumgrid.com> References: <1426816787-5001-1-git-send-email-ast@plumgrid.com> <1426816787-5001-4-git-send-email-ast@plumgrid.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Mar 2015 18:59:41 -0700 Alexei Starovoitov wrote: Some nits... > --- /dev/null > +++ b/kernel/trace/bpf_trace.c > @@ -0,0 +1,123 @@ > +/* Copyright (c) 2011-2015 PLUMgrid, http://plumgrid.com > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of version 2 of the GNU General Public > + * License as published by the Free Software Foundation. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include "trace.h" > + > +static DEFINE_PER_CPU(int, bpf_prog_active); > + > +/** > + * trace_call_bpf - invoke BPF program > + * @prog - BPF program > + * @ctx - opaque context pointer > + * > + * kprobe handlers execute BPF programs via this helper. > + * Can be used from static tracepoints in the future. Should also state what the expected return values are. What does a return of "1" mean? > + */ > +unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx) > +{ > + unsigned int ret; > + > + if (in_nmi()) /* not supported yet */ > + return 1; > + > + preempt_disable(); > + > + if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) { > + /* since some bpf program is already running on this cpu, You are no longer in the net/ world. The rest of the Linux coding style is: /* * multi line comments */ Only DaveM gets away with that format ;-) > + * don't call into another bpf program (same or different) > + * and don't send kprobe event into ring-buffer, > + * so return zero here > + */ > + ret = 0; > + goto out; > + } > + > + rcu_read_lock(); > + ret = BPF_PROG_RUN(prog, ctx); > + rcu_read_unlock(); > + > + out: > + __this_cpu_dec(bpf_prog_active); > + preempt_enable(); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(trace_call_bpf); The rest looks fine. For that.. Reviewed-by: Steven Rostedt -- Steve