summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPratyush Yadav (Google) <pratyush@kernel.org>2026-08-01 10:48:26 +0200
committerMike Rapoport (Microsoft) <rppt@kernel.org>2026-08-04 09:25:55 +0300
commit47a31168f86dc00d075ba925267f1a339840a06b (patch)
treee4c53dc9ba9e64d8e969f0c03491f6db2a12cf99 /include
parent01a0dd3d6fb73fa02ff775c9f4d8feff9e8265c0 (diff)
mm/mm_init: don't rely on memblock to get KHO scratch migratetype
Currently struct page init via memmap_init() or deferred_init_memmap() only queries the migrate type from KHO for each discrete memory range. That works currently since KHO scratch memory has a different memory type so it is always it its own region. An upcoming patch will add support for discovering blocks of memory with no preservations and it will mark it as MEMBLOCK_KHO_SCRATCH to allow allocations from them. This can lead to the bootmem KHO scratch areas to be merged into larger free ranges. This merging breaks the selection of migrate type. Get rid of memblock_is_kho_scratch_memory(). Instead, use kho_scratch_overlap() to decide the migrate type of the PFN. Since kho_scratch_migratetype() only uses KHO functions, move it to kexec_handover.h. Instead of calling kho_scratch_migratetype() once for each free range, call it once for each pageblock. Update pageblock_migratetype_init_range() and memmap_init_range() to do so. Since the migrate type is now evaluated for each pageblock and not each free range, drop the migratetype arguments to deferred_free_pages() and memmap_init_zone_range() and use MIGRATE_MOVABLE directly. Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org> Link: https://patch.msgid.link/20260801084833.1897543-18-pratyush@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/kexec_handover.h15
-rw-r--r--include/linux/memblock.h19
2 files changed, 15 insertions, 19 deletions
diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
index 18ba417f1ada..46de86dc343e 100644
--- a/include/linux/kexec_handover.h
+++ b/include/linux/kexec_handover.h
@@ -5,6 +5,7 @@
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/types.h>
+#include <linux/mm.h>
#include <asm-generic/kexec_handover.h>
struct kho_vmalloc;
@@ -39,6 +40,14 @@ void kho_populate(phys_addr_t fdt_phys, u64 fdt_len, phys_addr_t scratch_phys,
u64 scratch_len);
bool kho_scratch_overlap(phys_addr_t phys, size_t size);
+
+static inline enum migratetype kho_scratch_migratetype(unsigned long pfn,
+ enum migratetype mt)
+{
+ if (kho_scratch_overlap(PFN_PHYS(pfn), pageblock_nr_pages << PAGE_SHIFT))
+ return MIGRATE_CMA;
+ return mt;
+}
#else
static inline bool kho_is_enabled(void)
{
@@ -122,6 +131,12 @@ static inline bool kho_scratch_overlap(phys_addr_t phys, size_t size)
{
return false;
}
+
+static inline enum migratetype kho_scratch_migratetype(unsigned long pfn,
+ enum migratetype mt)
+{
+ return mt;
+}
#endif /* CONFIG_KEXEC_HANDOVER */
#endif /* LINUX_KEXEC_HANDOVER_H */
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 5afcd99aa8c1..f142c8a8cd5b 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -613,28 +613,9 @@ static inline void memtest_report_meminfo(struct seq_file *m) { }
#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH
void memblock_set_kho_scratch_only(void);
void memblock_clear_kho_scratch_only(void);
-bool memblock_is_kho_scratch_memory(phys_addr_t addr);
-
-static inline enum migratetype kho_scratch_migratetype(unsigned long pfn,
- enum migratetype mt)
-{
- if (memblock_is_kho_scratch_memory(PFN_PHYS(pfn)))
- return MIGRATE_CMA;
- return mt;
-}
#else
static inline void memblock_set_kho_scratch_only(void) { }
static inline void memblock_clear_kho_scratch_only(void) { }
-static inline bool memblock_is_kho_scratch_memory(phys_addr_t addr)
-{
- return false;
-}
-
-static inline enum migratetype kho_scratch_migratetype(unsigned long pfn,
- enum migratetype mt)
-{
- return mt;
-}
#endif
#endif /* _LINUX_MEMBLOCK_H */