From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx166.postini.com [74.125.245.166]) by kanga.kvack.org (Postfix) with SMTP id 875296B0072 for ; Fri, 27 Jul 2012 06:25:19 -0400 (EDT) Received: from m1.gw.fujitsu.co.jp (unknown [10.0.50.71]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 9DF783EE0C0 for ; Fri, 27 Jul 2012 19:25:17 +0900 (JST) Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 830F645DE5D for ; Fri, 27 Jul 2012 19:25:17 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 690F445DE55 for ; Fri, 27 Jul 2012 19:25:17 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 5737B1DB8056 for ; Fri, 27 Jul 2012 19:25:17 +0900 (JST) Received: from m1001.s.css.fujitsu.com (m1001.s.css.fujitsu.com [10.240.81.139]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 0E12A1DB8044 for ; Fri, 27 Jul 2012 19:25:17 +0900 (JST) Message-ID: <50126BF8.3070901@jp.fujitsu.com> Date: Fri, 27 Jul 2012 19:22:48 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: [RESEND RFC 3/3] memory-hotplug: bug fix race between isolation and allocation References: <1343004482-6916-1-git-send-email-minchan@kernel.org> <1343004482-6916-4-git-send-email-minchan@kernel.org> In-Reply-To: <1343004482-6916-4-git-send-email-minchan@kernel.org> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim Cc: Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , KOSAKI Motohiro , Hugh Dickins , lliubbo@gmail.com (2012/07/23 9:48), Minchan Kim wrote: > Like below, memory-hotplug makes race between page-isolation > and page-allocation so it can hit BUG_ON in __offline_isolated_pages. > > CPU A CPU B > > start_isolate_page_range > set_migratetype_isolate > spin_lock_irqsave(zone->lock) > > free_hot_cold_page(Page A) > /* without zone->lock */ > migratetype = get_pageblock_migratetype(Page A); > /* > * Page could be moved into MIGRATE_MOVABLE > * of per_cpu_pages > */ > list_add_tail(&page->lru, &pcp->lists[migratetype]); > > set_pageblock_isolate > move_freepages_block > drain_all_pages > > /* Page A could be in MIGRATE_MOVABLE of free_list. */ > > check_pages_isolated > __test_page_isolated_in_pageblock > /* > * We can't catch freed page which > * is free_list[MIGRATE_MOVABLE] > */ > if (PageBuddy(page A)) > pfn += 1 << page_order(page A); > > /* So, Page A could be allocated */ > > __offline_isolated_pages > /* > * BUG_ON hit or offline page > * which is used by someone > */ > BUG_ON(!PageBuddy(page A)); > > Signed-off-by: Minchan Kim Ah, hm. Then, you say the page in MIGRATE_MOVABLE will not be isolated and may be used again. > --- > I found this problem during code review so please confirm it. > Kame? > > mm/page_isolation.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index acf65a7..4699d1f 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -196,8 +196,11 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn) > continue; > } > page = pfn_to_page(pfn); > - if (PageBuddy(page)) > + if (PageBuddy(page)) { > + if (get_page_migratetype(page) != MIGRATE_ISOLATE) > + break; Doesn't this work enough ? The problem is MIGRATE_TYPE and list_head mis-match. Thanks, -Kame -- 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