[RFC PATCH 04/12] mm: add mirrored pages to buddy system

From: Xishi Qiu
Date: Thu Jun 04 2015 - 09:01:40 EST


Set mirrored pageblock's migratetype to MIGRATE_MIRROR, so they could free to
buddy system's MIGRATE_MIRROR list when free bootmem.

Signed-off-by: Xishi Qiu <qiuxishi@xxxxxxxxxx>
---
mm/page_alloc.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3b2ff46..8fe0187 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -572,6 +572,25 @@ static void __init print_mirror_info(void)
mirror_info.info[i].start +
mirror_info.info[i].size - 1);
}
+
+static inline bool is_mirror_pfn(unsigned long pfn)
+{
+ int i;
+ unsigned long addr = pfn << PAGE_SHIFT;
+
+ /* 0-4G is always mirrored, so ignore it */
+ if (addr < (4UL << 30))
+ return false;
+
+ for (i = 0; i < mirror_info.count; i++) {
+ if (addr >= mirror_info.info[i].start &&
+ addr < mirror_info.info[i].start +
+ mirror_info.info[i].size)
+ return true;
+ }
+
+ return false;
+}
#endif

/*
@@ -4147,6 +4166,9 @@ static void setup_zone_migrate_reserve(struct zone *zone)

block_migratetype = get_pageblock_migratetype(page);

+ if (is_migrate_mirror(block_migratetype))
+ continue;
+
/* Only test what is necessary when the reserves are not met */
if (reserve > 0) {
/*
@@ -4246,6 +4268,11 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
&& !(pfn & (pageblock_nr_pages - 1)))
set_pageblock_migratetype(page, MIGRATE_MOVABLE);

+#ifdef CONFIG_MEMORY_MIRROR
+ if (is_mirror_pfn(pfn))
+ set_pageblock_migratetype(page, MIGRATE_MIRROR);
+#endif
+
INIT_LIST_HEAD(&page->lru);
#ifdef WANT_PAGE_VIRTUAL
/* The shift won't overflow because ZONE_NORMAL is below 4G. */
--
2.0.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/