Received: by 10.223.176.5 with SMTP id f5csp4069916wra; Tue, 30 Jan 2018 01:29:03 -0800 (PST) X-Google-Smtp-Source: AH8x226ZX94IDhAhBfm3GaLZgk+P/QAll8O0AfBoRaEZGD9ZJCUQjpO2nb0rtfLJ4FAYG1ZsP9dk X-Received: by 10.98.248.75 with SMTP id c11mr29790729pfm.54.1517304543874; Tue, 30 Jan 2018 01:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517304543; cv=none; d=google.com; s=arc-20160816; b=hHBuJvJv16b8/pYyB+2Zxgp3vI9/AUljegP9iNt3TeY5NQ6uJxRDJ3KHfGoK0rGRNs x5P6mv8nvGxxR8Lli39OSKOwHNo785Fo4iFUGASMqPnME7rqUPkLI97fKj9kbnficQK8 L/2CgX+7dMLtzwniGWBx9on1O9sgi+ADpCf5yPmJzSHd6goQsLc7Wk63ZuDpoiItmHlc htqr1B+ClUEWmZkFS6wzcJe5WCRaBtgI0mgyEqJ6RnkRtIN2kVZL9Tt3qUDTzBhxu5rd /H+SZFafVMUJFCeF20SsWhI9VqSi8z+UMJJKlREzcIFmUg7Vydg6dd5Oy3dTpIqOCg+v B6rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hsRknsKk8u3XAmyluzA6xgV+O4MxHfZprWQX3oHfZKM=; b=e3WBIGt9OnypcjDdn6DTVzW5qNovTwMYya+SaRd5BZhQqHUXB4QBIo/t4CbaLOFiFU ZCY4R3TQbIy4utfBlAxCG2nKChdJbvzsmwu/XWY1uzPlHKRwJj9TTcmTmZxsH/ceMsKE xwPbNB2E/50Y+AKgpRwGgGcNaOLBnMwMbGiPy8fgFO+PA1tiFILu2vIk4FP1pifyjVY/ qUuhVDcfgf9Q9trxAOTBCx5LFMLh3a3hJMQVqfjeTXlxjCbX/02NnrrhJr1PmXK77uAU Z6fCRC+1uwghkcKwSxvSjfBXeBjaD+FfD2GfTqrLask75vaaTStE8ibolPXfbTiawF9A +MqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si8894029pgc.320.2018.01.30.01.28.49; Tue, 30 Jan 2018 01:29:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751552AbeA3J2T (ORCPT + 99 others); Tue, 30 Jan 2018 04:28:19 -0500 Received: from mx2.suse.de ([195.135.220.15]:35722 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959AbeA3J2R (ORCPT ); Tue, 30 Jan 2018 04:28:17 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0A5D2AD2D; Tue, 30 Jan 2018 09:28:16 +0000 (UTC) Date: Tue, 30 Jan 2018 10:28:15 +0100 From: Michal Hocko To: Bharata B Rao Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, pasha.tatashin@oracle.com Subject: Re: Memory hotplug not increasing the total RAM Message-ID: <20180130092815.GR21609@dhcp22.suse.cz> References: <20180130083006.GB1245@in.ibm.com> <20180130091600.GA26445@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180130091600.GA26445@dhcp22.suse.cz> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 30-01-18 10:16:00, Michal Hocko wrote: > On Tue 30-01-18 14:00:06, Bharata B Rao wrote: > > Hi, > > > > With the latest upstream, I see that memory hotplug is not working > > as expected. The hotplugged memory isn't seen to increase the total > > RAM pages. This has been observed with both x86 and Power guests. > > > > 1. Memory hotplug code intially marks pages as PageReserved via > > __add_section(). > > 2. Later the struct page gets cleared in __init_single_page(). > > 3. Next online_pages_range() increments totalram_pages only when > > PageReserved is set. > > You are right. I have completely forgot about this late struct page > initialization during onlining. memory hotplug really doesn't want > zeroying. Let me think about a fix. Could you test with the following please? Not an act of beauty but we are initializing memmap in sparse_add_one_section for memory hotplug. I hate how this is different from the initialization case but there is quite a long route to unify those two... So a quick fix should be as follows. --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6129f989223a..97a1d7e96110 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1178,9 +1178,10 @@ static void free_one_page(struct zone *zone, } static void __meminit __init_single_page(struct page *page, unsigned long pfn, - unsigned long zone, int nid) + unsigned long zone, int nid, bool zero) { - mm_zero_struct_page(page); + if (zero) + mm_zero_struct_page(page); set_page_links(page, zone, nid, pfn); init_page_count(page); page_mapcount_reset(page); @@ -1195,9 +1196,9 @@ static void __meminit __init_single_page(struct page *page, unsigned long pfn, } static void __meminit __init_single_pfn(unsigned long pfn, unsigned long zone, - int nid) + int nid, bool zero) { - return __init_single_page(pfn_to_page(pfn), pfn, zone, nid); + return __init_single_page(pfn_to_page(pfn), pfn, zone, nid, zero); } #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT @@ -1218,7 +1219,7 @@ static void __meminit init_reserved_page(unsigned long pfn) if (pfn >= zone->zone_start_pfn && pfn < zone_end_pfn(zone)) break; } - __init_single_pfn(pfn, zid, nid); + __init_single_pfn(pfn, zid, nid, true); } #else static inline void init_reserved_page(unsigned long pfn) @@ -1535,7 +1536,7 @@ static unsigned long __init deferred_init_pages(int nid, int zid, } else { page++; } - __init_single_page(page, pfn, zid, nid); + __init_single_page(page, pfn, zid, nid, true); nr_pages++; } return (nr_pages); @@ -5404,11 +5405,13 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, if (!(pfn & (pageblock_nr_pages - 1))) { struct page *page = pfn_to_page(pfn); - __init_single_page(page, pfn, zone, nid); + __init_single_page(page, pfn, zone, nid, + context != MEMMAP_HOTPLUG); set_pageblock_migratetype(page, MIGRATE_MOVABLE); cond_resched(); } else { - __init_single_pfn(pfn, zone, nid); + __init_single_pfn(pfn, zone, nid, + context != MEMMAP_HOTPLUG); } } } -- Michal Hocko SUSE Labs