Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp723112ybm; Fri, 29 May 2020 10:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMWzOF1Hw5IJ3DmOEWJBdnhXJH7i/S6Qs7mePVM5mfexItY0hPkvFjZ/4S2s/eqz1zs2C+ X-Received: by 2002:a17:907:392:: with SMTP id ss18mr9056636ejb.156.1590773649581; Fri, 29 May 2020 10:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590773649; cv=none; d=google.com; s=arc-20160816; b=k2m1DIIirYBE81Vtc7K8Ux7z8oahwcBifwL3pMGRpXzNkawMS9dGiYp5w3u6+0nlRG 2XzcF2nnYoXB2zEGe6G9j3COrSr13OJlXIEsvDh4GSMskFuYwI/Hq4ADsUWuvpmDXNLY mup6PTTZxVruadFYr2Ip+TQ2WQFCHbB/irnm6ZTCuXTE/qLlowBy6xLuG5E3cMOWbvyB StgR4VMK2FbZuuS1ovOXFJ9xX2+aH516Hw43nZYNMUoHaBf+NonpNjNzmKqqAw3qzOLX GEL9EOB1pAYDRgTRweZu+0bOXpZBEhjlOsjuUo2LV56incSJIlOmr7OhemQXYH5OWgBJ r1fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5QAaubCrSkbMtN2AeIrJ/eYnjpFRXFZ0sKgmmAcHtXo=; b=kXsIzbRQ+3kzfUn1ULhjHahtj0UUOlBcx2kVTejcNX9T94jXeSdjoMZP8HRIJ+g+le h1NK2PB3eb5gQqpF8lzyr0oNzEpuF7FO/eugHSgfMumO2UEC94zLnR2PKcfBUlwG998K dN90zA14fXkbu1av5BD23XpD27tksR8/RW3/jMPq17n1zcF0OOIQo3QLQEQ5HpMZlWZz 7RIHfersMtZyNEKsKnMugYf3BXolhprnoEge92An9UClPwtr7Tyiq+PVvon+K3sc4i62 1QE1C+kPZLmTyCeBfqIamEL81ilzFeSQrjBr6010keuuQlrQ6QO6dIGBcEALW3qM8tS2 Qphw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=ArfyHqMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si6143662edv.448.2020.05.29.10.33.46; Fri, 29 May 2020 10:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=ArfyHqMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbgE2Rbd (ORCPT + 99 others); Fri, 29 May 2020 13:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbgE2RXF (ORCPT ); Fri, 29 May 2020 13:23:05 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E3CC03E969 for ; Fri, 29 May 2020 10:23:03 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id c14so1872881qka.11 for ; Fri, 29 May 2020 10:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5QAaubCrSkbMtN2AeIrJ/eYnjpFRXFZ0sKgmmAcHtXo=; b=ArfyHqMUwzGeH73k2mBJsFUozWtJpj5oE8H9B7d7NEfa1b3Y64UjetLoU1oWDOLJCJ rF3mfwv/zQIH7hznhfFML65UdVKly2VQMoDIfNyLVqGvta7AXIc8vcbmi0FOkkI1osCr tGh1IJNnVkRi9HzqZ6D49ebWEAk3OHrSOggRA= 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; bh=5QAaubCrSkbMtN2AeIrJ/eYnjpFRXFZ0sKgmmAcHtXo=; b=XksW8AoG0aZnNHD8MvxCPBYO3k7bG2x8GlXOgVZxWv6kzPeDEqFowhSkgrjo8lLXfm q3095en6iYTMBuffhVTFCZjYDw0v8IqBWAm2AZG6WyGlPRrnuQdVjA6tzU42YQsNVcx4 4b17rmMtcY4jZZm8w9aE9C5nXamPCIV5q0CjqihQqAmRd0/RVVpoZkpwSqxcONfZturt 8pa48yVBX8YaKYAVEBbzMzaZsYYVM50y5JXvAcQxwiekJmw1iiB30N80i1PcZ/i0UL77 Xv9pu1nfYDJFxZHStUTopXQ92tJgedsxsfjc8LMohzeyVQMzhogYQvySD5vxysXpNFnF Cycg== X-Gm-Message-State: AOAM530T37yM5VipkT5V62Vtlfc//ooo+GtEaHRpGOs02j8XeYe6hnmn 26dzY0A1FXAqorv3X03oF928sOhJImk= X-Received: by 2002:a37:5ce:: with SMTP id 197mr8515029qkf.334.1590772982379; Fri, 29 May 2020 10:23:02 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id h5sm7408513qkk.108.2020.05.29.10.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 10:23:01 -0700 (PDT) Date: Fri, 29 May 2020 13:23:01 -0400 From: Joel Fernandes To: Andrii Nakryiko Cc: Boqun Feng , Andrii Nakryiko , "Paul E . McKenney" , Alan Stern , Peter Zijlstra , parri.andrea@gmail.com, will@kernel.org, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, Akira Yokosawa , dlustig@nvidia.com, open list , linux-arch@vger.kernel.org Subject: Re: Some -serious- BPF-related litmus tests Message-ID: <20200529172301.GB196085@google.com> References: <20200522003850.GA32698@paulmck-ThinkPad-P72> <20200522094407.GK325280@hirez.programming.kicks-ass.net> <20200522143201.GB32434@rowland.harvard.edu> <20200522174352.GJ2869@paulmck-ThinkPad-P72> <006e2bc6-7516-1584-3d8c-e253211c157e@fb.com> <20200525145325.GB2066@tardis> <20200528214823.GA211369@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 09:38:35PM -0700, Andrii Nakryiko wrote: > On Thu, May 28, 2020 at 2:48 PM Joel Fernandes wrote: > > > > On Mon, May 25, 2020 at 11:38:23AM -0700, Andrii Nakryiko wrote: > > > On Mon, May 25, 2020 at 7:53 AM Boqun Feng wrote: > > > > > > > > Hi Andrii, > > > > > > > > On Fri, May 22, 2020 at 12:38:21PM -0700, Andrii Nakryiko wrote: > > > > > On 5/22/20 10:43 AM, Paul E. McKenney wrote: > > > > > > On Fri, May 22, 2020 at 10:32:01AM -0400, Alan Stern wrote: > > > > > > > On Fri, May 22, 2020 at 11:44:07AM +0200, Peter Zijlstra wrote: > > > > > > > > On Thu, May 21, 2020 at 05:38:50PM -0700, Paul E. McKenney wrote: > > > > > > > > > Hello! > > > > > > > > > > > > > > > > > > Just wanted to call your attention to some pretty cool and pretty serious > > > > > > > > > litmus tests that Andrii did as part of his BPF ring-buffer work: > > > > > > > > > > > > > > > > > > https://lore.kernel.org/bpf/20200517195727.279322-3-andriin@fb.com/ > > > > > > > > > > > > > > > > > > Thoughts? > > > > > > > > > > > > > > > > I find: > > > > > > > > > > > > > > > > smp_wmb() > > > > > > > > smp_store_release() > > > > > > > > > > > > > > > > a _very_ weird construct. What is that supposed to even do? > > > > > > > > > > > > > > Indeed, it looks like one or the other of those is redundant (depending > > > > > > > on the context). > > > > > > > > > > > > Probably. Peter instead asked what it was supposed to even do. ;-) > > > > > > > > > > I agree, I think smp_wmb() is redundant here. Can't remember why I thought > > > > > that it's necessary, this algorithm went through a bunch of iterations, > > > > > starting as completely lockless, also using READ_ONCE/WRITE_ONCE at some > > > > > point, and settling on smp_read_acquire/smp_store_release, eventually. Maybe > > > > > there was some reason, but might be that I was just over-cautious. See reply > > > > > on patch thread as well ([0]). > > > > > > > > > > [0] https://lore.kernel.org/bpf/CAEf4Bza26AbRMtWcoD5+TFhnmnU6p5YJ8zO+SoAJCDtp1jVhcQ@mail.gmail.com/ > > > > > > > > > > > > > While we are at it, could you explain a bit on why you use > > > > smp_store_release() on consumer_pos? I ask because IIUC, consumer_pos is > > > > only updated at consumer side, and there is no other write at consumer > > > > side that we want to order with the write to consumer_pos. So I fail > > > > to find why smp_store_release() is necessary. > > > > > > > > I did the following modification on litmus tests, and I didn't see > > > > different results (on States) between two versions of litmus tests. > > > > > > > > > > This is needed to ensure that producer can reliably detect whether it > > > needs to trigger poll notification. > > > > Boqun's question is on the consumer side though. Are you saying that on the > > consumer side, the loads prior to the smp_store_release() on the consumer > > side should have been seen by the consumer? You are already using > > smp_load_acquire() so that should be satisified already because the > > smp_load_acquire() makes sure that the smp_load_acquire()'s happens before > > any future loads and stores. > > Consumer is reading two things: producer_pos and each record's length > header, and writes consumer_pos. I re-read this paragraph many times, > but I'm still a bit confused on what exactly you are trying to say. This is what I was saying in the other thread. I think you missed that comment. If you are adding litmus documentation, at least it should be clear what memory ordering is being verified. Both me and Boqun tried to remove a memory barrier each and the test still passes. So what exactly are you verifying from a memory consistency standpoint? I know you have those various rFail things and conditions - but I am assuming the goal here is to verify memory consistency as well. Or are we just throwing enough memory barriers at the problem to make sure the test passes, without understanding exactly what ordering is needed? > Can you please specify in each case release()/acquire() of which > variable you are talking about? I don't want to speculate and confuse the thread more. I am afraid the burden of specifying what the various release/acquire orders is on the author of the code introducing the memory barriers ;-). That is, IMHO you should probably add code comments in the test about why a certain memory barrier is needed. That said, I need to do more diligence and read the actual BPF ring buffer code to understand what you're modeling. I will try to make time to do that. thanks! - Joel