From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with SMTP id 073936B004A for ; Mon, 6 Sep 2010 21:37:52 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o871bots016970 for (envelope-from kamezawa.hiroyu@jp.fujitsu.com); Tue, 7 Sep 2010 10:37:50 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 2733445DE55 for ; Tue, 7 Sep 2010 10:37:50 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id E94751EF082 for ; Tue, 7 Sep 2010 10:37:49 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id CAA951DB8038 for ; Tue, 7 Sep 2010 10:37:49 +0900 (JST) Received: from ml13.s.css.fujitsu.com (ml13.s.css.fujitsu.com [10.249.87.103]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 7EC0EE18006 for ; Tue, 7 Sep 2010 10:37:46 +0900 (JST) Date: Tue, 7 Sep 2010 10:32:44 +0900 From: KAMEZAWA Hiroyuki Subject: [PATCH 1/3] [BUGFIX] memory hotplug: fix next block calculation in is_removable Message-Id: <20100907103244.35eb6b71.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <20100907102813.d633b8ef.kamezawa.hiroyu@jp.fujitsu.com> References: <20100906144019.946d3c49.kamezawa.hiroyu@jp.fujitsu.com> <20100907102813.d633b8ef.kamezawa.hiroyu@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org To: KAMEZAWA Hiroyuki Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Michal Hocko , fengguang.wu@intel.com, "akpm@linux-foundation.org" , Mel Gorman , andi.kleen@intel.com, Dave Hansen List-ID: From: KAMEZAWA Hiroyuki next_active_pageblock() is for finding next _used_ freeblock. It skips several blocks when it finds there are a chunk of free pages lager than pageblock. But it has 2 bugs. 1. We have no lock. page_order(page) - pageblock_order can be minus. 2. pageblocks_stride += is wrong. it should skip page_order(p) of pages. Changelog: 2010/09/07 - fix range check of order returned by page_order(). Signed-off-by: KAMEZAWA Hiroyuki --- mm/memory_hotplug.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) Index: kametest/mm/memory_hotplug.c =================================================================== --- kametest.orig/mm/memory_hotplug.c +++ kametest/mm/memory_hotplug.c @@ -584,19 +584,19 @@ static inline int pageblock_free(struct /* Return the start of the next active pageblock after a given page */ static struct page *next_active_pageblock(struct page *page) { - int pageblocks_stride; - /* Ensure the starting page is pageblock-aligned */ BUG_ON(page_to_pfn(page) & (pageblock_nr_pages - 1)); - /* Move forward by at least 1 * pageblock_nr_pages */ - pageblocks_stride = 1; - /* If the entire pageblock is free, move to the end of free page */ - if (pageblock_free(page)) - pageblocks_stride += page_order(page) - pageblock_order; + if (pageblock_free(page)) { + int order; + /* be careful. we don't have locks, page_order can be changed.*/ + order = page_order(page); + if ((order < MAX_ORDER) && (order >= pageblock_order)) + return page + (1 << order); + } - return page + (pageblocks_stride * pageblock_nr_pages); + return page + pageblock_nr_pages; } /* Checks if this range of memory is likely to be hot-removable. */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org