From patchwork Mon Jun 12 15:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 106680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2672133vqr; Mon, 12 Jun 2023 08:33:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P+DB2NnhJuONdRqTARTG+c14GRF3nWsSR/RduPkwh2lCHBEjcZAN0vEA/9aoIAULwsQb8 X-Received: by 2002:a17:907:930b:b0:967:e015:f542 with SMTP id bu11-20020a170907930b00b00967e015f542mr9848093ejc.44.1686584037257; Mon, 12 Jun 2023 08:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584037; cv=none; d=google.com; s=arc-20160816; b=lBmeNl0vbmxp7d0MJSWRXdkYe2tMQS/sBYmA9UYekFhdyrBuEdQrUg159WeaWOKbUd 1muSTR7SF+iddJepDZp6n0Cv/P6T/gyyXx5emNQgybDaQMBbQs9YwfYpQzeRyM0pLMka vYbUkkzDsKRjgo3b2rEmSTwbRtV1y3cm3cevBBlz/2LdFYTvCEC6dLwp+JPgC5m0jgGN ZV7gjw3XbEQyyKvGuXuIzI3BLyZF6bKS7AgsCY1FzLCkYGCrHiJLPCSazSYYDXq0KYzD +dtdN/VkDlooCFrLz8E2u9HTpingVc2AvNenVdjqhJgn1aiYZDievrMGleZ+idtfNNs7 D7hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0+ER2+meiKY6IihdeAmqEesVkZOLrX6iyumSQ77U0Uw=; b=TF6jMwnbn0NE7aYWFmykmfkugTq2Pz+kwkVfJD/hLKgPWnVeerQNBpBhRoRFNNlNgr wZ2A6HZKSoJWReLeACtkbhm1MmJK4mK+qq2AFPfjurNn5o2bMl4OwKqzztmKrBJDB5k8 S6M6C8vZAo863TiVnHg20nELF6V6WAS3yAt37T7U4w8AiQWJjclfeJVUqGmg47vkA2Kp ba228kV9C8rS6TqubenSA+CjAsDphuj539c6F+n702I3KMoswScy3cs/7pz2B9glrjpN wIwwaS7Jo8kWQu5A0Yi6w2fQlQ2gyMp3AW9CsXeA1+IpdWEJTkQKsm6kGJxINyT5YJ0T CGIQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a1709063c1500b00977cc7cec71si1707182ejg.285.2023.06.12.08.33.32; Mon, 12 Jun 2023 08:33:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239386AbjFLPQL (ORCPT + 99 others); Mon, 12 Jun 2023 11:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234242AbjFLPQH (ORCPT ); Mon, 12 Jun 2023 11:16:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D4FD8F for ; Mon, 12 Jun 2023 08:16:06 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 64A882F4; Mon, 12 Jun 2023 08:16:51 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B93A3F5A1; Mon, 12 Jun 2023 08:16:01 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Mike Rapoport , Yu Zhao , Jason Gunthorpe , David Airlie , Daniel Vetter , Dimitri Sivanich , Alex Williamson , Oleksandr Tyshchenko , Alexander Viro , Christian Brauner , Mike Kravetz , Muchun Song , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Naoya Horiguchi , Miaohe Lin , Pasha Tatashin , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [PATCH v3 1/3] mm: ptdump should use ptep_get_lockless() Date: Mon, 12 Jun 2023 16:15:43 +0100 Message-Id: <20230612151545.3317766-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230612151545.3317766-1-ryan.roberts@arm.com> References: <20230612151545.3317766-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1768511543396059986?= X-GMAIL-MSGID: =?utf-8?q?1768511543396059986?= The page table dumper uses walk_page_range_novma() to walk the page tables, which does not lock the PTL before calling the pte_entry() callback. Therefore, the page table dumper's callback must use ptep_get_lockless() rather than ptep_get() to ensure that the pte it reads is not torn or otherwise corrupt when racing with writers. Signed-off-by: Ryan Roberts --- mm/ptdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/ptdump.c b/mm/ptdump.c index 8adab455a68b..03c1bdae4a43 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -119,7 +119,7 @@ static int ptdump_pte_entry(pte_t *pte, unsigned long addr, unsigned long next, struct mm_walk *walk) { struct ptdump_state *st = walk->private; - pte_t val = ptep_get(pte); + pte_t val = ptep_get_lockless(pte); if (st->effective_prot) st->effective_prot(st, 4, pte_val(val));