From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753602AbbFDNBh (ORCPT ); Thu, 4 Jun 2015 09:01:37 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:14356 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753485AbbFDNBc (ORCPT ); Thu, 4 Jun 2015 09:01:32 -0400 Message-ID: <55704BB0.7030606@huawei.com> Date: Thu, 4 Jun 2015 20:59:28 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Xishi Qiu , Andrew Morton , , Yinghai Lu , "H. Peter Anvin" , Thomas Gleixner , , Xiexiuqi , Hanjun Guo , "Luck, Tony" CC: Linux MM , LKML Subject: [RFC PATCH 04/12] mm: add mirrored pages to buddy system References: <55704A7E.5030507@huawei.com> In-Reply-To: <55704A7E.5030507@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.55704C24.0251,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ac22dc14693d4b71eb516754a7b3eca3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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