Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5719628rwd; Mon, 12 Jun 2023 08:47:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ564YC9prVp6ace7frnqBD4VDbnXTNmIZyZwC5ANd0m1pPj8qTat9++CVrWCo/0t5PE+nrN X-Received: by 2002:aa7:cf12:0:b0:516:7a2b:ff80 with SMTP id a18-20020aa7cf12000000b005167a2bff80mr5816876edy.11.1686584874299; Mon, 12 Jun 2023 08:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584874; cv=none; d=google.com; s=arc-20160816; b=ViCALPn7/vw0lmQNe6C3+XmVV8laoDIs11DCD2tX5VffUqIF0msqh9udci1VGzRQh4 rbyp3wuhJ02JgFfx47Rmm0Um/Nl+hW5d80JzlzOgWSTci5xhIDmDjCmhigV9PJwl+4lN 4GlHvf4fEXYhS8muSnxk24rnEczbLm5iXprLANuMP9NIZcg0kInrs44EiufePlkR0YJe YO6nssZ2kaKhQn2sMDWG7OxLbVFcc6XZUedJkR3RAcAZZs0C2FL04iIJ/ip+l3/KBprN Me+/R1pdxu62GMuXl0ArZGn5A/NrgPA82llPnuy22RdlYj2xfXIkvp9BX60Hel9zmb/v 8mKw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020aa7d552000000b005184abebe85si485472edr.443.2023.06.12.08.47.28; Mon, 12 Jun 2023 08:47:54 -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 S239413AbjFLPQL (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?q?J=C3=A9r=C3=B4me=20Glisse?= , 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 Content-Transfer-Encoding: 8bit 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 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)); -- 2.25.1