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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5F54BC47094 for ; Thu, 10 Jun 2021 12:15:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC277613E7 for ; Thu, 10 Jun 2021 12:15:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC277613E7 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 258DE6B0036; Thu, 10 Jun 2021 08:15:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22FBB6B006E; Thu, 10 Jun 2021 08:15:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D06D6B0070; Thu, 10 Jun 2021 08:15:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id D26A46B0036 for ; Thu, 10 Jun 2021 08:15:44 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 774754DB7 for ; Thu, 10 Jun 2021 12:15:44 +0000 (UTC) X-FDA: 78237710208.23.7FAD978 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf20.hostedemail.com (Postfix) with ESMTP id B3371544 for ; Thu, 10 Jun 2021 12:15:37 +0000 (UTC) Received: by mail-qk1-f169.google.com with SMTP id c18so11939422qkc.11 for ; Thu, 10 Jun 2021 05:15:43 -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; bh=X/mw4hUZ/e5f8XcWky8PtkE7VfZGoQ7c5l0ce8GaFjk=; b=pSqsk6p1i6tt3msly851ebT62Y/2WSMFTcvhfyyUMuhTUXHhw1/gPmNWygVky3pXhy lCvnjq7gr9f0ofN3XRP2fQkIhZ/Luzt0ZOyvH/MRBsGLQvJ8zsvkh2NFVlrP5SwNcf9z gNPzr6of/TmH2GLQr6m5W3NAOVX8lOmqWyBFoGq3kYPadO1ditmqEDWbNIiHgFL0NqUE X1ErKX7lL5VEkI3RBNQmfHyRBDpYCFAVhM8w6biv0xISvwLyTky/kg81jh/bepQDZsUf RKzQFj9V5dFIZ/GHAza4DFQTD6RXVJr3/jyllN7jM9tU7uOX/p0PUa7rFArfTpK9Jt2t qFVQ== 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=X/mw4hUZ/e5f8XcWky8PtkE7VfZGoQ7c5l0ce8GaFjk=; b=PlJpptttE8Qnwkc/9oHxmak252u3Wz6pRdBcvsIuZYxvYesENDXSVApVSS/VZyhGen HhrQUgpdTH45xuLE2LmYYVcMV2LrcCEJNC/1y0vU+BWYdBEzL5+OI44Sv85B0C8c9pCq 25OQz2XqA0I3LvR2OlWm0t/cee1hdWPu99ZaeGCzxDOoYSTBb83MqiRcSH9yTpEBfi3K LaUI83UHK/DIp1AhY5txqIeC82LHqoaHNtf690hU1GcDoVXSOXEAbNiFppk96/UOOSo8 TwDtQjSaWtDsP7qcMV1Nf5c4R+qCL0PDcc6c/TexeV0sn9NYvKvYoW1x7s2vAJ4hEt71 uR/g== X-Gm-Message-State: AOAM533+W0ybcx0x2WzPKNcAsZcG9mzoSbuqChpi8SV22EWUCjRfYsQk cd+z4poADU2YVNaj/9M8+uT1TA== X-Google-Smtp-Source: ABdhPJx8bkfi4t9XeSnNx/iqKc0BUHZGJ17n0wfLu9CTkrquetTaEWfeRydyF66UUbGMoF2UrtYlxg== X-Received: by 2002:a37:63d6:: with SMTP id x205mr4208068qkb.501.1623327343383; Thu, 10 Jun 2021 05:15:43 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-47-55-113-94.dhcp-dynamic.fibreop.ns.bellaliant.net. [47.55.113.94]) by smtp.gmail.com with ESMTPSA id a191sm2133358qkg.61.2021.06.10.05.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 05:15:42 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lrJb4-0053vI-3o; Thu, 10 Jun 2021 09:15:42 -0300 Date: Thu, 10 Jun 2021 09:15:42 -0300 From: Jason Gunthorpe To: "Kirill A. Shutemov" Cc: Hugh Dickins , Andrew Morton , "Kirill A. Shutemov" , Yang Shi , Wang Yugui , Matthew Wilcox , Alistair Popple , Ralph Campbell , Zi Yan , Peter Xu , Will Deacon , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 03/11] mm: page_vma_mapped_walk(): use pmd_read_atomic() Message-ID: <20210610121542.GQ1096940@ziepe.ca> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> <594c1f0-d396-5346-1f36-606872cddb18@google.com> <20210610090617.e6qutzzj3jxcseyi@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210610090617.e6qutzzj3jxcseyi@box.shutemov.name> Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=pSqsk6p1; dmarc=none; spf=pass (imf20.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.222.169 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-Stat-Signature: t1ijjnnrkjetf1yz4xyjyhiqo6pitnc9 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B3371544 X-HE-Tag: 1623327337-306707 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 Thu, Jun 10, 2021 at 12:06:17PM +0300, Kirill A. Shutemov wrote: > On Wed, Jun 09, 2021 at 11:38:11PM -0700, Hugh Dickins wrote: > > page_vma_mapped_walk() cleanup: use pmd_read_atomic() with barrier() > > instead of READ_ONCE() for pmde: some architectures (e.g. i386 with PAE) > > have a multi-word pmd entry, for which READ_ONCE() is not good enough. > > > > Signed-off-by: Hugh Dickins > > Cc: > > mm/page_vma_mapped.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c > > index 7c0504641fb8..973c3c4e72cc 100644 > > +++ b/mm/page_vma_mapped.c > > @@ -182,13 +182,16 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) > > pud = pud_offset(p4d, pvmw->address); > > if (!pud_present(*pud)) > > return false; > > + > > pvmw->pmd = pmd_offset(pud, pvmw->address); > > /* > > * Make sure the pmd value isn't cached in a register by the > > * compiler and used as a stale value after we've observed a > > * subsequent update. > > */ > > - pmde = READ_ONCE(*pvmw->pmd); > > + pmde = pmd_read_atomic(pvmw->pmd); > > + barrier(); > > + > > Hm. It makes me wounder if barrier() has to be part of pmd_read_atomic(). > mm/hmm.c uses the same pattern as you are and I tend to think that the > rest of pmd_read_atomic() users may be broken. > > Am I wrong? I agree with you, something called _atomic should not require the caller to provide barriers. I think the issue is simply that the two implementations of pmd_read_atomic() should use READ_ONCE() internally, no? Jason