From patchwork Mon Jun 12 15:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13276831 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 B5756C88CB4 for ; Mon, 12 Jun 2023 15:16:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00EBD6B0078; Mon, 12 Jun 2023 11:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFE026B007B; Mon, 12 Jun 2023 11:16:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC5F46B007D; Mon, 12 Jun 2023 11:16:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CDEE16B0078 for ; Mon, 12 Jun 2023 11:16:14 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9968180199 for ; Mon, 12 Jun 2023 15:16:14 +0000 (UTC) X-FDA: 80894446668.20.D23A71B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 9E069180023 for ; Mon, 12 Jun 2023 15:16:12 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1686582972; 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=WzUhZLjp2QKiWlMNzRU1Y/O9bYtEINhSv9zjgwiVe/s=; b=EsGl2o6s4hqkP5MBMS6w8Gef+Hy5l5nZKHQfhGEempGCHcE2jNEMwWoCZYeJK2nTrT3bCy okViH3pIMcyZFFXhXiyVArgmvMaNu5+VKKoBZ4SOU/JSA19j6tKj4mZbargznbeQHWHDml 3K+KKAxkNyuzzyzVzWvG95vcmfM4rAg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686582972; a=rsa-sha256; cv=none; b=DTK7/k4nu5+2b2EVO9qy5tJ2pwbZMnO6wsap5XBdpEeWK+cUI0ZG+L1Cs1Su7dFZ3FCLRw zNNqaP/z0dTxFgAxiKhONkdq4fK2pZTNOFGUoDQ0A6rmuIgC4K9Xb6dML0RN+NdbKek0CK TIjGlm9ccqrHh2wFnT7Uuac+g2HrN/Y= 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 7B86513D5; Mon, 12 Jun 2023 08:16:56 -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 929F13F5A1; Mon, 12 Jun 2023 08:16:06 -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 2/3] mm: Move ptep_get() and pmdp_get() helpers Date: Mon, 12 Jun 2023 16:15:44 +0100 Message-Id: <20230612151545.3317766-3-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-Rspamd-Queue-Id: 9E069180023 X-Rspam-User: X-Stat-Signature: i38uks8joohfqmya9unx1uatkp5sk5k7 X-Rspamd-Server: rspam01 X-HE-Tag: 1686582972-592423 X-HE-Meta: U2FsdGVkX1/IwgfqyrRBNXYj2Kv197ACoNiOSYV1DPkCRmSevy1Rz8ErenrIL77SLv0QV0et69/oYbAGwaWzT/l5HxoJ/g8Tb5JgEuXO6vUahr4Ooq9lYifPfZS8IHXrkYiSvqxSciwlp7oPPSCmUJJgomIORhFnMA8rHLqSH8RgMb8p0/Udxm237LLu3Z0ZbuuzqaNuEhBAlY7zaA98lYy/Jp9w8ZDpuDy0qSLKwlTiL7r1WhClQABv5Leuol9YqFZUj+hB8Pb8xQXwMknJMomOxy7WCd8EKBtp4tMOl+32pcSH2CtEdlrpH8aUUnJY4Hi2ZbXsqu2Q9sfug/zSnVgMrEUZllcjABJu+T6O4V9kV6YXhWdHUT4rFqGnUAnB5zFdNQXnSxvqMgBbShFnM3ZsgzutF9v/7z4qAajc16xjSNGnoNDMT3+aaJdf2mJxriQTI9u+2YG7oe+OOCe9UjmAJGAJJAZihDyy+ovjy8AWMXoIgPI3WjKRUMOJoqWrvvD0Pzo8Ao56rGVgB0xcdqLv/zzywtfV3aFm5jhBvaE5rXm9n7YcnvBZEHcsuoeP3dQMX3DhYXs6GSFaGKjla8GzNuOBGsDJ82QpDPuqXeZ3oxJW1mq7Bm1Jfeb6Gn4uCnaIjdJEeYDdN0ZnupZZe6DxYn5cZvmIEz1jVdvTEU/gofCJHr/EETElhvNLoZvfKVdOzIPMXwa2WNQDc7fB8y5gfGDP8041Tlx24383Xq9gcsuonGWjP7uuECG+uUO3GOEvFcOTnaUTx0zqTJcLrLEl4gfRbrq+DQzY6qcj39yoQOofNM5ubSLgjDJCx4O72EErmfcf5Z+46zA7jdOHZboXUHhKPLmJ1HMK6vdmuav/miN3tRY1m/yaFa3mjATk9h+f2ePLWy+m+dOTSyoI31VFRrraojZRIFriZtV3Oc5S1I57DFRGw+Ohip8sIhN4Fdp22/17ss0jRqNs1U8 BlORVgjW /Fep64BLQGQu0yfkdd5Z66koREa5jeotsC3lL0WT5vkJlhwkUFGHAF93XvJdDbsXF4scUlbMweiqI3wZejw37YS5w5vm28hmaXQwCr3IoxmCzblLVMfbiSev5kHmvjScapvdMRHcVrsnrfYixMzLdIsfEru9wf3sOevTcaMdWMJhFoaF+BKGRxFVv9rXP25X3yLkdw4y+hHe/gihRZEKf+oS9mxtUTMjlRrP1/Rp2+VWwbbmx8dzl+b8l1tg4ZXWD1ILs34fJ5aEAvk5qwzHSaaNYnw== 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: There are many call sites that directly dereference a pte_t pointer. This makes it very difficult to properly encapsulate a page table in the arch code without having to allocate shadow page tables. We will shortly solve this by replacing all the call sites with ptep_get() calls. But there are call sites above the function definition in the header file, so let's move ptep_get() to an earlier location to solve that problem. And move pmdp_get() at the same time to keep it close to ptep_get(). Signed-off-by: Ryan Roberts --- include/linux/pgtable.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index a1326e61d7ee..fc06f6419661 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -212,6 +212,20 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif +#ifndef ptep_get +static inline pte_t ptep_get(pte_t *ptep) +{ + return READ_ONCE(*ptep); +} +#endif + +#ifndef pmdp_get +static inline pmd_t pmdp_get(pmd_t *pmdp) +{ + return READ_ONCE(*pmdp); +} +#endif + #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, @@ -317,20 +331,6 @@ static inline void ptep_clear(struct mm_struct *mm, unsigned long addr, ptep_get_and_clear(mm, addr, ptep); } -#ifndef ptep_get -static inline pte_t ptep_get(pte_t *ptep) -{ - return READ_ONCE(*ptep); -} -#endif - -#ifndef pmdp_get -static inline pmd_t pmdp_get(pmd_t *pmdp) -{ - return READ_ONCE(*pmdp); -} -#endif - #ifdef CONFIG_GUP_GET_PXX_LOW_HIGH /* * For walking the pagetables without holding any locks. Some architectures