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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 01EF0C742C7 for ; Fri, 12 Jul 2019 15:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF6C2208E4 for ; Fri, 12 Jul 2019 15:32:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="WhHL4nEa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727060AbfGLPcp (ORCPT ); Fri, 12 Jul 2019 11:32:45 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:42204 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbfGLPcp (ORCPT ); Fri, 12 Jul 2019 11:32:45 -0400 Received: by mail-qt1-f196.google.com with SMTP id h18so8469284qtm.9 for ; Fri, 12 Jul 2019 08:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6zUuNAxC0W8UA4PyJfN+NTLv2uHwtQW0uxPeJFySWhY=; b=WhHL4nEaSeEd0vRZOuyDcURKZ0cIDxWXvxDZbS9TJi+X/uea1BzMCjEV3BPQDBS7kF Dpkkz2XDk8Cq31X6ysMikLsVpO4/A6/XX+9SpUG+W1O09Ph1QgZt6F95E72Jvv5xOz7E q7g3yVOFNmZDNJiyrLb7uSW1KGLl0Q1+OFgPCeLMQs4aOOlyJ3DLJmK3xFUpVrkpjcsB QQY6IbgORFPsALQkh8diwYLGK2Iijn5DUi7LcqCzPyJj5Pixni0GPZh99oEQHA9a1HDc QuLsPci3N/i5e6QkqSbRmroGlDOqP8DKDJE1pkprzCZ4CQ2YDpVXaUlmhimtsJwtsYcH a6bA== 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=6zUuNAxC0W8UA4PyJfN+NTLv2uHwtQW0uxPeJFySWhY=; b=UmXGdEGHfMixbIsJyZ+5BxQfTxvxvNY2V9Fc1QzEotKi+1Zj1QjW6M2DPinzyqjSfD TaaDz9wL8rYcNpNYIv5Ao14rugQgiblkSTYJZeKKj/Euczo2OZ7sv8ZxdrzRHqftIqrj 5wvg6J28TRjrBNEZ7KlQ0ionCTYlRslgZ4hAUwrLTb99vxl2VWLvWuv8u2SIT90vyqYZ 4c8Lzpp3GtHWHecOWwURvYlXxt1WG/b8sxCkiToDHeIoxiUDy570boIZKi3hG3ccta9u nWzg88hVhxZeJ9KFAFLNG+zIyo8pNXZCU8CyUmjpCDNf7c08ET1bSJGHnuxC1bWJUDMT qyWA== X-Gm-Message-State: APjAAAUVN6Nj0yfZOlaR9GiqUlZ/qFJFM2EW2jkat5XiEnGcL0RN23BV PeeH13Apl8V8BtBuYkjiTLRUtw== X-Google-Smtp-Source: APXvYqzEwIAjKS3Em026GIl/n6OaECDF5z0P7UjmcJEJgVEtwMvAC0d3LOiyLBn306FibVuHBvyEHQ== X-Received: by 2002:ac8:444c:: with SMTP id m12mr6913649qtn.306.1562945564475; Fri, 12 Jul 2019 08:32:44 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id v75sm4201337qka.38.2019.07.12.08.32.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2019 08:32:44 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hlxXP-0002Tp-KZ; Fri, 12 Jul 2019 12:32:43 -0300 Date: Fri, 12 Jul 2019 12:32:43 -0300 From: Jason Gunthorpe To: Bernard Metzler Cc: Arnd Bergmann , Doug Ledford , Peter Zijlstra , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Re: Re: Re: [PATCH] rdma/siw: avoid smp_store_mb() on a u64 Message-ID: <20190712153243.GI27512@ziepe.ca> References: <20190712144257.GE27512@ziepe.ca> <20190712135339.GC27512@ziepe.ca> <20190712120328.GB27512@ziepe.ca> <20190712085212.3901785-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 03:24:09PM +0000, Bernard Metzler wrote: > > >To: "Bernard Metzler" > >From: "Jason Gunthorpe" > >Date: 07/12/2019 04:43PM > >Cc: "Arnd Bergmann" , "Doug Ledford" > >, "Peter Zijlstra" , > >linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org > >Subject: [EXTERNAL] Re: Re: Re: [PATCH] rdma/siw: avoid > >smp_store_mb() on a u64 > > > >On Fri, Jul 12, 2019 at 02:35:50PM +0000, Bernard Metzler wrote: > > > >> >This looks wrong to me.. a userspace notification re-arm cannot be > >> >lost, so have a split READ/TEST/WRITE sequence can't possibly > >work? > >> > > >> >I'd expect an atomic test and clear here? > >> > >> We cannot avoid the case that the application re-arms the > >> CQ only after a CQE got placed. That is why folks are polling the > >> CQ once after re-arming it - to make sure they do not miss the > >> very last and single CQE which would have produced a CQ event. > > > >That is different, that is re-arm happing after a CQE placement and > >this can't be fixed. > > > >What I said is that a re-arm from userspace cannot be lost. So you > >can't blindly clear the arm flag with the WRITE_ONCE. It might be OK > >beacuse of the if, but... > > > >It is just goofy to write it without a 'test and clear' atomic. If > >the > >writer side consumes the notify it should always be done atomically. > > > Hmmm, I don't yet get why we should test and clear atomically, if we > clear anyway - is it because we want to avoid clearing a re-arm which > happens just after testing and before clearing? It is just clearer as to the intent.. Are you trying to optimize away an atomic or something? That might work better as a dual counter scheme. > Another complication -- test_and_set_bit() operates on a single > bit, but we have to test two bits, and reset both, if one is > set. Why are two bits needed to represent armed and !armed? Jason