Mel Gorman f332b9
From bdf90d473194123c6454f39790a72fa092907caa Mon Sep 17 00:00:00 2001
Mel Gorman f332b9
From: Naoya Horiguchi <naoya.horiguchi@nec.com>
Mel Gorman f332b9
Date: Thu, 2 Sep 2021 14:57:07 -0700
Mel Gorman f332b9
Subject: [PATCH] mm/sparse: set SECTION_NID_SHIFT to 6
Mel Gorman f332b9
Mel Gorman f332b9
References: bsc#1190208 (MM functional and performance backports)
Mel Gorman f332b9
Patch-mainline: v5.15-rc1
Mel Gorman f332b9
Git-commit: 01c8d337d195ed105cabab95bc4dcb9e145bf5ea
Mel Gorman f332b9
Mel Gorman f332b9
Currently SECTION_NID_SHIFT is set to 3, which is incorrect because bit 3
Mel Gorman f332b9
and 4 can be overlapped by sub-field for early NID, and can be
Mel Gorman f332b9
unexpectedly set on NUMA systems.  There are a few non-critical issues
Mel Gorman f332b9
related to this:
Mel Gorman f332b9
Mel Gorman f332b9
- Having SECTION_TAINT_ZONE_DEVICE set for wrong sections forces
Mel Gorman f332b9
  pfn_to_online_page() through the slow path, but doesn't actually break
Mel Gorman f332b9
  the kernel.
Mel Gorman f332b9
Mel Gorman f332b9
- A kdump generation tool like makedumpfile uses this field to calculate
Mel Gorman f332b9
  the physical address to read.  So wrong bits can make the tool access to
Mel Gorman f332b9
  wrong address and fail to create kdump.  This can be avoided by the
Mel Gorman f332b9
  tool, so it's not critical.
Mel Gorman f332b9
Mel Gorman f332b9
To fix it, set SECTION_NID_SHIFT to 6 which is the minimum number of
Mel Gorman f332b9
available bits of section flag field.
Mel Gorman f332b9
Mel Gorman f332b9
Link: https://lkml.kernel.org/r/20210707045548.810271-1-naoya.horiguchi@linux.dev
Mel Gorman f332b9
Fixes: 1f90a3477df3 ("mm: teach pfn_to_online_page() about ZONE_DEVICE section collisions")
Mel Gorman f332b9
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Mel Gorman f332b9
Reported-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Mel Gorman f332b9
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Mel Gorman f332b9
Acked-by: David Hildenbrand <david@redhat.com>
Mel Gorman f332b9
Cc: Oscar Salvador <osalvador@suse.de>
Mel Gorman f332b9
Cc: Wang Wensheng <wangwensheng4@huawei.com>
Mel Gorman f332b9
Cc: Rui Xiang <rui.xiang@huawei.com>
Mel Gorman f332b9
Cc: Kazu <k-hagio-ab@nec.com>
Mel Gorman f332b9
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Mel Gorman f332b9
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Mel Gorman f332b9
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Mel Gorman f332b9
Signed-off-by: Mel Gorman <mgorman@suse.de>
Mel Gorman f332b9
---
Mel Gorman f332b9
 include/linux/mmzone.h | 2 +-
Mel Gorman f332b9
 1 file changed, 1 insertion(+), 1 deletion(-)
Mel Gorman f332b9
Mel Gorman f332b9
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
Mel Gorman f332b9
index 8827f4d081d4..59bad25ce78e 100644
Mel Gorman f332b9
--- a/include/linux/mmzone.h
Mel Gorman f332b9
+++ b/include/linux/mmzone.h
Mel Gorman f332b9
@@ -1364,7 +1364,7 @@ extern size_t mem_section_usage_size(void);
Mel Gorman f332b9
 #define SECTION_TAINT_ZONE_DEVICE	(1UL<<4)
Mel Gorman f332b9
 #define SECTION_MAP_LAST_BIT		(1UL<<5)
Mel Gorman f332b9
 #define SECTION_MAP_MASK		(~(SECTION_MAP_LAST_BIT-1))
Mel Gorman f332b9
-#define SECTION_NID_SHIFT		3
Mel Gorman f332b9
+#define SECTION_NID_SHIFT		6
Mel Gorman f332b9
 
Mel Gorman f332b9
 static inline struct page *__section_mem_map_addr(struct mem_section *section)
Mel Gorman f332b9
 {