Message ID | 20230511125848.78621-5-ryan.roberts@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4357092vqo; Thu, 11 May 2023 06:08:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dtQlT7HlC7m6QksbhT6QSPK/N4onWemrfntzGJXlnro/wPmqiqalghv9OPcwmzJ13P0Oo X-Received: by 2002:a05:6e02:152a:b0:331:5854:eb47 with SMTP id i10-20020a056e02152a00b003315854eb47mr16073894ilu.3.1683810504841; Thu, 11 May 2023 06:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683810504; cv=none; d=google.com; s=arc-20160816; b=PSepYYMt2iGC43uNK1+CcPu3cBYbJ4pfzAiS8pHDwQXbr2NgiqvqFLz8q6gMqSOoVI iF+5VALUi/rnRWY4V+bTAgNyRwKX9H5dTsixk0UmNWa0xIj3sRam3dwX2M6lIqLZSH2F mfy3Lp5im/NZJB6qrZQdhM+E9yrR2cMxhe+hQ+I/bZwcJ0bBUPRvZRYeJH3uYOrrRGzr GcJwC+5bSBQmsFpHeAOBHbkW/JhPbsC4/SoIuFPJrBWRcGyaiuMLnGVx1YrPEg2G5i86 nQolf9IDXgH5mpADg70z+1OQ/gjclKrQmFd7OfaEGRiXI+d9JP+hJv1yfZVx6lZI7nnw eHDw== 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=/52sUb9+9WPQZmxdyTfX0GVTpGvmb9ShLbs41ARbI6k=; b=JgaUa6KnXd4pxR6GZbDShhHyLhFsWaH5bDhCT814c/t88ENZuMR5zI8bEiqEq1kvrd 6n1w416LJMT1CLMYXC8LeRdrIUFBkCZfGQwW1KuwUCjh7s7DKR63Ur9Rzqf/aOn0dGwL 9GdSYA4oMF25W9RwNTX4xuxx5NMGHKD9IFEWy0eVUYF23RAaJrsdCMqyg3FqgLbK0lW8 eCioyleP7yN/gMS6boLJ5hWjSytuAsxGcxgYKydVQug2yroNKakTp6926xutMZTXnCFL ky+1pbxBq+3IwIZDT3QOLzUtnBZNlUjzO9ptMKG6Z6sZiriimSMseAS6dwDb74SGQtjI BkUQ== 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 s192-20020a0251c9000000b0040f692a8a9esi6372010jaa.165.2023.05.11.06.08.10; Thu, 11 May 2023 06:08:24 -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 S236865AbjEKM7a (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Thu, 11 May 2023 08:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237971AbjEKM7W (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 11 May 2023 08:59:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D1577AA1 for <linux-kernel@vger.kernel.org>; Thu, 11 May 2023 05:59:13 -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 5AE531688; Thu, 11 May 2023 05:59:57 -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 B46B23F5A1; Thu, 11 May 2023 05:59:11 -0700 (PDT) From: Ryan Roberts <ryan.roberts@arm.com> To: Andrew Morton <akpm@linux-foundation.org>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, SeongJae Park <sj@kernel.org> Cc: Ryan Roberts <ryan.roberts@arm.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [PATCH v1 4/5] mm: Add new ptep_deref() helper to fully encapsulate pte_t Date: Thu, 11 May 2023 13:58:47 +0100 Message-Id: <20230511125848.78621-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230511125848.78621-1-ryan.roberts@arm.com> References: <20230511125848.78621-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765603284082904003?= X-GMAIL-MSGID: =?utf-8?q?1765603284082904003?= |
Series |
[v1,1/5] mm: vmalloc must set pte via arch code
|
|
Commit Message
Ryan Roberts
May 11, 2023, 12:58 p.m. UTC
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. ptep_deref()
aims to solve this by replacing all direct dereferences with a call to
this function.
The default implementation continues to just dereference the pointer
(*ptep), so generated code should be exactly the same. However, it is
possible for the architecture to override the default with their own
implementation, that can (e.g.) hide certain bits from the core code, or
determine young/dirty status by mixing in state from another source.
While ptep_get() and ptep_get_lockless() already exist, these are
implemented as atomic accesses (e.g. READ_ONCE() in the default case).
So rather than using ptep_get() and risking performance regressions,
introduce an new variant.
Call sites will be converted to use the accessor in future commits.
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
include/linux/pgtable.h | 7 +++++++
1 file changed, 7 insertions(+)
Comments
My appologies for the noise: A blank line between Cc and Subject has broken the subject and grouping in lore. Please Ignore this, I will resend. On 11/05/2023 13:58, Ryan Roberts wrote: > 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. ptep_deref() > aims to solve this by replacing all direct dereferences with a call to > this function. > > The default implementation continues to just dereference the pointer > (*ptep), so generated code should be exactly the same. However, it is > possible for the architecture to override the default with their own > implementation, that can (e.g.) hide certain bits from the core code, or > determine young/dirty status by mixing in state from another source. > > While ptep_get() and ptep_get_lockless() already exist, these are > implemented as atomic accesses (e.g. READ_ONCE() in the default case). > So rather than using ptep_get() and risking performance regressions, > introduce an new variant. > > Call sites will be converted to use the accessor in future commits. > > Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> > --- > include/linux/pgtable.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index c5a51481bbb9..1161beab2492 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -204,6 +204,13 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma, > #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > #endif > > +#ifndef ptep_deref > +static inline pte_t ptep_deref(pte_t *ptep) > +{ > + return *(pte_t *)ptep; > +} > +#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,
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index c5a51481bbb9..1161beab2492 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -204,6 +204,13 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #endif +#ifndef ptep_deref +static inline pte_t ptep_deref(pte_t *ptep) +{ + return *(pte_t *)ptep; +} +#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,