From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945Ab2I0NTl (ORCPT ); Thu, 27 Sep 2012 09:19:41 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:59123 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752232Ab2I0NTk (ORCPT ); Thu, 27 Sep 2012 09:19:40 -0400 Message-ID: <5064525E.5080901@gmail.com> Date: Thu, 27 Sep 2012 21:19:26 +0800 From: Ni zhan Chen User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Lai Jiangshan CC: linux-kernel@vger.kernel.org, Mel Gorman , Andrew Morton , Jiang Liu , Xishi Qiu , Mel Gorman , Minchan Kim , KAMEZAWA Hiroyuki , Michal Hocko , linux-mm@kvack.org Subject: Re: [PATCH 3/3] memory_hotplug: Don't modify the zone_start_pfn outside of zone_span_writelock() References: <1348728470-5580-1-git-send-email-laijs@cn.fujitsu.com> <1348728470-5580-4-git-send-email-laijs@cn.fujitsu.com> In-Reply-To: <1348728470-5580-4-git-send-email-laijs@cn.fujitsu.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/27/2012 02:47 PM, Lai Jiangshan wrote: > The __add_zone() maybe call sleep-able init_currently_empty_zone() > to init wait_table, > > But this function also modifies the zone_start_pfn without any lock. > It is bugy. > > So we move this modification out, and we ensure the modification > of zone_start_pfn is only done with zone_span_writelock() held or in booting. > > Since zone_start_pfn is not modified by init_currently_empty_zone() > grow_zone_span() needs to check zone_start_pfn before update it. > > CC: Mel Gorman > Signed-off-by: Lai Jiangshan > Reported-by: Yasuaki ISIMATU > Tested-by: Wen Congyang > --- > mm/memory_hotplug.c | 2 +- > mm/page_alloc.c | 3 +-- > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index b62d429b..790561f 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -205,7 +205,7 @@ static void grow_zone_span(struct zone *zone, unsigned long start_pfn, > zone_span_writelock(zone); > > old_zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages; > - if (start_pfn < zone->zone_start_pfn) > + if (!zone->zone_start_pfn || start_pfn < zone->zone_start_pfn) > zone->zone_start_pfn = start_pfn; > > zone->spanned_pages = max(old_zone_end_pfn, end_pfn) - > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index c13ea75..2545013 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3997,8 +3997,6 @@ int __meminit init_currently_empty_zone(struct zone *zone, > return ret; > pgdat->nr_zones = zone_idx(zone) + 1; > > - zone->zone_start_pfn = zone_start_pfn; > - then how can mminit_dprintk print zone->zone_start_pfn ? always print 0 make no sense. > mminit_dprintk(MMINIT_TRACE, "memmap_init", > "Initialising map node %d zone %lu pfns %lu -> %lu\n", > pgdat->node_id, > @@ -4465,6 +4463,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat, > ret = init_currently_empty_zone(zone, zone_start_pfn, > size, MEMMAP_EARLY); > BUG_ON(ret); > + zone->zone_start_pfn = zone_start_pfn; > memmap_init(size, nid, j, zone_start_pfn); > zone_start_pfn += size; > }