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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, 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 924B2C282C3 for ; Fri, 25 Jan 2019 00:05:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 607D4218A6 for ; Fri, 25 Jan 2019 00:05:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XzA0hE0Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbfAYAFU (ORCPT ); Thu, 24 Jan 2019 19:05:20 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46957 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726015AbfAYAFU (ORCPT ); Thu, 24 Jan 2019 19:05:20 -0500 Received: by mail-pf1-f196.google.com with SMTP id c73so3803692pfe.13 for ; Thu, 24 Jan 2019 16:05:19 -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=zIY0Fw4TzGScBtr2brLKCTxU8f9h7Jw5T+3RWnjnE68=; b=XzA0hE0YPiOaI7/4HyB1cS9Q3rp9Z7HYD2Ya6qsS7BvANnVQiZmgXrUxD+LKw0CgBR q93IJ6RlqUT5oiKX+3oa56adUCyPHbkidh3SKuodOZjx3ufG+apP+jQAXodRcrveVUn9 rPCuIzWCVCsPdO3nMSyI5YP4mmXB2aZrJzrtGIRSxdjFTiqQt68y7ULfAyShV2lmGH4K IXKJfrSWKW0rOQ8izmLhjNJ4LcOdbfKP3o+QGYNJBMJ8z/5xT2KSm6Tqpde5dzcU5Ot0 HsMjuehkDIqaMh/wJ6FxcTlYllkiUxd4i50SX6BEBzPO5fOy//XJ8dIOLlaIFuRNuI3m IPJw== 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=zIY0Fw4TzGScBtr2brLKCTxU8f9h7Jw5T+3RWnjnE68=; b=fMyh5jxEHE2RiGnZKzYshmfG8QN9ikA7uAJ7CueG4omu6dxSE58m5j3b86VevolQ1N xNVKwvbWNk2RnMMAqU1/JXLQ2JriCchwczWu4Hi8k8OaEbu+Sa413OoNmS17UyRA+sxC 6NY83xSIFYV2BE0/RiXUh/ygTcMOcWpUzTKNL9ZljDo8JlzLm1Qs9X56vN+gx6D5D92R 9WjDWGH5xLPv/rDjBXWbIZecchinNwKStJSqBrlMB/E6g3YHqOjNo/VfL8vun+rtQjqI FNhJY+rh29mGTm6KPq1O5B231BZgJPzfrsswlAXfJXncMIRBC27KwRmsQ6H0BmFPCkAN GEnA== X-Gm-Message-State: AJcUukdzbDjHgBfgl6PEBh/aYolvGHxBgmHasSbNj8tcNtdLLiJ5wj+l +d1JkxfWRCFa/YwKuR7ff7s= X-Google-Smtp-Source: ALg8bN5mfhFbGIhKxWbEotJmjyiqdIIEjijsPj70BDS50KT6DpgNUWmyxUPAzl3AVx7ErXrkJ7FzGw== X-Received: by 2002:a62:8985:: with SMTP id n5mr8715229pfk.255.1548374719129; Thu, 24 Jan 2019 16:05:19 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:200::7:5429]) by smtp.gmail.com with ESMTPSA id c72sm45625418pfb.107.2019.01.24.16.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 16:05:18 -0800 (PST) Date: Thu, 24 Jan 2019 16:05:16 -0800 From: Alexei Starovoitov To: "Paul E. McKenney" Cc: Peter Zijlstra , 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, jannh@google.com Subject: Re: [PATCH v4 bpf-next 1/9] bpf: introduce bpf_spin_lock Message-ID: <20190125000515.jizijxz4n735gclx@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> <20190124185652.GB17767@hirez.programming.kicks-ass.net> <20190124234232.GY4240@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190124234232.GY4240@linux.ibm.com> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jan 24, 2019 at 03:42:32PM -0800, Paul E. McKenney wrote: > On Thu, Jan 24, 2019 at 07:56:52PM +0100, Peter Zijlstra wrote: > > On Thu, Jan 24, 2019 at 07:01:09PM +0100, Peter Zijlstra wrote: > > > > > > Thanks for having kernel/locking people on Cc... > > > > > > On Wed, Jan 23, 2019 at 08:13:55PM -0800, Alexei Starovoitov wrote: > > > > > > > Implementation details: > > > > - on !SMP bpf_spin_lock() becomes nop > > > > > > Because no BPF program is preemptible? I don't see any assertions or > > > even a comment that says this code is non-preemptible. > > > > > > AFAICT some of the BPF_RUN_PROG things are under rcu_read_lock() only, > > > which is not sufficient. > > > > > > > - on architectures that don't support queued_spin_lock trivial lock is used. > > > > Note that arch_spin_lock cannot be used, since not all archs agree that > > > > zero == unlocked and sizeof(arch_spinlock_t) != sizeof(__u32). > > > > > > I really don't much like direct usage of qspinlock; esp. not as a > > > surprise. > > Substituting the lightweight-reader SRCU as discussed earlier would allow > use of a more generic locking primitive, for example, one that allowed > blocking, at least in cases were the context allowed this. > > git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git > branch srcu-lr.2019.01.16a. > > One advantage of a more generic locking primitive would be keeping BPF > programs independent of internal changes to spinlock primitives. Let's keep "srcu in bpf" discussion separate from bpf_spin_lock discussion. bpf is not switching to srcu any time soon. If/when it happens it will be only for certain prog+map types like bpf syscall probes that need to be able to do copy_from_user from bpf prog.