Skip to contentSkip to conversation

FAILED: patch "[PATCH] kho: init alloc tags when restoring pages from reserved" failed to apply to 6.18-stable tree

PATCH In review [email protected] 4 participants 8 messages Feb 3 – Feb 5

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026020303-drippy-appliance-a74c@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 Mon Sep 17 00:00:00 2001
From: Ran Xiaokai <[email protected]>
Date: Thu, 22 Jan 2026 13:27:40 +0000
Subject: [PATCH] kho: init alloc tags when restoring pages from reserved
memory

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
kernel/liveupdate/kexec_handover.c +8 -0
index d4482b6e3cae..96767b106cac 100644
@@ -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);
 
+	/* 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 = 1; i < nr_pages; i++)
+			clear_page_tag_ref(page + i);
+	}
+
 	adjust_managed_page_count(page, nr_pages);
 	return page;
 }
maintainer
#1 lore raw

PATCH 1/1 kho: init alloc tags when restoring pages from reserved memory

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +8 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
 	if (info.order > 0)
 		prep_compound_page(page, info.order);
 
+	/* 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 = 1; i < nr_pages; i++)
+			clear_page_tag_ref(page + i);
+	}
+
 	adjust_managed_page_count(page, nr_pages);
 	return page;
 }
Signature · 1 line
2.51.0
author maintainer
#2 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

Quoted 45 lines · Sasha Levin

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
 	if (info.order > 0)

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 10 lines
kernel/kexec_handover.c +8 -0
 		prep_compound_page(page, info.order);
 
+	/* 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 = 1; i < nr_pages; i++)
+			clear_page_tag_ref(page + i);
+	}
+

Breaks the build :(

#3 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

Quoted 49 lines · Greg KH
Quoted 47 lines · Sasha Levin

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
      if (info.order > 0)
              prep_compound_page(page, info.order);
 
Quoted 10 lines

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 8 lines
kernel/kexec_handover.c +8 -0
+     /* 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 = 1; i < nr_pages; i++)
+                     clear_page_tag_ref(page + i);
+     }
+

Breaks the build :(

Which config? I built both defconfig and CONFIG_MEM_ALLOC_PROFILING=y, they didn't fail. Could you please send me your failing config?

Quoted 1 line
author maintainer
#4 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

Quoted 61 lines · Suren Baghdasaryan
Quoted 49 lines · Greg KH
Quoted 47 lines · Sasha Levin

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
      if (info.order > 0)
              prep_compound_page(page, info.order);
 
Quoted 10 lines

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 8 lines
kernel/kexec_handover.c +8 -0
+     /* 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 = 1; i < nr_pages; i++)
+                     clear_page_tag_ref(page + i);
+     }
+

Breaks the build :(

Quoted 2 lines

Which config? I built both defconfig and CONFIG_MEM_ALLOC_PROFILING=y, they didn't fail. Could you please send me your failing config?

is_folio is not defined in this function, how are you even building this file?

thanks,

greg k-h

maintainer
#5 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

Quoted 62 lines · Greg KH
Quoted 61 lines · Suren Baghdasaryan
Quoted 59 lines · Greg KH
Quoted 45 lines · Sasha Levin

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
      if (info.order > 0)

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 10 lines
kernel/kexec_handover.c +8 -0
              prep_compound_page(page, info.order);
 
+     /* 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 = 1; i < nr_pages; i++)
+                     clear_page_tag_ref(page + i);
+     }
+

Breaks the build :(

Quoted 5 lines
Quoted 2 lines

Which config? I built both defconfig and CONFIG_MEM_ALLOC_PROFILING=y, they didn't fail. Could you please send me your failing config?

is_folio is not defined in this function, how are you even building this file?

This is a stupid issue I've hit last time too: allmodconfig sets CONFIG_DEFERRED_STRUCT_PAGE_INIT=y which disables KHO.

I'll figure out a patch that still builds KHO if CONFIG_COMPILE_TEST is set, unless someone beats be to it...

Signature · 2 lines
Thanks,
Sasha
#6 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

Quoted 64 lines · Sasha Levin
Quoted 62 lines · Greg KH
Quoted 61 lines · Suren Baghdasaryan
Quoted 59 lines · Greg KH
Quoted 45 lines · Sasha Levin

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
      if (info.order > 0)

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 10 lines
kernel/kexec_handover.c +8 -0
              prep_compound_page(page, info.order);
 
+     /* 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 = 1; i < nr_pages; i++)
+                     clear_page_tag_ref(page + i);
+     }
+

Breaks the build :(

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Which config? I built both defconfig and CONFIG_MEM_ALLOC_PROFILING=y, they didn't fail. Could you please send me your failing config?

is_folio is not defined in this function, how are you even building this file?

This is a stupid issue I've hit last time too: allmodconfig sets CONFIG_DEFERRED_STRUCT_PAGE_INIT=y which disables KHO.

Yeah, that's what hit me too. The file is not complied with defconfigs.

Quoted 7 lines

I'll figure out a patch that still builds KHO if CONFIG_COMPILE_TEST is set, unless someone beats be to it...

--
Thanks,
Sasha

#7 lore raw

Re: [PATCH 6.18.y] kho: init alloc tags when restoring pages from reserved memory

In reply to Greg KH

Hi, Greg

Quoted 62 lines · Suren Baghdasaryan
Quoted 61 lines · On Wed, Feb 4, 2026 at 1:59?AM Greg KH <[email protected]> wrote:
Quoted 59 lines · Sasha Levin
Quoted 45 lines

From: Ran Xiaokai <[email protected]>

[ Upstream commit e86436ad0ad2a9aaf88802d69b68f02cbd1f04a9 ]

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 Alexander Graf <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
---
 kernel/kexec_handover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/kexec_handover.c +0 -0
index 03d12e27189fc..db08c1a2e1f80 100644
@@ -260,6 +260,14 @@ static struct page *kho_restore_page(phys_addr_t phys)
      if (info.order > 0)

kernel/kexec_handover.c static struct page *kho_restore_page(phys_addr_t phys) · line 270

Quoted 10 lines
kernel/kexec_handover.c +8 -0
              prep_compound_page(page, info.order);
 
+     /* 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 = 1; i < nr_pages; i++)
+                     clear_page_tag_ref(page + i);
+     }
+

Breaks the build :(

Quoted 5 lines
Quoted 2 lines

Which config? I built both defconfig and CONFIG_MEM_ALLOC_PROFILING=y, they didn't fail. Could you please send me your failing config?

is_folio is not defined in this function, how are you even building this file?

This fix is based on commit 7b71205ae112 0e90c7f6d41d282e26c00e9ee6a7. Therefore we would need to backport that prerequisite commit first. I'm not sure whether it's worth the effort for a stable backport ?

On a related note, Pratyush's series
https://lore.kernel.org/all/[email protected]/
is currently refactoring this code area.
Perhaps we should wait for that series to land upstream and directly user Pratyush's code for the stable tree?

Quoted 3 lines

thanks,

greg k-h