From mboxrd@z Thu Jan 1 00:00:00 1970 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 714D1C77B7A for ; Wed, 24 May 2023 19:06:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0697E6B007B; Wed, 24 May 2023 15:06:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F34E66B007D; Wed, 24 May 2023 15:06:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD521900002; Wed, 24 May 2023 15:06:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CA9F96B007B for ; Wed, 24 May 2023 15:06:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 79A14A0A9E for ; Wed, 24 May 2023 19:06:44 +0000 (UTC) X-FDA: 80826080328.11.A25FD5E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id A627D4000C for ; Wed, 24 May 2023 19:06:42 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KhQs1INe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684955202; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tMQ9Sj5UKQodz5LU/7Nx1+G9aOkR7z7C6c3Pb9m//CE=; b=oNSuFO4nD/a4oWC3EdpFmnqy21h1aB6ck3xLqCTNqQHvnQtQthku7snfvjX/g3DPMOHfI+ UDXEigB0PQIipTvlIhn2XtCRUtE35TXKyYPlytw5C5Ow7+lhAZjpsBd25ZrHKLuO+3TfO6 bcp7DgMnAGkn+M0M+gq6FxjJoJA0Oy8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KhQs1INe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684955202; a=rsa-sha256; cv=none; b=WDeAfOsOToga5LHeXHyMzhAzy5V6JzBkTY6eWnHywZEGmNr+UaEbDTkK105z55vCuATSoQ 3duQitxWLTvjx3rj3ATmpfwp+Rv+d4vtzqKwxU40MuAHod2IvewEymesg8KE5aVWEpkFyZ v1RZ/1D+/S4bmH4csSWJZxWLSypmqPA= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7FBA760C6C; Wed, 24 May 2023 19:06:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7309C433D2; Wed, 24 May 2023 19:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684955200; bh=GVRc+Sp9w/3xXlBsQVu0Gt2t8xcE/XUdcs2PrknnrIU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KhQs1INe6kCzvHfogk+XSvMboZSn/7JsnDgsYzrpLC3uzaY72fqtCGJBwbZ6kgOwy KdiYU3k3pkgjkBvtBVB+6ZfojBBijCQZ1lPQLAJlreF6ZMhcE6ISQFwTGb2jRIB4k3 YrSNvcq+s2fga2YfhBwK9vdmdOK6lugfX0rovb2NfPhSYUB0b8slU7RKVKAx7kP+cd 6MTvp8O0W/K5mUfNhaI07Hr2eLyYU6CANtyTsmTP+Cdo6xVR2FmrsjZHIt9jZgzC9I NGWZWvaLg3pkzzRqa1mxCaB7kw4Z5GR70fCd53RJUtgYXsQu/6nwGtiKpBtqBnL1AG 3PQ58WowleodQ== Date: Wed, 24 May 2023 22:06:18 +0300 From: Mike Rapoport To: Ryan Roberts Cc: Andrew Morton , SeongJae Park , Christoph Hellwig , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Lorenzo Stoakes , Uladzislau Rezki , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: Re: [PATCH v2 4/5] mm: Add new ptep_deref() helper to fully encapsulate pte_t Message-ID: <20230524190618.GR4967@kernel.org> References: <20230518110727.2106156-1-ryan.roberts@arm.com> <20230518110727.2106156-5-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230518110727.2106156-5-ryan.roberts@arm.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A627D4000C X-Stat-Signature: jxxqoab9h9df18rcbc4otbbhgy9k1y7r X-Rspam-User: X-HE-Tag: 1684955202-700406 X-HE-Meta: U2FsdGVkX1/YKTEkiZtIUGHqdUdd5ctykwrEWyDb7SUDJkjJb6a9Fui6XGVs6wQTwDo+yKEqXnCLeQmmkgtUjUWdhABfj+J0vl/bw7AZT9/hnqgmbaNrwF2/d3ETFdGenGMU+ub2MObafKZ/mHfWH8ZVs0ky5B11Ce998EsY/eEUjBuFz5tGU8Ii81QdFZTF4++sDXF6ra5Gi31dNq8a1kg307vCcVcnm5k0DWoYJF50A+d9r4bjDRWlS0JhIXVyjJ/wPjQSCfy5oxDsgx8c4G+n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nSNLrP/R0LUeKQzr/DjIg= 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: On Thu, May 18, 2023 at 12:07:26PM +0100, 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 > --- > 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; Why do you need the casting here? > +} > +#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, > -- > 2.25.1 > > -- Sincerely yours, Mike.