Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbbEGWJf (ORCPT ); Thu, 7 May 2015 18:09:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45622 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbbEGWJd (ORCPT ); Thu, 7 May 2015 18:09:33 -0400 Date: Thu, 7 May 2015 15:09:32 -0700 From: Andrew Morton To: Mel Gorman Cc: Waiman Long , Nathan Zimmer , Dave Hansen , Scott Norton , Daniel J Blueman , Linux-MM , LKML Subject: Re: [PATCH] mm: meminit: Finish initialisation of struct pages before basic setup Message-Id: <20150507150932.79e038167f70dd467c25d6ee@linux-foundation.org> In-Reply-To: <20150507072518.GL2462@suse.de> References: <1430231830-7702-1-git-send-email-mgorman@suse.de> <554030D1.8080509@hp.com> <5543F802.9090504@hp.com> <554415B1.2050702@hp.com> <20150504143046.9404c572486caf71bdef0676@linux-foundation.org> <20150505104514.GC2462@suse.de> <20150505130255.49ff76bbf0a3b32d884ab2ce@linux-foundation.org> <20150507072518.GL2462@suse.de> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3020 Lines: 84 On Thu, 7 May 2015 08:25:18 +0100 Mel Gorman wrote: > Waiman Long reported that 24TB machines hit OOM during basic setup when > struct page initialisation was deferred. One approach is to initialise memory > on demand but it interferes with page allocator paths. This patch creates > dedicated threads to initialise memory before basic setup. It then blocks > on a rw_semaphore until completion as a wait_queue and counter is overkill. > This may be slower to boot but it's simplier overall and also gets rid of a > section mangling which existed so kswapd could do the initialisation. Seems a reasonable compromise. It makes a bit of a mess of the patch sequencing. Have some tweaklets: From: Andrew Morton Subject: mm-meminit-finish-initialisation-of-struct-pages-before-basic-setup-fix include rwsem.h, use DECLARE_RWSEM, fix comment, remove unneeded cast Cc: Daniel J Blueman Cc: Dave Hansen Cc: Mel Gorman Cc: Nathan Zimmer Cc: Scott Norton Cc: Waiman Long --- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff -puN mm/page_alloc.c~mm-meminit-finish-initialisation-of-struct-pages-before-basic-setup-fix mm/page_alloc.c --- a/mm/page_alloc.c~mm-meminit-finish-initialisation-of-struct-pages-before-basic-setup-fix +++ a/mm/page_alloc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1075,12 +1076,12 @@ static void __init deferred_free_range(s __free_pages_boot_core(page, pfn, 0); } -static struct rw_semaphore __initdata pgdat_init_rwsem; +static __initdata DECLARE_RWSEM(pgdat_init_rwsem); /* Initialise remaining memory on a node */ static int __init deferred_init_memmap(void *data) { - pg_data_t *pgdat = (pg_data_t *)data; + pg_data_t *pgdat = data; int nid = pgdat->node_id; struct mminit_pfnnid_cache nid_init_state = { }; unsigned long start = jiffies; @@ -1096,7 +1097,7 @@ static int __init deferred_init_memmap(v return 0; } - /* Bound memory initialisation to a local node if possible */ + /* Bind memory initialisation thread to a local node if possible */ if (!cpumask_empty(cpumask)) set_cpus_allowed_ptr(current, cpumask); @@ -1200,7 +1201,6 @@ void __init page_alloc_init_late(void) { int nid; - init_rwsem(&pgdat_init_rwsem); for_each_node_state(nid, N_MEMORY) { down_read(&pgdat_init_rwsem); kthread_run(deferred_init_memmap, NODE_DATA(nid), "pgdatinit%d", nid); _ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/