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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 4576AC07E9C for ; Mon, 5 Jul 2021 16:12:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26ECA6108B for ; Mon, 5 Jul 2021 16:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbhGEQOp (ORCPT ); Mon, 5 Jul 2021 12:14:45 -0400 Received: from ale.deltatee.com ([204.191.154.188]:40548 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbhGEQOo (ORCPT ); Mon, 5 Jul 2021 12:14:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=Q3YIK3t9z+fN5nGyXTdIuXppJPkxUCeL7c4AVzJi+kY=; b=l6HJ3DnwxZZU6aKXCzjaIRSBsT LbVWl7FbsPNed0mxfaZYeSjZ9c+8xrk+2OoGr0VRbICRVllqYNWNz6P3qI5F5Hbi/yJzxfC6qaXyS yOyg762Y2AC2DmygosBJ8ljHE2PFFwpGB/NqLv0FdY9n0GHIea2PFxVbdRewWp5Qfaxpo0Ckd70t3 /05fNLEg6T9pgswty+tL7OVFlueljO2/Vpr0wEVGZWABzpXmcDWH2YSCi2mFUZjSKnh1DHadyrHNn JevsJ05ol0XwIxSLUv8X+oEfgDo9iidMUv0OITntKJuyIGvU4cnVPujmsLdCwWSMDnvqww98+xxsN vOlYnjhA==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1m0RCQ-0002b1-IF; Mon, 05 Jul 2021 10:12:01 -0600 To: Eric Dumazet , Bjorn Helgaas Cc: linux-kernel , Eric Dumazet , Dan Williams , Ira Weiny , Christoph Hellwig , Greg Kroah-Hartman , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Rafael J. Wysocki" , linux-pci@vger.kernel.org References: <20210701095621.3129283-1-eric.dumazet@gmail.com> From: Logan Gunthorpe Message-ID: <986ec985-a42c-9107-564d-5878a669388b@deltatee.com> Date: Mon, 5 Jul 2021 10:11:55 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210701095621.3129283-1-eric.dumazet@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: linux-pci@vger.kernel.org, rafael@kernel.org, jglisse@redhat.com, gregkh@linuxfoundation.org, hch@lst.de, ira.weiny@intel.com, dan.j.williams@intel.com, edumazet@google.com, linux-kernel@vger.kernel.org, bhelgaas@google.com, eric.dumazet@gmail.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH] PCI/P2PDMA: finish RCU conversion of pdev->p2pdma X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-07-01 3:56 a.m., Eric Dumazet wrote: > From: Eric Dumazet > > While looking at pci_alloc_p2pmem() I found rcu protection > was not properly applied there, as pdev->p2pdma was > potentially read multiple times. > > I decided to fix pci_alloc_p2pmem(), add __rcu qualifier > to p2pdma field of struct pci_dev, and fix all > other accesses to this field with proper rcu verbs. > > Fixes: 1570175abd16 ("PCI/P2PDMA: track pgmap references per resource, not globally") > Signed-off-by: Eric Dumazet > Cc: Dan Williams > Cc: Ira Weiny > Cc: Logan Gunthorpe > Cc: Bjorn Helgaas > Cc: Christoph Hellwig > Cc: Greg Kroah-Hartman > Cc: "Jérôme Glisse" > Cc: "Rafael J. Wysocki" > Cc: linux-pci@vger.kernel.org Reviewed-by: Logan Gunthorpe For history, though, Dan had originally suggested the full RCU protection is not necessary and it was only a barrier to force the NULL check on teardown to resolve: https://lore.kernel.org/nvdimm/CAPcyv4jZiK+OHjwNqDARv4g326AQZx7N_Lmxj1Zux_bX1T2CLQ@mail.gmail.com/ Things may have changed since then and other uses might be racing with the teardown, so having it marked __rcu and fully protected sounds like a good idea to me. Logan