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.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E63DEC2BA19 for ; Tue, 14 Apr 2020 19:06:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9E3B52082E for ; Tue, 14 Apr 2020 19:06:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="bOkEv+1t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E3B52082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4B3BD8E0006; Tue, 14 Apr 2020 15:06:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43CB48E0001; Tue, 14 Apr 2020 15:06:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32B958E0006; Tue, 14 Apr 2020 15:06:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 0FC468E0001 for ; Tue, 14 Apr 2020 15:06:24 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A8E5F181AEF21 for ; Tue, 14 Apr 2020 19:06:23 +0000 (UTC) X-FDA: 76707391446.24.bit65_1aaf809f47939 X-HE-Tag: bit65_1aaf809f47939 X-Filterd-Recvd-Size: 4906 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 19:06:23 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id m67so14510928qke.12 for ; Tue, 14 Apr 2020 12:06:23 -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=kecgSrOyjcStfXPghMK6SzkzEVdVsqes3tfF9y2jXlE=; b=bOkEv+1t1+HuXCMyXbGYxfFtEqJ+NbCQPE3goSDOBRgg4hNu8GdpT9EiB/WRao0s7M fJk16f85uhlJcB/K0hcO9PcMH/simleg+MmPQLGYQxR7ZFz5175w7NuhkowUZlmKu9wd nKil+jfbGKS870CAMNSY1PKFajTBU3jhtdpIPbiJhCZSxJn5QwUBVqnUc3oYof4GwJNP UZiXsUoB2WvUmT4X/yNl2rVLLmpW3P6b5p8FibbTSstrGi04hcItezleuquTK6gGkE9S 9xgTPzXDqDKdWrBlzGMJ675u/VhKrfuoKfi359fWV+Nd5Nn75AS82XOM6v+nRa2gQOHD mIOw== 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=kecgSrOyjcStfXPghMK6SzkzEVdVsqes3tfF9y2jXlE=; b=b5itQJ8/3jz1dbkgKkthxMOnUHINaWmJYAHbvUdmnksYiJLNdyx4tt/YOn88jCa/va ZgIgek4rKXAElyOjMEDf5qC11UwObbUly/6+gKNpjq8xxOQTsg45pZR+1aeF+j9dpC57 sQW8vJUrZWSxZs4HlDrQcpW2uvTBm7acq9FbkJtk+eevzIvd7I3U0hTT3JY4iKvOHYAP rPHjDBUAd1wdRs/Bq25jnwrxxKZTjREwdhjDKMnxd3eRXjPYIFO1yGdBGAkZREHEC8aa 5uyiFwqsUrnU8IEdLhrv4i2xH8lPSrMTz+4TFllCJvm6hUx1t8gO8kaIC1DoAphZHOdQ COOg== X-Gm-Message-State: AGi0PuZuokX2myT91ErYpIJcYcyuItgipI/T6LRG634vyLMiNUFKWz1x PdUDjT65D35Aro3ziRPvA39ASQ== X-Google-Smtp-Source: APiQypL6Ne3BjkNL4lVw6NUh1f09yNPoMm1MnMTn/Ay/nhenSPl5AKVKuYPxt/K6ZsWnq9cFnfeqxg== X-Received: by 2002:a37:a407:: with SMTP id n7mr10784701qke.235.1586891182628; Tue, 14 Apr 2020 12:06:22 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id x16sm10267975qts.0.2020.04.14.12.06.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Apr 2020 12:06:22 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jOQt2-0003LQ-PT; Tue, 14 Apr 2020 16:06:20 -0300 Date: Tue, 14 Apr 2020 16:06:20 -0300 From: Jason Gunthorpe To: Ira Weiny Cc: Alexander Gordeev , linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , linux-mm@kvack.org Subject: Re: [PATCH] mm/gup: dereference page table entry using helper Message-ID: <20200414190620.GJ5100@ziepe.ca> References: <1586877001-19138-1-git-send-email-agordeev@linux.ibm.com> <20200414163234.GG5100@ziepe.ca> <20200414185829.GB1853609@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200414185829.GB1853609@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 14, 2020 at 11:58:29AM -0700, Ira Weiny wrote: > On Tue, Apr 14, 2020 at 01:32:34PM -0300, Jason Gunthorpe wrote: > > On Tue, Apr 14, 2020 at 05:10:01PM +0200, Alexander Gordeev wrote: > > > Commit 0005d20 ("mm/gup: Move page table entry dereference > > > into helper function") wrapped access to page table entries > > > larger than sizeof(long) into a race-aware accessor. One of > > > the two dereferences in gup_fast path was however overlooked. > > > > > > CC: Kirill A. Shutemov > > > CC: linux-mm@kvack.org > > > Signed-off-by: Alexander Gordeev > > > mm/gup.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/gup.c b/mm/gup.c > > > index d53f7dd..eceb98b 100644 > > > +++ b/mm/gup.c > > > @@ -2208,7 +2208,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, > > > if (!head) > > > goto pte_unmap; > > > > > > - if (unlikely(pte_val(pte) != pte_val(*ptep))) { > > > + if (unlikely(pte_val(pte) != pte_val(gup_get_pte(ptep)))) { > > > > It doesn't seem like this needs the special helper as it is just > > checking that the pte hasn't changed, it doesn't need to be read > > exactly. > > > > But it probably should technically still be a READ_ONCE. Although I > > think the atomic inside try_grab_compound_head prevents any real > > problems. > > I think we should go for consistency here and use the helper function. It seems quite expensive to do two more unncessary barriers.. Jason