From nobody Thu Apr 2 20:26:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FBCB34B1A6 for ; Fri, 13 Feb 2026 08:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770973166; cv=none; b=KOd8aq1m+AbILkL8NBADQistnQVpDoQX8BPttztHrbxz6mEFEFV25mK9k56nzIkgLKLE5KuYClgsl+LbbHde0xDKqz/NMHOwx+sE0NVNZALnrahuap0cxEG3sY0CEfwELs0Ph6TwKpUmZh2m7hnG1O+/iJLjPGGQ2Q5wcHok+V4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770973166; c=relaxed/simple; bh=uixbDt7OlKbJ5MtQyLaeFtlWYMi840nDFBt1QnEFSsc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bDBJB01IZbXWk3vP4D9yP3m6+QQtYGIZ1AUuR/IIoQrgYy/v/M5HJZ2GVE94qEoh38VTsz8gfr5TYzD/4kpPHg6/LBt08onfFYSjvn0llK+U4MmCvR1o+jxd3p97iUNpZYqFiuTJ7St2j65HjCOg4901YLap7+Kjn4fveY+Xby8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r9Sz6PR1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r9Sz6PR1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E6F5C116C6; Fri, 13 Feb 2026 08:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770973165; bh=uixbDt7OlKbJ5MtQyLaeFtlWYMi840nDFBt1QnEFSsc=; h=From:To:Cc:Subject:Date:From; b=r9Sz6PR1rjD1VMrg9L/5/Ux78jvnREicHVYwULG0PiEJ4UwXVrVv/7uwmQpvHNhVM 2kyITMiYnmhPCd9qvMdqUpAQ0+nvhhU1fWC0mXa4V8McB7UOAMvUkJsSeKze3g8xpC XBdvShAEp5sQBw35nMh0CpIKij/oHmN8//EVYE//lLCNG35Xr5evy6w8aPtN3cYGBB Kx+z1qNt7jz+Xgz4RSvwc96iu0rOIYEJYZ64FDLAKDf7riR7y3En8nhQ8ekOmJZ8zf XDSwaCWHGJKNV34mi0yptyGLH7Q4NKPZFReqTj2bR/XAypiWt9nZ1Of63p2H70ymIS oFewsJTbK+uug== From: Pratyush Yadav To: Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Andrew Morton , Alexander Graf Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] kho: move alloc tag init to kho_init_{folio,pages}() Date: Fri, 13 Feb 2026 09:59:12 +0100 Message-ID: <20260213085914.2778107-1-pratyush@kernel.org> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Pratyush Yadav (Google)" Commit 8f1081892d62 ("kho: simplify page initialization in kho_restore_page()") cleaned up the page initialization logic by moving the folio and 0-order-page paths into separate functions. It missed moving the alloc tag initialization. Do it now to keep the two paths cleanly separated. While at it, touch up the comments to be a tiny bit shorter (mainly so it doesn't end up splitting into a multiline comment). This is purely a cosmetic change and there should be no change in behaviour. Signed-off-by: Pratyush Yadav (Google) --- Notes: The patch for e86436ad0ad2 ("kho: init alloc tags when restoring pages from reserved memory") was posted after the patch for 8f1081892d62 ("kho: simplify page initialization in kho_restore_page()"), but landed in mainline before it because it went through the hotfixes path. This led to the simplification patch missing the code tag bits. I don't think any of this is worth explaining in the commit message, so I just left it at "missed moving the alloc tags..." =20 Tested on a qemu VM with CONFIG_MEM_ALLOC_PROFILING_DEBUG enabled. Not adding a Fixes tag here since this isn't a bug fix, only a cosmetic fix. kernel/liveupdate/kexec_handover.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 95601623b4d6..7e5d805fa1fe 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -219,8 +219,11 @@ static int __kho_preserve_order(struct kho_mem_track *= track, unsigned long pfn, /* For physically contiguous 0-order pages. */ static void kho_init_pages(struct page *page, unsigned long nr_pages) { - for (unsigned long i =3D 0; i < nr_pages; i++) + for (unsigned long i =3D 0; i < nr_pages; i++) { set_page_count(page + i, 1); + /* Clear each page's codetag to avoid accounting mismatch. */ + clear_page_tag_ref(page + i); + } } =20 static void kho_init_folio(struct page *page, unsigned int order) @@ -229,6 +232,8 @@ static void kho_init_folio(struct page *page, unsigned = int order) =20 /* Head page gets refcount of 1. */ set_page_count(page, 1); + /* Clear head page's codetag to avoid accounting mismatch. */ + clear_page_tag_ref(page); =20 /* For higher order folios, tail pages get a page count of zero. */ for (unsigned long i =3D 1; i < nr_pages; i++) @@ -265,14 +270,6 @@ static struct page *kho_restore_page(phys_addr_t phys,= bool is_folio) else kho_init_pages(page, nr_pages); =20 - /* Always mark headpage's codetag as empty to avoid accounting mismatch */ - clear_page_tag_ref(page); - if (!is_folio) { - /* Also do that for the non-compound tail pages */ - for (unsigned int i =3D 1; i < nr_pages; i++) - clear_page_tag_ref(page + i); - } - adjust_managed_page_count(page, nr_pages); return page; } base-commit: 6c8dd4f02805de481c200636e567a871f25399a2 --=20 2.53.0.335.g19a08e0c02-goog