From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20160C282C8 for ; Mon, 28 Jan 2019 08:25:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DDBE02148E for ; Mon, 28 Jan 2019 08:25:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GJdNBMpt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbfA1IZS (ORCPT ); Mon, 28 Jan 2019 03:25:18 -0500 Received: from merlin.infradead.org ([205.233.59.134]:60998 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726681AbfA1IZS (ORCPT ); Mon, 28 Jan 2019 03:25:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=veSeiRz5l/KpGqOZ9DqugHMVqU+NZ6bbIBdk4N8ouOg=; b=GJdNBMptcu0B5ZYma5xYlK4aC ErfsVA70CHylQ1qfbr4r+yt3K9aojUo061/2JnnMkdFxCiT/u+AT7G+dbRg0Lvh6f2/xrhFiFMQW6 UJkXeZ9W7vUwreIfZK8+pMKF0pP0EA+qXP5VbotxmCdWrdhVau+wG1vA4yHSOqF3XVEYwv0Cddt27 1M20nQwMi7kAiTMYR6jc2X3O7pKVtmmmVyNzeY4DQtBn7Rh4M7KX2LudK7dchxPsFTsz4lUfkHp7i JesxQZOltzOWLMAkrq7MjI90vNvODIvdcaYrgdLmKLzA0PJifbK8SBjzQxktk9+jDjb9h7r0mbc5T wP/RCFpIg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1go2Dv-0005aE-CD; Mon, 28 Jan 2019 08:24:55 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3956920101B8D; Mon, 28 Jan 2019 09:24:52 +0100 (CET) Date: Mon, 28 Jan 2019 09:24:52 +0100 From: Peter Zijlstra To: Alexei Starovoitov Cc: Alexei Starovoitov , davem@davemloft.net, daniel@iogearbox.net, jakub.kicinski@netronome.com, netdev@vger.kernel.org, kernel-team@fb.com, mingo@redhat.com, will.deacon@arm.com, Paul McKenney , jannh@google.com Subject: Re: [PATCH v4 bpf-next 1/9] bpf: introduce bpf_spin_lock Message-ID: <20190128082452.GA28467@hirez.programming.kicks-ass.net> References: <20190124041403.2100609-1-ast@kernel.org> <20190124041403.2100609-2-ast@kernel.org> <20190124180109.GA27771@hirez.programming.kicks-ass.net> <20190124235857.xyb5xx2ufr6x5mbt@ast-mbp.dhcp.thefacebook.com> <20190125091057.GK17749@hirez.programming.kicks-ass.net> <20190125234241.soomtkrgp2i7m7ul@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190125234241.soomtkrgp2i7m7ul@ast-mbp.dhcp.thefacebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Jan 25, 2019 at 03:42:43PM -0800, Alexei Starovoitov wrote: > On Fri, Jan 25, 2019 at 10:10:57AM +0100, Peter Zijlstra wrote: > > Do we want something like (the completely untested) below to avoid > > having to manually audit this over and over? > > > > --- > > include/linux/filter.h | 2 +- > > include/linux/kernel.h | 9 +++++++-- > > kernel/sched/core.c | 28 ++++++++++++++++++++++++++++ > > 3 files changed, 36 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/filter.h b/include/linux/filter.h > > index d531d4250bff..4ab51e78da36 100644 > > --- a/include/linux/filter.h > > +++ b/include/linux/filter.h > > @@ -513,7 +513,7 @@ struct sk_filter { > > struct bpf_prog *prog; > > }; > > > > -#define BPF_PROG_RUN(filter, ctx) (*(filter)->bpf_func)(ctx, (filter)->insnsi) > > +#define BPF_PROG_RUN(filter, ctx) ({ cant_sleep(); (*(filter)->bpf_func)(ctx, (filter)->insnsi); }) > > That looks reasonable and I intent to apply this patch to bpf-next after testing. > Can you pls reply with a sob ? Sure; with the caveat that I didn't even hold it near a compiler, and it probably should grow a comment to explain the interface (similar to might_sleep): Suggested-by: Jann Horn Signed-off-by: Peter Zijlstra (Intel) > The easiest fix is to add preempt_disable/enable for socket filters. > There is a concern that such fix will make classic bpf non-preemptable > and classic bpf can be quite cpu expensive. > Also on the receive side classic runs in bh, so 4k flow_dissector calls > in classic has to be dealt with anyway. Right and agreed; per that argument the worst case (legacy) BPF was already present under non-preempt and thus making it consistently so should not affect the worst case.