From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with SMTP id 727996B0047 for ; Mon, 6 Sep 2010 01:47:42 -0400 (EDT) Received: from m4.gw.fujitsu.co.jp ([10.0.50.74]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id o865ldHK015259 for (envelope-from kamezawa.hiroyu@jp.fujitsu.com); Mon, 6 Sep 2010 14:47:39 +0900 Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 115D845DE60 for ; Mon, 6 Sep 2010 14:47:39 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id E53A845DE4D for ; Mon, 6 Sep 2010 14:47:38 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id CFEA31DB803A for ; Mon, 6 Sep 2010 14:47:38 +0900 (JST) Received: from m105.s.css.fujitsu.com (m105.s.css.fujitsu.com [10.249.87.105]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 844DE1DB8041 for ; Mon, 6 Sep 2010 14:47:35 +0900 (JST) Date: Mon, 6 Sep 2010 14:42:28 +0900 From: KAMEZAWA Hiroyuki Subject: [BUGFIX][PATCH 1/3] memory hotplug: fix next block calculation in is_removable Message-Id: <20100906144228.4ee5a738.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <20100906144019.946d3c49.kamezawa.hiroyu@jp.fujitsu.com> References: <20100906144019.946d3c49.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 , stable@kernel.org 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. CC: stable@kernel.org 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 > 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