From patchwork Wed Nov 2 09:12:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 14127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3503947wru; Wed, 2 Nov 2022 02:14:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N30igjsS0fk8LGerWgDDixc1VvHSqHQxaM6vdltWtYbdhc4Pj6UxlchCqFno53F7SpJJJ X-Received: by 2002:a17:90b:524f:b0:212:c22f:fbd1 with SMTP id sh15-20020a17090b524f00b00212c22ffbd1mr25264536pjb.155.1667380474577; Wed, 02 Nov 2022 02:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667380474; cv=none; d=google.com; s=arc-20160816; b=C3Kia67f6wYh6ebeGtVUZ3jD5VKY0vigpQpVlGCjoWDSDJUzqT1Td/szuVkn2F2g8M YiGfu19d1Ke7R9/YA6tCpsZT1VmNtzhJdxApb6vh8/JGluHrTn1nIMtaTpgvYxt1eegL CFFmagpQMd9RYq7ex5yTNmnAibkJJz9oxaLJNB+mn7CjP2qdIEIjwOhtp44Vi7F9IPeP 3QECW7/vJ8207J0AJTpnoaWSP8rnWc1a9Z9DRPVd2ANguSTLndhHsNYDhLn+2FI+OgTe l+K/BiuQBtWZrgAJTYLKKCYlhUTZY/VcUj53PpiIMdyk6t1v/+mYS2nt1NsCGjnOz/m3 NAEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=RT8L0UGb4JToLrqr1SrWn3MXpnb+J9vu9IfgZDz2iTI=; b=rhNr9vadRlEN2MwuL9kH1kGj5OtNQpKTXnsbkt3jIe1m2h2T2pNJW7n8bN1BuQnnuD cB8J1Ni7y/RtNDk6WKbt/9lkg/ODN/0KZPxLMH9QzzBXq/a3nrOG2UwO20DuyzMgQ0Cy Nmdl16pdsPh+XG+BKQo2OswZYwIZqbBe84deszOmwJWiOml0H4pgitAnFbkyOJY6ytW5 E1v5EXiUXP+UHoGiMgZvF6bJiS0lRmsngjXSKodum+IXQ1gJZa+teBIGWs+uThyq9m5z or3D9xjXsm/+DRpRkq3/DCchY1e+pNjeQzb9CUfdvkG7VqoJDhm+Kc3MR1lyGJyHEN3U nskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RxmPFjaC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WvdSmDGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a635d4f000000b004632ef90079si15636874pgm.858.2022.11.02.02.14.21; Wed, 02 Nov 2022 02:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RxmPFjaC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WvdSmDGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbiKBJOD (ORCPT + 99 others); Wed, 2 Nov 2022 05:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbiKBJMx (ORCPT ); Wed, 2 Nov 2022 05:12:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61B0E28E18; Wed, 2 Nov 2022 02:12:42 -0700 (PDT) Date: Wed, 02 Nov 2022 09:12:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667380360; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RT8L0UGb4JToLrqr1SrWn3MXpnb+J9vu9IfgZDz2iTI=; b=RxmPFjaCarVAMF5rWqg6bbQCmE/Nn+SNQJhSXevJgzkcWeOXQQMz7aeNCP9rfMnsGZ1p8p t+/oc+rkPnv/n+qHkX/dHUKwxMr8NP6Hp9ipZSobeBv0E1/di/6G7ULXoFtfYN4Q9O8Rk9 ta7hHU63Nfi8ChIIw3iPovucWU8EorZ68t0nnzvzZRXIVYSVkxltgWzBZ+XlyMFGC4vDLG K/ji5MiNh085zwXaEddA63WjL8Va6xPZxU1KFeu1jvseHpgI3KiNwzAbpmghcP41pWZ01i yfXCc2LvbygCMVpqy3S+PeZqa1kfjyol4U83phqZ+lnqSpAVep8iN9LZmpI8Vg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667380360; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RT8L0UGb4JToLrqr1SrWn3MXpnb+J9vu9IfgZDz2iTI=; b=WvdSmDGTsVes/NLOlw/lw11lVT0qch+xDbNrtwPs5cRDSkL2G2IOy/EVDaoEiRZ/GFELfx 8nyt01rTXdhVNgAg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] mm/gup: Fix the lockless PMD access Cc: "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166738035964.7716.5433885798359533434.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748375148817516107?= X-GMAIL-MSGID: =?utf-8?q?1748375148817516107?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 4fff2c7e6b8e91e00838b145d08353dd8a1893c1 Gitweb: https://git.kernel.org/tip/4fff2c7e6b8e91e00838b145d08353dd8a1893c1 Author: Peter Zijlstra AuthorDate: Thu, 26 Nov 2020 17:21:30 +01:00 Committer: Peter Zijlstra CommitterDate: Tue, 01 Nov 2022 13:44:02 +01:00 mm/gup: Fix the lockless PMD access On architectures where the PTE/PMD is larger than the native word size (i386-PAE for example), READ_ONCE() can do the wrong thing. Use pmdp_get_lockless() just like we use ptep_get_lockless(). Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20221022114424.906110403%40infradead.org --- kernel/events/core.c | 2 +- mm/gup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 4ec3717..b0d3842 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7306,7 +7306,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) return pud_leaf_size(pud); pmdp = pmd_offset_lockless(pudp, pud, addr); - pmd = READ_ONCE(*pmdp); + pmd = pmdp_get_lockless(pmdp); if (!pmd_present(pmd)) return 0; diff --git a/mm/gup.c b/mm/gup.c index fe195d4..ff8b223 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2808,7 +2808,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo pmdp = pmd_offset_lockless(pudp, pud, addr); do { - pmd_t pmd = READ_ONCE(*pmdp); + pmd_t pmd = pmdp_get_lockless(pmdp); next = pmd_addr_end(addr, end); if (!pmd_present(pmd))