Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5702145rwd; Mon, 12 Jun 2023 08:33:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DfW4PZzi8W9lkphZgDZ2U0LvikRTAok6ctALRzrcVuvoTi0Mih8VzYEgj6OLzb89S9ADu X-Received: by 2002:a05:6a00:179d:b0:646:3c2:4d30 with SMTP id s29-20020a056a00179d00b0064603c24d30mr11651153pfg.30.1686584000747; Mon, 12 Jun 2023 08:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584000; cv=none; d=google.com; s=arc-20160816; b=IUui23T/IKXJjdWL+AegbPs4qQYj9e0T6k5759z+q98uPAPqxcKOdI+rKuVh4/NM6K +dW3nik0yhLzOaMD1mmh0fOaB85YqQWKyF3bRhM1kg+YZmuDNNoR7v9MUEcoQnuH2X8/ 2QEqVr4EY7344HKUMbAiuJI059JT6T8PjInOPKD6wfC4oigBpO3Dft8SSk+9ApI51rwM luZe1wKOY3uv8uFng+7X9lacxgDR8asttAR2lJ5lAQRB4ges83mtbfoGKYtESdV1DuMD 0s2tWTYQHWLu+Fag4Xji9IvSv3I0dwJIzBQ0bZllqX0vFNaTo9datfopDGY+jxaiI5cO 6ONA== 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=WzUhZLjp2QKiWlMNzRU1Y/O9bYtEINhSv9zjgwiVe/s=; b=lVxt0KX1WdnA9TvuHHgSLKIG9uG/RVPfymr89hCwsYefjRl9OBsmDPYTX5ts/iDJEb gp9yg8DtNAU4KbkZ3tN3qreLoAwW+8Vxxd7fVpoHivebbbOVIUdAocmIDKbVYJgEW7K9 DXi8HKH3he8OIZo3UWnjOQqELImj1AdBAu00YcQOvBKuY/Vwi9sXcLMTIxhz8tX/wsEE ++W8Xbowa7E3JNJ3fcMpX0j96sQ3h1ICcGE5Nq63tN+VqhApAQeqcZ2Z4JcmSX+FjvkD lPnG4npdaqv5TV/ZZX2kRFf1z4T94D7iDXLgQCzOgSpTgmYbRNkTK9QlPTVy2Yors64y TVig== 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 t69-20020a638148000000b00518cf8916e2si7218011pgd.415.2023.06.12.08.33.08; Mon, 12 Jun 2023 08:33:20 -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 S239417AbjFLPQQ (ORCPT + 99 others); Mon, 12 Jun 2023 11:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239473AbjFLPQN (ORCPT ); Mon, 12 Jun 2023 11:16:13 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F416FE5F for ; Mon, 12 Jun 2023 08:16:11 -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 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?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 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 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 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 -- 2.25.1