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: 13276830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 116BDC88CB2 for ; Mon, 12 Jun 2023 15:16:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1DE86B0075; Mon, 12 Jun 2023 11:16:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CDFA6B0078; Mon, 12 Jun 2023 11:16:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86F0E6B007B; Mon, 12 Jun 2023 11:16:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7887C6B0075 for ; Mon, 12 Jun 2023 11:16:09 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4D2BC1602AA for ; Mon, 12 Jun 2023 15:16:09 +0000 (UTC) X-FDA: 80894446458.04.38EE1C4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id 72EAE40014 for ; Mon, 12 Jun 2023 15:16:07 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686582967; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0+ER2+meiKY6IihdeAmqEesVkZOLrX6iyumSQ77U0Uw=; b=lEKUJEd8KiSUJFpklhwhf3tmGcv4NXszMMbXbB3NdSJZck1NlHzCISFf/YZCsfByj54B3h OAtRlKEghsbXvVHWnxF8L1bJvk3+P5XiwlrfBK14Ot9ra7V6FCIHOhsZ4XxiHPLmOXE5NZ PCkSbk4kDLASs6CIOAEMXLvls+vkJ8E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686582967; a=rsa-sha256; cv=none; b=QuYhWvZi3JSpvnhxPwNYGy7ET8gyPWiAKmceULsk7eIsWMJ6XItB/4E3YfxIATnHfIqT/Q 7V99W2jDBIuPoaJBempa9h8fFhkvhRNwfaI+DQ/DcEHDpbNTNSDIIIcYXdoSpN3gCWQ/HX IeW5Sy8Hoh2JiY+F3LT7pWgC5dwzyF0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com 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-Stat-Signature: o8dmm13y9sd5mqkkmiu31nyhyow67xb6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 72EAE40014 X-Rspam-User: X-HE-Tag: 1686582967-28977 X-HE-Meta: U2FsdGVkX1+vA0XzQp3/D0NSpwmnrxYH4y5n5SCqOvUsd7zpaIBml85q9fPfky8cQOVTfgCT+OfaFuprDFgqaaAm/WUNrZdrmum49r/GAjd4elwudpowVTZJPaT3rN94ekFJ66H5ySHlf8YkuEf0b6ZTRevMR7+evg++j2OT1ZPljvHqL72eaZQIF4SWRSb6haq/eAIynDb1Mev/jck7M6fUoEHulVvqAtar+gujAZWfLLMbyZLkYtkeZfg8Tf7PQfr6JWV/1FHSCP0Pkv+ZIa4vWUCnOy7lY0U0/Z+fbtZ+cAFfv6R3EV0KDSKnsRQmLtmGpaLl452s8lRGAMxndM3s+KmjHft6OdrLqnn4GxJjpzcFAk8DXYKJjWLtcnguAfO7aX0fFaK6Wp8rcIHHX6Znvn17fiF1awtL/G/vpYfuKuKNyiXAjBoeHgDgVR/ca1rIftNLzpIjHb+GkGHisfNzuf1m5HIsuRM2x1/Nqz4Jcj3YpN2Mtxr/dW4oXdOUxoLG4Vn/cEnYTzo17LnzQP+qVgkrvMWGMrU9Y5b36eAhXOMYX7PCXejoldcr6URqaZzltSKGjEmseTYhgsc0pYyNoptTn0bNV0op6BWJZzGScH3wIYE99o+NF/TCf64rVTn/h8l9AxHPA9C2/3vmjVsb4c5C7BPrr0ZlXkh2cRrW0/iSsbMk3JALr+ZxXA6nKLcPMjuks2PdL/XZCoc20RCqEqxtwr2yvErewHWQNQ6qznREBhRTxZSu7p52xXRcaOiuNbKdYW85c9mprQwRbh53Ai1gX0SNfQAMYCNQJZ0oQgE/OLPFMVoSKKH+yiGn4GRd429CpDy6dnaYfu9+GA1+9nbrJ9zPmsdWPEZFp9nl7J86wQPFeZCImvcYiKfPgJa9lvodSJcTZDaq2mKl6X/SRcaN3FT8RjzetWEb347wvA8UDC0CN3V0oDhG7DCZoQ+xlBpigbPe3HN7AGk HbSBcx45 0zvFVXv5kJ5WeISm5l/+DMCzOPj4zMPrjRN9Ssz/unyhPwfOplHiJaMc6hYHZPsX1MeUs7JyWAUAoQe7VhWQlEBZNwLhjDokCZ6DdgW/aSBEVzttAScah+9QaO0Pny7dSQ7H8+h4ll8awN74zRrPtEAuipKIs/9rTGplo5qH3NNrjm5kaI4jbbLj4zVFVoPtLZVhp5ccowL5ewo6/p1hHuFVtbS6Eubyf4ibtn2u4WdG07DqBNq4B5/MWi96LhK26uZKHhSygWWWQF+2GJEsUKMGD+eTa1+D5ezhMVzGHXiRjflg= 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: 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));