Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp598632ybz; Wed, 15 Apr 2020 14:52:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIZpJFgx1FbleEM2fLipMUfKFiC/iuzkeh0rkJ9V9G8JP3VdC2tXiQKGSiw5FAL0SbWbFAu X-Received: by 2002:a50:c850:: with SMTP id s16mr27716881edg.90.1586987544098; Wed, 15 Apr 2020 14:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586987544; cv=none; d=google.com; s=arc-20160816; b=QT0wKVr7wxsyi8DCI1vvg1pV9PL0Z+BfeGRh1YrTx2w3fTYu6m6rpFbLVHySoqK2KA aKKSDH2OkcR+a9YAkzXqkjSjxj0IXQjOPtWhLaBfNyvkWxWyykPsefyw6Flb8evI0E8r LTaAUUMWL8Ut9XGt/iby88M/v4FDc3r+yFR9wTyTWpgFmE2eeq3V1GwkOYJyljN45ePQ wvrE8c5njvippCaRraGp7+i1k65vaoWkW+JL0XnicDsnDQfmtZRkxsk40zC8slTxLg2g cJpg/vE/QJGu5J2j2+hd1fVrdC/hVFeZuR8uXmbacRfoam3ke+9pmwayAjbIBnOWDx+3 ZzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=LR9PWaYJU00mbcnqWFjxonV/FAZLPnxKx0D2fCEaUYo=; b=nET14ohjPacDgNrJaNjZA/k35RejfvK16dWUaAYcCZLEeexqYaHtb7Q79dSL4MuTXR dTa5pkKI+HrGPgASVP1/N0p/Y1L08QgU/RxmHP7mZBBPBvy9AHTbUASMBy27sJxSCVM7 3sMZR19kMJyVa+5WEGmuMllNgg2udRPRvC74obSacHcLzi7nAybZdEun9NixjwGrP/ed zTMNSdx5mt5v4zQzJ6eyyODkI1KcyAboC696ynH/ZnfhOj+JbNZi73aG534VApRskG61 JedSy9RAhePN4j6+gmF2JiHw2Dgs6m1Oz5hlCVrKKKaCKljcfTg/PgjtLDybf0Tv/fOr fedg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si8187952edy.494.2020.04.15.14.52.00; Wed, 15 Apr 2020 14:52:24 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504535AbgDNS7A (ORCPT + 99 others); Tue, 14 Apr 2020 14:59:00 -0400 Received: from mga02.intel.com ([134.134.136.20]:39425 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504522AbgDNS6a (ORCPT ); Tue, 14 Apr 2020 14:58:30 -0400 IronPort-SDR: VrIxCfimzZEQKlxuvWd0gOG98KIpeAmmbosVD6zcMMUu0AR9SRBs7NWXnMBKN5w+acii105O6j E1yyKdffa9BQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 11:58:29 -0700 IronPort-SDR: 9FdJBCeUopAL3U0NX9fEzeH7rCHULi9c/wWB2l5KrUFQeiImXxzjYOb/RwWVJIJ05/Njn3phr7 Xv9yFwxQowyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,383,1580803200"; d="scan'208";a="427167843" Received: from iweiny-desk2.sc.intel.com ([10.3.52.147]) by orsmga005.jf.intel.com with ESMTP; 14 Apr 2020 11:58:29 -0700 Date: Tue, 14 Apr 2020 11:58:29 -0700 From: Ira Weiny To: Jason Gunthorpe 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: <20200414185829.GB1853609@iweiny-DESK2.sc.intel.com> References: <1586877001-19138-1-git-send-email-agordeev@linux.ibm.com> <20200414163234.GG5100@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200414163234.GG5100@ziepe.ca> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Ira > > Jason >