From patchwork Thu Jun 10 06:38:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311943 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, USER_IN_DEF_DKIM_WL 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 CE921C47094 for ; Thu, 10 Jun 2021 06:38:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5D855613CB for ; Thu, 10 Jun 2021 06:38:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D855613CB Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E82816B0036; Thu, 10 Jun 2021 02:38:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E32306B006E; Thu, 10 Jun 2021 02:38:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C84EB6B0070; Thu, 10 Jun 2021 02:38:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 924DF6B0036 for ; Thu, 10 Jun 2021 02:38:15 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2C3BC8249980 for ; Thu, 10 Jun 2021 06:38:15 +0000 (UTC) X-FDA: 78236859750.22.A598485 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf15.hostedemail.com (Postfix) with ESMTP id 7FB69A00025F for ; Thu, 10 Jun 2021 06:38:13 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id l17so15992920qtq.12 for ; Wed, 09 Jun 2021 23:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=sJXaknDNqIwNp1rWQgx+PfiGckf+KTxU5H8H8+f9QU0=; b=b1XjZwsGuZXQBj/2tSNWtimTETxoUPqdgZyvsNvx8vkkjvIi8Ygjkp1bT84QOB3lNJ ixcBPLAR/OAzhh7P3V0jtbZh1ooj6X0xFHLsy7KQXcbQ8aOSQ6l5kFOJe3AOYcBv3NqT E7KEwyIfiR+iWAyTglS9872q46W0IfZLa0SZYfNtlhT4vzUpAaLa4jBB11OLKKxErsCz AUCWU0p9KNTvh9jcrLiiaQLay/yDLrASCVHxeq4MehjsqX2LfiSe0CDrQJRsXa/g5jgy b4/ByIHtTGaaggP1grvtIyVnLQrgK0I/cXPR2CZPovkVvpl3KwUUFq2Epp/oDGC+1osu yznw== 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:in-reply-to:message-id :references:mime-version; bh=sJXaknDNqIwNp1rWQgx+PfiGckf+KTxU5H8H8+f9QU0=; b=UFBuOpTwv/JU5VVGm+do81DlhEgGfpd06ACkQxjgsITYJ4PfdcI8qd39ZXA7IFXlFa rAFoQ1cTBPTEyU4GayQZ5M5mImcbQZHJzIn8J1CwoxNCQLWGqBRkiHchjvkolE+ELryk SPIyTGZDbRQWPc10InofADIQeH9gzdz0Szmm5HexNRAczwq2PqzgWCDMd00KhAHZHEDK QECTXbH2vwOi0H/gWH0OxLl2cwQv0lA8GHyKEfu8Zcu0DXbqA2V3+LbhTvbgD6UQXCWG JfrLwywmHqFKPXnYFR/NS+4qFtdHsv0gkGj2hLiLFrIWFPK4wFRVUP9YCoVHF7nymuYM JIDQ== X-Gm-Message-State: AOAM533koq/+yuBp6MZ6+S+jU30bs9KdxnLlXfmzpeKluNlORTA7uMbi 7YcUo5IVeLQihbRcYSH/v8zDcg== X-Google-Smtp-Source: ABdhPJy5ZcKX50ID5llLhv4bLtcmcu81J9Dm4F8WNmXVszglwbobG1CeiGKZ+cv2mz2wkusrlKG8cg== X-Received: by 2002:ac8:4ccf:: with SMTP id l15mr3701125qtv.174.1623307094084; Wed, 09 Jun 2021 23:38:14 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id c20sm1716101qtm.52.2021.06.09.23.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:38:13 -0700 (PDT) Date: Wed, 9 Jun 2021 23:38:11 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Hugh Dickins , "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: [PATCH 03/11] mm: page_vma_mapped_walk(): use pmd_read_atomic() In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <594c1f0-d396-5346-1f36-606872cddb18@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7FB69A00025F X-Stat-Signature: hyqpnfay5kqknoxzmjo3aqj1zt9c6ujq Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=b1XjZwsG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of hughd@google.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=hughd@google.com X-HE-Tag: 1623307093-603084 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: 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 --- a/mm/page_vma_mapped.c +++ 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(); + if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) { pvmw->ptl = pmd_lock(mm, pvmw->pmd); if (likely(pmd_trans_huge(*pvmw->pmd))) {