From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754672AbbCEIn3 (ORCPT ); Thu, 5 Mar 2015 03:43:29 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:23563 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751170AbbCEIn2 (ORCPT ); Thu, 5 Mar 2015 03:43:28 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="64868335" Message-ID: <54F81322.8010202@cn.fujitsu.com> Date: Thu, 5 Mar 2015 16:26:10 +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: Xishi Qiu CC: Yasuaki Ishimatsu , Andrew Morton , Tang Chen , Yinghai Lu , Linux MM , LKML , Toshi Kani , Mel Gorman , Tejun Heo Subject: Re: node-hotplug: is memset 0 safe in try_offline_node()? References: <54F52ACF.4030103@huawei.com> In-Reply-To: <54F52ACF.4030103@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.100] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Xishi, Could you please try the following one? It postpones the reset of obsolete pgdat from try_offline_node() to hotadd_new_pgdat(), and just resetting pgdat->nr_zones and pgdat->classzone_idx to be 0 rather than the whole reset by memset() as Kame suggested. Regards, Gu --- mm/memory_hotplug.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1778628..c17eebf 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1092,6 +1092,10 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) return NULL; arch_refresh_nodedata(nid, pgdat); + } else { + /* Reset the nr_zones and classzone_idx to 0 before reuse */ + pgdat->nr_zones = 0; + pgdat->classzone_idx = 0; } /* we can use NODE_DATA(nid) from here */ @@ -2021,15 +2025,6 @@ void try_offline_node(int nid) /* notify that the node is down */ call_node_notify(NODE_DOWN, (void *)(long)nid); - - /* - * Since there is no way to guarentee the address of pgdat/zone is not - * on stack of any kernel threads or used by other kernel objects - * without reference counting or other symchronizing method, do not - * reset node_data and free pgdat here. Just reset it to 0 and reuse - * the memory when the node is online again. - */ - memset(pgdat, 0, sizeof(*pgdat)); } EXPORT_SYMBOL(try_offline_node); -- 1.7.7 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()? > > process A: offline node XX: > for_each_populated_zone() > find online node XX > cond_resched() > offline cpu and memory, then try_offline_node() > node_set_offline(nid), and memset(pgdat, 0, sizeof(*pgdat)) > access node XX's pgdat > NULL pointer access error > > Thanks, > Xishi Qiu > > -- > 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 >