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: 106691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2677292vqr; Mon, 12 Jun 2023 08:42:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5QQjgOtE8Uy9MYv3U/3+GxBlHUl/dJ+gHfAHSA8k/fb4HPca93RuWACA53k3JFiGPODNVU X-Received: by 2002:a05:6a20:4407:b0:103:ef39:a832 with SMTP id ce7-20020a056a20440700b00103ef39a832mr11223595pzb.23.1686584528094; Mon, 12 Jun 2023 08:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584528; cv=none; d=google.com; s=arc-20160816; b=FKhL62u2sKycjnNsZh/ePNmTZiDm47lLilNg6gtttabEbsVwDMsJfFnWsPKh1Jyeav I7lxYKl9KgrZoN8Zz3hJ1UIYMmdbgemrxA9lop0Zfnfr5CDlrHX3Pv62A8eWjmpp7lX/ +7U/dW2wE3tUvbruyXyj4m2hI+0mvyW+PZgt93qJo2gM5zZaCCXupGJQ1X68dTwGUIyk 2ihzKsIGH3TeK3r+qVHOVA+bpWtjvxndLU+jzS6ETi/0mxW+d9vYc4gLM08/aURYnhIb c1gIly01DYrHBsTSlIWFKGSFlNkFyWS5+BQyuyxZuneivmiqkTyv+H6iFlHxIaO5bilM s40A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020a637f02000000b005307d9f387esi6929342pgd.536.2023.06.12.08.41.53; Mon, 12 Jun 2023 08:42:08 -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 S239475AbjFLPQQ (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?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-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?1768512058253800347?= X-GMAIL-MSGID: =?utf-8?q?1768512058253800347?= 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