From nobody Sun Feb 8 19:44:24 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 2A83131B803; Thu, 22 Jan 2026 13:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769088550; cv=none; b=Bx1GXLNBRl5J09jroDk2O6+xmNyO5mj4I4MMGpeS/iZJ9CdG9MpxG52Dh5q5fLR2Dova6fHHDCCToFVYhW7fdgCTl2y2hiLq0ZVxFgNHAjQxonhBu9HRm+UShT8qsjXSOx7oFwyXsRtGXXFYKXbtqFaNDITsmzBcSsAa4RKukHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769088550; c=relaxed/simple; bh=m9U6Y+bSWTgs4pYYcQrqD8WdR2YkpRXqY9YeVrThtjA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Pe6BeFIf7FyFc6gwFBt9ojFuSleVZKfszD/I9nssGdCFpWZ+9HakMDhiRU9tjqjsF1EbKJwycMWzoFgPIGXGf0FyW7eE+MM5uhrUj0wwLjr29SYJ6Y5FELSfD9GQoNADV4kLqZkobiOqSU+5hoqLiMKfnjd2aha86Wj32H0RGhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=dC1wa78e; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="dC1wa78e" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=e+ 6gDoaU6sjJYiXvvo+102yEP3zTOi6BPXPONrmdz8k=; b=dC1wa78esyeMyra8fB Ue5iSWNlHlVvxuY3NcWOQse2SSMGWXKuMf6PBV/dz1nnHH2I/C4v74o5OT5qoye7 M21pKWJm/hmqwHr0UcNJiKjxzX+ocJ4dj9uLykTa1YoKx5Hnu6EcPpzUexqLwxjV BNOA1Ag/wMheQnO8B32WwAWEs= Received: from ubuntu24-z.. (unknown []) by gzsmtp5 (Coremail) with SMTP id QCgvCgAnE2TOJXJpoBt0MQ--.31S2; Thu, 22 Jan 2026 21:27:46 +0800 (CST) From: ranxiaokai627@163.com To: pratyush@kernel.org, surenb@google.com, akpm@linux-foundation.org Cc: pasha.tatashin@soleen.com, kent.overstreet@linux.dev, rppt@kernel.org, graf@amazon.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, ran.xiaokai@zte.com.cn, ranxiaokai627@163.com, stable@vger.kernel.org Subject: [PATCH RESEND v3] kho: init alloc tags when restoring pages from reserved memory Date: Thu, 22 Jan 2026 13:27:40 +0000 Message-ID: <20260122132740.176468-1-ranxiaokai627@163.com> X-Mailer: git-send-email 2.43.0 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 X-CM-TRANSID: QCgvCgAnE2TOJXJpoBt0MQ--.31S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ArWkWr1xuFWrXFyruw4xXrb_yoW8CFWDpr WUJr1kt3y5JwnrZws2va4vk34fXws5C3y5Jasru34fZF13Awn2yas7ZFy0vF15Zr4FvF48 Wr4UXrZ0v3WYk3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piFdgJUUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbCxRJ0wGlyJdLrAwAA3n Content-Type: text/plain; charset="utf-8" From: Ran Xiaokai Memblock pages (including reserved memory) should have their allocation tags initialized to CODETAG_EMPTY via clear_page_tag_ref() before being released to the page allocator. When kho restores pages through kho_restore_page(), missing this call causes mismatched allocation/deallocation tracking and below warning message: alloc_tag was not set WARNING: include/linux/alloc_tag.h:164 at ___free_pages+0xb8/0x260, CPU#1: = swapper/0/1 RIP: 0010:___free_pages+0xb8/0x260 kho_restore_vmalloc+0x187/0x2e0 kho_test_init+0x3c4/0xa30 do_one_initcall+0x62/0x2b0 kernel_init_freeable+0x25b/0x480 kernel_init+0x1a/0x1c0 ret_from_fork+0x2d1/0x360 Add missing clear_page_tag_ref() annotation in kho_restore_page() to fix this. Fixes: fc33e4b44b27 ("kexec: enable KHO support for memory preservation") Cc: Signed-off-by: Ran Xiaokai Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Pasha Tatashin Reviewed-by: Pratyush Yadav --- v2 -> v3:=20 - also call clear_page_tag_ref() for non-compound order-0 tail pages kernel/liveupdate/kexec_handover.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index d4482b6e3cae..96767b106cac 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -255,6 +255,14 @@ static struct page *kho_restore_page(phys_addr_t phys,= bool is_folio) if (is_folio && info.order) prep_compound_page(page, info.order); =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; } --=20 2.25.1