Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754626AbdDOMTp (ORCPT ); Sat, 15 Apr 2017 08:19:45 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33660 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752796AbdDOMTI (ORCPT ); Sat, 15 Apr 2017 08:19:08 -0400 From: Michal Hocko To: linux-mm@kvack.org Cc: Andrew Morton , Mel Gorman , Vlastimil Babka , Andrea Arcangeli , Jerome Glisse , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Kani Toshimitsu , slaoub@gmail.com, Joonsoo Kim , Andi Kleen , David Rientjes , Daniel Kiper , Igor Mammedov , Vitaly Kuznetsov , LKML , Michal Hocko Subject: [PATCH 1/3] mm: consider zone which is not fully populated to have holes Date: Sat, 15 Apr 2017 14:17:32 +0200 Message-Id: <20170415121734.6692-2-mhocko@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170415121734.6692-1-mhocko@kernel.org> References: <20170410110351.12215-1-mhocko@kernel.org> <20170415121734.6692-1-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1446 Lines: 39 From: Michal Hocko __pageblock_pfn_to_page has two users currently, set_zone_contiguous which checks whether the given zone contains holes and pageblock_pfn_to_page which then carefully returns a first valid page from the given pfn range for the given zone. This doesn't handle zones which are not fully populated though. Memory pageblocks can be offlined or might not have been onlined yet. In such a case the zone should be considered to have holes otherwise pfn walkers can touch and play with offline pages. Current callers of pageblock_pfn_to_page in compaction seem to work properly right now because they only isolate PageBuddy (isolate_freepages_block) or PageLRU resp. __PageMovable (isolate_migratepages_block) which will be always false for these pages. It would be safer to skip these pages altogether, though. In order to do that let's check PageReserved in __pageblock_pfn_to_page because offline pages are reserved. Signed-off-by: Michal Hocko --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0cacba69ab04..dcbbcfdda60e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1351,6 +1351,8 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, return NULL; start_page = pfn_to_page(start_pfn); + if (PageReserved(start_page)) + return NULL; if (page_zone(start_page) != zone) return NULL; -- 2.11.0