Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp467636pxj; Thu, 10 Jun 2021 05:20:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj5pYd0f4A1Ztvf5NlrwmAYjiFawEJwLNyi/RlvM6Rq0bYsRkNzAgJNOEIPFfazNOUD7Lw X-Received: by 2002:a17:906:b253:: with SMTP id ce19mr4254388ejb.379.1623327639184; Thu, 10 Jun 2021 05:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623327639; cv=none; d=google.com; s=arc-20160816; b=qq4bUMQl2eNuLhdpA+8tZwe7NRLTu1kK0TjqA+gtb6HEfUUrf89srakSQxdlrVSU5/ 6+SnB7H1OnqPSpAXsUH6T/u2Ep2KTodxJUN82SQeLL3sKJFyRFer6sv7CDVFDDKZbumP uCfCygyVv9dUfOxqLGWbHAc03L8JF6V7p3Vu3lWfSXyc5O3qaTAdne2bOK9iYT5emvWO cdwXKJLRc/QWp0IhIoThhc6V4IYQChCiZ3KHGOrSQLAe0DbDgPKpsz0lcPuqwuFenw4t o0cR+0UDQw6f/SpjVFJvXHttBXs0L5g1ZFKe3giL3UOXRZN0tyDL2GLeRFySauMSOrRN piLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X/mw4hUZ/e5f8XcWky8PtkE7VfZGoQ7c5l0ce8GaFjk=; b=sPqcLqQfMXnLKMlhpb3cqgkPAb3JtaSb4qB19/RaIb3oMKA1BpqgzmagHSNxZZJvoL ujXIp/dXR68MeHx5nh9QLCo3ur8d2M96ChuvI8lwR4ACQe7lkUf6v7RGKCr63fyikinC MJ4cVTfxgh0NCkfObR8/jz+I0ZQ8XpSXVQStGaynaSYapgrvGOA2Gpk7rImGcQyMa37P Q5o72jYfC6oaWtMl+edDMyDwx8KT3Ur4t1+AstNal64awYCYg0CFy30ubmlN4pUmNu18 EtEL47o+hfcCvXEkvEBn/Z5OCYJb0c8mOBNSzn3J011ME+1UeVxDFDWGi5pXR+mQy41C ocOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=pSqsk6p1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv18si2090676ejb.596.2021.06.10.05.20.14; Thu, 10 Jun 2021 05:20:39 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=pSqsk6p1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbhFJMSy (ORCPT + 99 others); Thu, 10 Jun 2021 08:18:54 -0400 Received: from mail-qk1-f172.google.com ([209.85.222.172]:33344 "EHLO mail-qk1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbhFJMSy (ORCPT ); Thu, 10 Jun 2021 08:18:54 -0400 Received: by mail-qk1-f172.google.com with SMTP id c9so701115qkm.0 for ; Thu, 10 Jun 2021 05:16: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=kDIAeJLuAXTlo+TuB2UMw4butFQwXTzYkzJ4Xw0epBIiLX+uTpXB8HCcR0BMAFu/zI cwMjXY6IJgwcfEe+VmFFAnXpyfHVo283guM9+GJk7Zbxr+6QTCxW2XbE0pY7HoHWcX73 yayeG2XTIKxUVqf50vuUS1NPuDd6HZMAsQN01iZW5q56LjXRtjtstgyxiuxqp6kNfKYJ CVSMyPVoZoDunjix6hPEewfGig4fTPOiZh8rkaA1t9SuUo3W1KwcGJMqM9H/NkyX3cgE VEowbgERvLA5HQYy669GgQWWvgbGo/YLpclYwbPlM9AwXIERFn9iwpH3Y0CUFATCvDon 7agA== X-Gm-Message-State: AOAM533fIeY7ZiQKaSVBa4amZUlgpdubgMgQkPUG4N7UdZ2zQB8S7cER vIpWmOKruoHoWN8ZT6psVmUXTw== 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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