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 EB664C47422 for ; Thu, 25 Jan 2024 16:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C2656B009B; Thu, 25 Jan 2024 11:43:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6746F6B009C; Thu, 25 Jan 2024 11:43:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53BEC6B009D; Thu, 25 Jan 2024 11:43:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4711F6B009B for ; Thu, 25 Jan 2024 11:43:01 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2A7B61C1884 for ; Thu, 25 Jan 2024 16:43:01 +0000 (UTC) X-FDA: 81718402962.07.B5B16BB Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP id 74B2DA000C for ; Thu, 25 Jan 2024 16:42:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706200979; a=rsa-sha256; cv=none; b=cUDgOx2vo/YtbhF+5CjjF6Xoilp/I2aqUXi+pbjFL14HidML85TuMvNwImkBt08zc4elOt jHQqbG0+E22NS6gTlRBDDtxNn/e+0hjC6bM3m2DBDFM+eElmvG5DbrG83kQVqRLc1WG/OU yZGz1md0WpcAhYP+Xf6dRM0XCocp1gE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706200979; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wwaMmcFR+7gYAKWJTVbpRrP8BqwS476rsGrY3piUjRU=; b=dP+4ErrOoU8NbCekAKpaX+m/FrQiPA5UVj+/TOKcurkbrU34Cr10DBTdwcvksHdpKLnJ2e rq57tuws1WT7PP7gAsb+oNL/AUGDZNPT3SV/RViZxrnK20vnV+xk4yyJarQfJSbDLPOJB1 bsXi856laSilG3AysGHbMw5FrwSoRZ8= 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 13EB31476; Thu, 25 Jan 2024 08:43:43 -0800 (PST) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 219223F5A1; Thu, 25 Jan 2024 08:42:52 -0800 (PST) From: Alexandru Elisei To: 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 Cc: pcc@google.com, steven.price@arm.com, anshuman.khandual@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: [PATCH RFC v3 02/35] mm: page_alloc: Add an arch hook early in free_pages_prepare() Date: Thu, 25 Jan 2024 16:42:23 +0000 Message-Id: <20240125164256.4147-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125164256.4147-1-alexandru.elisei@arm.com> References: <20240125164256.4147-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 74B2DA000C X-Stat-Signature: giz7sezkfxxj594sw1bdedpm5t9sgeu4 X-HE-Tag: 1706200979-424301 X-HE-Meta: U2FsdGVkX18udFxVcI1aAfD2ffzQmvALs8CqQOE9a5vCvUPTZEipdhEJQFyHZDJfVP64RNDXKcZhnnTwLAdiU5U95PmVWj0ar2gRW/U9B25RERYejfGqh+EdI2kCT5x+18RpO4cH6ZuVdKlhbzJUPQ3CAgkI7WiJUXWv9xapYp6+FekF7h7H95rcnzGj6IvQqdgFEoIgH0ugH9qnZeCUE3eL8mY7w4TRupopcg3AbVsDuAW98sADFE5NWNAaVGXyHqEu9iXj5Tcfzbj7qcqZ7EZXTJsrg0ZpVjWmbUhavFc3so9GNC7W2N1iNQ8hK3PFCt3EPVOlHbk2rJpy7fnyscp8l06upIDTaHxvvyNRqFzw1DWQnirokmzExkkXeBEpgKPrHek+y+oYgKTngxzKNHUTb1Ax+kpbTytcZOc8D1REMGWd3xTl3YUZsLZc/ASE5j5XvZmvqYWY29fPMbl2dIFTL67jvCcxR3KLof4UUHCLnG71Azv2Zpr43xoI/lR129oiIC6uePx1eTHi9j01AWCo7/OZDxjo9U7CJiAkjDH4PmPFPIDsFvDJjjmX9541f79h+DUtYEZ3uJmp3dSiPUEWnIDJK7sROUhPh24LWAwz37y9iGe81KavWnGN9dQFIp7pzWRM1c+BffcRX6MQiqvwx4zI/0x+0+lW+Y/vJeBpYkrRnQwMRqst8hY9/zBk/1ixA1z5+nQv9vtbbjwZme8xownjgpuATvpDH57LnpW93tWyPEi/eb6PLlzzUcjSGpeyp2S+A/32IjW/LOaKxpo3k4YUSUCgdauK2vKjzConQrVi88rPswNtkiHbcVl6G1tv3eIA4jobmGbmIDkZuikWFZljmSJjGrxfvIqR1Yh5/H+y0rJ8k5lyjUaLYkEsVBiZrV4YS33GJIToEh66VzJggVsqgl7XSyyiCCayl45EjHSkvYA1+uwndZC6l33qJEgjw52rcCmPCLKAaLA pL8TGd6I 4sa55emOducHxdVszDb3hqD2TVfE7WE5KbEl4UphOP7S7BOuCIEmnnmjWoQT2WreipYqwRsvDaUxZH2YTbZGn1D/FBUPKjPs3IYL2CVcctjEZwpnlEWNCpW94+02pXL/OWN83ZyHwfCoG+fE16FR7traCQV4C884HHeOoxCftNgY+Hl1SQM1o2AS4hI24o1qD06aoefVt4rg8n9Y= 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: List-Subscribe: List-Unsubscribe: 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. 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 +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); -- 2.43.0