[PATCHv4 06/14] mm: Make page_zonenum() use head page

Kiryl Shutsemau posted 14 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCHv4 06/14] mm: Make page_zonenum() use head page
Posted by Kiryl Shutsemau 2 weeks, 4 days ago
With the upcoming changes to HVO, a single page of tail struct pages
will be shared across all huge pages of the same order on a node. Since
huge pages on the same node may belong to different zones, the zone
information stored in shared tail page flags would be incorrect.

Always fetch zone information from the head page, which has unique and
correct zone flags for each compound page.

Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
---
 include/linux/mmzone.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 6cfede39570a..390ce11b3765 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1223,6 +1223,7 @@ static inline enum zone_type memdesc_zonenum(memdesc_flags_t flags)
 
 static inline enum zone_type page_zonenum(const struct page *page)
 {
+	page = compound_head(page);
 	return memdesc_zonenum(page->flags);
 }
 
-- 
2.51.2
Re: [PATCHv4 06/14] mm: Make page_zonenum() use head page
Posted by Zi Yan 2 weeks, 4 days ago
On 21 Jan 2026, at 11:22, Kiryl Shutsemau wrote:

> With the upcoming changes to HVO, a single page of tail struct pages
> will be shared across all huge pages of the same order on a node. Since
> huge pages on the same node may belong to different zones, the zone
> information stored in shared tail page flags would be incorrect.
>
> Always fetch zone information from the head page, which has unique and
> correct zone flags for each compound page.
>
> Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> ---
>  include/linux/mmzone.h | 1 +
>  1 file changed, 1 insertion(+)
>
Make sense.

Acked-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi