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=-3.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_NEOMUTT 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 A34FEC169C4 for ; Wed, 30 Jan 2019 02:20:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FBF72175B for ; Wed, 30 Jan 2019 02:20:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L9tWuiB3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbfA3CUS (ORCPT ); Tue, 29 Jan 2019 21:20:18 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36197 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfA3CUR (ORCPT ); Tue, 29 Jan 2019 21:20:17 -0500 Received: by mail-pf1-f194.google.com with SMTP id b85so10666189pfc.3 for ; Tue, 29 Jan 2019 18:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4J58J8+8gjcDG5dOLXYivyo/f53BPoYeqphNmwAZOi4=; b=L9tWuiB3sEqIBW9ls9zJ5YZBLgA2YDyjvwc0+/pBpO4WJdhSFd1QxzrE2NzW4Go1bc pau/GMcMENZ/QlV/PJ3LZsxhyFd8vshLzsd0YL+iyDYZ1XBJ9CafccTTRE/DuODBIDGz 3OqPoZfUGDRJL6ly4if3rsp5AXHctZnCJmdnzidRlGtvwA0chJID5FiZVEoTKhM3F/S3 A4NxI9Uo0ZYq5ETT1kReXlaS3Pq92uEvRNUALhK94SXvOzqCggmk3Up8zH3UlgQFB408 g93ihL/Vt0UJ6mFkuWmkq+JaZp+mF/USVUd/jZGXDZLxHiIxFC1DZt+nI3lbtUovM5KK OhuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4J58J8+8gjcDG5dOLXYivyo/f53BPoYeqphNmwAZOi4=; b=AyEPB40KZ62D5bsX6ggIzXV08EmCWUehqfdT6ChuIq/LoLR+VSX/f97FTNhxyjt6g4 Z89f3YFxQtKGAJgs1KyArT0VoYgvOQ5l5sIY8OJJ3gdajRVHShuxM5mQBfrYUzFQ8F59 sCjYlnsh+Qb4lbJdOyc5udmdXxfuJqmw4V9qNm2e/5788PHVGpjnypRPt4cXggKX+jMq mU8rafBZmETEyhnlYX6Y+0Fz8p1N5dTimkjuIEujT/B33LkMITfvuZl9a5PejAslVMis UFzUq8oUh9ln9Lbxxs6qS4AMq535WHqYp9wFm7qF8Ldfg14Pm45W5ATV6yGsltljh6LW vMMQ== X-Gm-Message-State: AJcUukck8OTSvg059mEwJWtN8vO2TSKN2D/AMFQxYFFxFMXu3mGA2xFY weU6SEtbEtg08rttvccFH5U= X-Google-Smtp-Source: ALg8bN5Ne5dkY36kI0fYiYhfua2rwRbHU6NXmwx/7BYOt+BNVo+Z/WQ8aSM9rZbHyXFoWvQadOeteg== X-Received: by 2002:a62:a510:: with SMTP id v16mr28510005pfm.18.1548814816695; Tue, 29 Jan 2019 18:20:16 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:200::5:6f31]) by smtp.gmail.com with ESMTPSA id 12sm137416pgt.33.2019.01.29.18.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 18:20:15 -0800 (PST) Date: Tue, 29 Jan 2019 18:20:14 -0800 From: Alexei Starovoitov To: Peter Zijlstra 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: <20190130022012.suxxs4h4z5qfbrdf@ast-mbp.dhcp.thefacebook.com> 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> <20190128084310.GC28467@hirez.programming.kicks-ass.net> <20190128213710.vjxnc2eq5rsisgfx@ast-mbp> <20190129085903.GC28485@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190129085903.GC28485@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Jan 29, 2019 at 09:59:03AM +0100, Peter Zijlstra wrote: > On Mon, Jan 28, 2019 at 01:37:12PM -0800, Alexei Starovoitov wrote: > > On Mon, Jan 28, 2019 at 09:43:10AM +0100, Peter Zijlstra wrote: > > > > Isn't that still broken? AFAIU networking progs can happen in task > > > context (TX) and SoftIRQ context (RX), which can nest. > > > > Sure. sendmsg side of networking can be interrupted by napi receive. > > Both can have bpf progs attached at different points, but napi won't run > > when bpf prog is running, because bpf prog disables preemption. > > Disabling preemption is not sufficient, it needs to have done > local_bh_disable(), which isn't unlikely given this is all networking > code. right. excellent point. Since bh is not disabled nesting of the sender side socket filter is possible with receive side socket filter. Theoretically the same socket filter prog can be nested. I believe it's fine with the current state of things including parrallel access to bpf maps (my patch to add preempt_disable around socket filter is still needed). But this point regarding local_bh_disable changes the plans for bpf_spin_lock. We'd need local_bh_disable around socket filters and around syscall access to map with 'struct bpf_spin_lock' or two new helpers bpf_spin_lock_irqsave and corresponding verifier support. I guess we'll argue about best option when that time comes. For now there will be no bpf_spin_lock in socket filters and I need to add local_bh_disable for syscall access to maps with bpf_spin_lock to avoid deadlock. I'll send a set of fixes for lockdep false positives and respin bpf_spin_lock set.