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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77BFDC47422 for ; Mon, 29 Jan 2024 11:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ShoMx/O1xcA3Ezd1en8MqEemz2cwJ4anXQwcRasXmA4=; b=bRZ7BmXCQhkLCU CjRtr90+S2+STIqf9nyP8lNuPqPpNtxfutixhrAj+AoqjpVSw1pP95Zhio/tiIpq8LKFYSwnb18t3 l9w3zqyHe8seEjPI2cQIiZ7ae3iOl74e4C4wiLwZbgefPEw2/gJjHxzQ7JyN8LFdexzWMCrUY+IRo C8GV/Ed8fZJQdu36qTo83NymuMjgIKMOWKPaN4LnA/Ax7ZjlsIoeaU980apARyjz3pzZhRmqBlcRx AF4G1yUDR3mygah0oWDxgd3hFux546dS+pSRPyOZrJlJ1pS3URWp9x4Aovh0amOcf+53rYC2LWwM8 UlzX1AgL71TvAb/BlM4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUQ2C-0000000CQtq-2jxa; Mon, 29 Jan 2024 11:42:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUQ29-0000000CQrY-3V26 for linux-arm-kernel@lists.infradead.org; Mon, 29 Jan 2024 11:42:39 +0000 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 542A3DA7; Mon, 29 Jan 2024 03:43:17 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C3433F5A1; Mon, 29 Jan 2024 03:42:27 -0800 (PST) Date: Mon, 29 Jan 2024 11:42:25 +0000 From: Alexandru Elisei To: Anshuman Khandual Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC v3 02/35] mm: page_alloc: Add an arch hook early in free_pages_prepare() Message-ID: References: <20240125164256.4147-1-alexandru.elisei@arm.com> <20240125164256.4147-3-alexandru.elisei@arm.com> <8d1c6b04-105e-4fb2-b514-1c5dea0fcce6@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8d1c6b04-105e-4fb2-b514-1c5dea0fcce6@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240129_034238_075054_CBBA7674 X-CRM114-Status: GOOD ( 26.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Mon, Jan 29, 2024 at 01:49:44PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > The arm64 MTE code uses the PG_arch_2 page flag, which it renames to > > PG_mte_tagged, to track if a page has been mapped with tagging enabled. > > That flag is cleared by free_pages_prepare() by doing: > > > > page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; > > > > When tag storage management is added, tag storage will be reserved for a > > page if and only if the page is mapped as tagged (the page flag > > PG_mte_tagged is set). When a page is freed, likewise, the code will have > > to look at the the page flags to determine if the page has tag storage > > reserved, which should also be freed. > > > > For this purpose, add an arch_free_pages_prepare() hook that is called > > before that page flags are cleared. The function arch_free_page() has also > > been considered for this purpose, but it is called after the flags are > > cleared. > > arch_free_pages_prepare() makes sense as a prologue to arch_free_page(). Thanks! > > s/arch_free_pages_prepare/arch_free_page_prepare to match similar functions. The function free_pages_prepare() calls the function arch_free_pages_prepare(). I find that consistent, and it makes it easy to identify from where arch_free_pages_prepare() is called. Thanks, Alex > > > > > Signed-off-by: Alexandru Elisei > > --- > > > > Changes since rfc v2: > > > > * Expanded commit message (David Hildenbrand). > > > > include/linux/pgtable.h | 4 ++++ > > mm/page_alloc.c | 1 + > > 2 files changed, 5 insertions(+) > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > index f6d0e3513948..6d98d5fdd697 100644 > > --- a/include/linux/pgtable.h > > +++ b/include/linux/pgtable.h > > @@ -901,6 +901,10 @@ static inline void arch_do_swap_page(struct mm_struct *mm, > > } > > #endif > > > > +#ifndef __HAVE_ARCH_FREE_PAGES_PREPARE > > I guess new __HAVE_ARCH_ constructs are not being added lately. Instead > something like '#ifndef arch_free_pages_prepare' might be better suited. > > > +static inline void arch_free_pages_prepare(struct page *page, int order) { } > > +#endif > > + > > #ifndef __HAVE_ARCH_UNMAP_ONE > > /* > > * Some architectures support metadata associated with a page. When a > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 2c140abe5ee6..27282a1c82fe 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -1092,6 +1092,7 @@ static __always_inline bool free_pages_prepare(struct page *page, > > > > trace_mm_page_free(page, order); > > kmsan_free_page(page, order); > > + arch_free_pages_prepare(page, order); > > > > if (memcg_kmem_online() && PageMemcgKmem(page)) > > __memcg_kmem_uncharge_page(page, order); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel