From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759461AbbCDKLW (ORCPT ); Wed, 4 Mar 2015 05:11:22 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:21035 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1758901AbbCDKLS convert rfc822-to-8bit (ORCPT ); Wed, 4 Mar 2015 05:11:18 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="63139934" Message-ID: <54F6D637.6040705@cn.fujitsu.com> Date: Wed, 4 Mar 2015 17:53:59 +0800 From: Gu Zheng User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Kamezawa Hiroyuki , Xishi Qiu CC: Yasuaki Ishimatsu , Andrew Morton , Tang Chen , Yinghai Lu , Linux MM , LKML , Toshi Kani , Mel Gorman , Tejun Heo , Xiexiuqi , Hanjun Guo , Li Zefan , Taku Izumi Subject: Re: node-hotplug: is memset 0 safe in try_offline_node()? References: <54F52ACF.4030103@huawei.com> <54F58AE3.50101@cn.fujitsu.com> <54F66C52.4070600@huawei.com> <54F67376.8050001@huawei.com> <54F68270.5000203@cn.fujitsu.com> <54F6BC43.3000509@huawei.com> <54F6C809.1080709@jp.fujitsu.com> In-Reply-To: <54F6C809.1080709@jp.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.167.226.100] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/04/2015 04:53 PM, Kamezawa Hiroyuki wrote: > On 2015/03/04 17:03, Xishi Qiu wrote: >> On 2015/3/4 11:56, Gu Zheng wrote: >> >>> Hi Xishi, >>> On 03/04/2015 10:52 AM, Xishi Qiu wrote: >>> >>>> On 2015/3/4 10:22, Xishi Qiu wrote: >>>> >>>>> On 2015/3/3 18:20, Gu Zheng wrote: >>>>> >>>>>> Hi Xishi, >>>>>> On 03/03/2015 11:30 AM, Xishi Qiu wrote: >>>>>> >>>>>>> When hot-remove a numa node, we will clear pgdat, >>>>>>> but is memset 0 safe in try_offline_node()? >>>>>> >>>>>> It is not safe here. In fact, this is a temporary solution here. >>>>>> As you know, pgdat is accessed lock-less now, so protection >>>>>> mechanism (RCU?) is needed to make it completely safe here, >>>>>> but it seems a bit over-kill. >>>>>> >>>> >>>> Hi Gu, >>>> >>>> Can we just remove "memset(pgdat, 0, sizeof(*pgdat));" ? >>>> I find this will be fine in the stress test except the warning >>>> when hot-add memory. >>> >>> As you see, it will trigger the warning in free_area_init_node(). >>> Could you try the following patch? It will reset the pgdat before reuse it. >>> >>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >>> index 1778628..0717649 100644 >>> --- a/mm/memory_hotplug.c >>> +++ b/mm/memory_hotplug.c >>> @@ -1092,6 +1092,9 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) >>> return NULL; >>> >>> arch_refresh_nodedata(nid, pgdat); >>> + } else { >>> + /* Reset the pgdat to reuse */ >>> + memset(pgdat, 0, sizeof(*pgdat)); >>> } >> >> Hi Gu, >> >> If schedule last a long time, next_zone may be still access the pgdat here, >> so it is not safe enough, right? Hi Xishi, IMO, the scheduled time is rather short if compares with the time gap between hot remove and hot re-add a node, so we can say it is safe here. >> > > How about just reseting pgdat->nr_zones and pgdat->classzone_idx to be 0 rather than > memset() ? > > It seems breaking pointer information in pgdat is not a choice. > Just proper "values" should be reset. Anyway, sounds reasonable. Best regards, Gu > > Thanks, > -Kame > > > > . >