From patchwork Sat Dec 17 18:55:33 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: 34243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1636341wrn; Sat, 17 Dec 2022 10:58:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pcv+thDHycRUrUenqki8nXJjxbqhmXnRPEKuacROj1TTjtvX26d8cEZewLlofKpMY6Rvw X-Received: by 2002:a05:6402:1a36:b0:46d:b89a:de1e with SMTP id be22-20020a0564021a3600b0046db89ade1emr34140107edb.1.1671303504489; Sat, 17 Dec 2022 10:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671303504; cv=none; d=google.com; s=arc-20160816; b=KlkMPLEFcLEiRbjZC5OcZiAnqkuLG9qdPRprbu0aax224JpD80NsrPur/vuXAmndad QC1oeadgNPdfBmuACwZP+Y9DdZrBxpbB/Q1FhFkVEmE3hjEaSjnqz0VXifzH7+t5dz2y yFOUcHHF8VSk6Q8RdXAGYHpJIu1dNZo3w7oEnm/yGiaD2DcD+KgEiiBIIJL9RMXuFMo/ SPpQoUFza1oUsZyqgl6ifVKLx4lGe+MhORMKVt5+FvsxeuF4UlUufGwWWSnIDmoSMK5C PiTItNlyvOXDtRV5doB+h6RAyPmJTqlaGGBddh6+uuJNXL5f/TC4Sa52TO4NQtMB0BdD FgZQ== 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=lKKXJOtH81Nxky+4PgDivO30jQ9slzM0RDWljCDF8b0=; b=nsvSSLztyO4tFs53OmVPb+x4Hsgg94FlP9X+8Tv5TbvFj/SB7NPIvHr+cKj69SOUnZ 6JgsjSPU20hHJhxr20STtQUvNQiS6RIT78OVwUE+vCezphhO1pXqwXj06FFPbWXeHVKq z6egRq/f+DtTm4ByBJ4aJh5gtGK8uWqyVj1DS5PtzqKscBolEoyzn7tokf05iAZd4J5x UHs14V5fAoPPsobScJp03DJJgL+lSwtO94Pk24+xTUT35JcArL3ol0NZnZCph500Oi/t 97XKqdLC6GaLPnwNr4NN9emuJ8X5C+z7mb66QM3p9X30a6kuhphx+uxKfiCPtnrNRQcu uvxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fHrySRWb; dkim=neutral (no key) header.i=@linutronix.de; 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 e9-20020a1709067e0900b007c09f4b0947si4450031ejr.1004.2022.12.17.10.57.59; Sat, 17 Dec 2022 10:58:24 -0800 (PST) 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=fHrySRWb; dkim=neutral (no key) header.i=@linutronix.de; 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 S230212AbiLQS5O (ORCPT + 99 others); Sat, 17 Dec 2022 13:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbiLQSzj (ORCPT ); Sat, 17 Dec 2022 13:55:39 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7994FBE7; Sat, 17 Dec 2022 10:55:37 -0800 (PST) Date: Sat, 17 Dec 2022 18:55:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1671303333; 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=lKKXJOtH81Nxky+4PgDivO30jQ9slzM0RDWljCDF8b0=; b=fHrySRWb/Qy+LCtVqUXNzNi8iI4MK5TvsICB9NoiwX0Z6I5Zf5Umq149KcygQsyeGj3Nu5 G4yiqPdpxCibLDbNpflayVPMwmRX1HuWXxmCwlFWjfzgeldVCiN/vsOun1XnuV0BSUZN7R KpWVW/c4s/wq8S4Ncug8jc21ZFaUBpQ8vXWBvL57qlgny6BXZsN/T1Xf7IVglbmfK6721z tqL8jlyegWkIFaQxp4mOqncKaIUMTItCUoAr5pQ72UUwT9DYaefYshhEBZ+bd9YPFOJQ1v qZworw0iu5g3Se0DyNPobXqjDn9n4kex9vif6UdlcZNR+2OidCUkMS8DDlKJ5A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1671303333; 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=lKKXJOtH81Nxky+4PgDivO30jQ9slzM0RDWljCDF8b0=; b=y9M3JHTZHNzx2WFkg+/bB3LzxJwSusq5tgnhr/tx9qVaucK2dRISUMy6ZqnACjyIy05C+e g8b8I8wzE3mfc0Ag== 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: <167130333302.4906.13152896885964546282.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?1752488743534393585?= X-GMAIL-MSGID: =?utf-8?q?1752488743534393585?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 1180e732c985ed3c8866d2fd9e02b619848404a0 Gitweb: https://git.kernel.org/tip/1180e732c985ed3c8866d2fd9e02b619848404a0 Author: Peter Zijlstra AuthorDate: Thu, 26 Nov 2020 17:21:30 +01:00 Committer: Dave Hansen CommitterDate: Thu, 15 Dec 2022 10:37:27 -08: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))