From patchwork Wed Mar 15 16:40:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 9626139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B52CB60522 for ; Wed, 15 Mar 2017 16:40:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A71792863A for ; Wed, 15 Mar 2017 16:40:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C51328669; Wed, 15 Mar 2017 16:40:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FDB028667 for ; Wed, 15 Mar 2017 16:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=/d5fvCRsT/5nnApFUBZWwjPllUuzYVlG98wWzBtJF6E=; b=lAH yz8chsIPUDaGiwbb+TzSrBMSc500NnGgLjbNWOem0NDYCpm93n+zDNO3W6uf5LqoGvYGxCXrpo4tL 8pyVML2+BGYIm4AlVHWrGDK8GjDzydeNdceQhCVuwju4PS0Oo6Yk/sfPDjEs8q/Zh1WO0doB1TdQu O3For1pSsUKzcJo+M9lnrLXz079Bau8TnoBLlUxlVWBbOHCQ8aY3FCn8jpxV4GaHzoETJ2WApSrxp TWSaaK9H7TRHlLEouMO/aS5qW2/F4p4Wlz3iDeIF2tcsqOlcZN+FPda/5FcWsCJbDcdpLZvALpFl8 ipu0IX2HVmtzXf++cEU2I06qJyi2FQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1coByr-0004PX-4I; Wed, 15 Mar 2017 16:40:57 +0000 Received: from mail-wm0-f65.google.com ([74.125.82.65]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1coByo-0004Nq-Bh for linux-arm-kernel@lists.infradead.org; Wed, 15 Mar 2017 16:40:56 +0000 Received: by mail-wm0-f65.google.com with SMTP id v190so5572172wme.3 for ; Wed, 15 Mar 2017 09:40:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=y9kzok5geAntgcCSbSstJxQVflC511fHqZ0qNb51sKU=; b=J79Y7D+VdVW4EkkpelKanEiRSTZ/6/eMLdbPcovvReELIqDRDzZ9Ul8ee+KjQrFNjW 0N6pJiHop6dNjoH8UMv+hYdcugrkrxve/1GvjtHYokSvu2viqfSC4PllSwqWCOBBpOAq EUfLm9ClrpJIFqZ8aF5ITB8Rh77kveFTvAHGg55RG0vzUcjmfQNSe4DgDUArAV68u47u kQyQNemcQINzovVQJpY37Nplukg4+XP+Bx644uAbOk88Nkwdn6h3ab9hGJyj82fqEdOH JlmDvKuaOVNxiMZ+MbTkqYyb1ZicOyU3e1Re+t5EaVyIwasfQAcB6XOm/8jMoHp2liS7 IP7A== X-Gm-Message-State: AFeK/H2a/ODEEm3z5zINBTWtOHiBkO1GWoL9xqARtOs9sW/Wf2Udk+ETlv/vrPLYB1e+Tg== X-Received: by 10.28.129.83 with SMTP id c80mr19511334wmd.82.1489596031669; Wed, 15 Mar 2017 09:40:31 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-86-49-65-7.net.upcbroadband.cz. [86.49.65.7]) by smtp.gmail.com with ESMTPSA id n187sm1116573wmd.4.2017.03.15.09.40.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 09:40:30 -0700 (PDT) From: Michal Hocko To: Andrew Morton Subject: [PATCH] mm: move mm_percpu_wq initialization earlier Date: Wed, 15 Mar 2017 17:40:21 +0100 Message-Id: <20170315164021.28532-1-mhocko@kernel.org> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170315_094054_559112_0ADDF081 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Michal Hocko , Tetsuo Handa , LKML , linux-mm@kvack.org, Li Yang , Mel Gorman , Vlastimil Babka MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko Yang Li has reported that drain_all_pages triggers a WARN_ON which means that this function is called earlier than the mm_percpu_wq is initialized on arm64 with CMA configured: [ 0.276449] WARNING: CPU: 2 PID: 1 at mm/page_alloc.c:2423 drain_all_pages+0x244/0x25c [ 0.276537] Modules linked in: [ 0.276594] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.11.0-rc1-next-20170310-00027-g64dfbc5 #127 [ 0.276693] Hardware name: Freescale Layerscape 2088A RDB Board (DT) [ 0.276764] task: ffffffc07c4a6d00 task.stack: ffffffc07c4a8000 [ 0.276831] PC is at drain_all_pages+0x244/0x25c [ 0.276886] LR is at start_isolate_page_range+0x14c/0x1f0 [...] [ 0.279000] [] drain_all_pages+0x244/0x25c [ 0.279065] [] start_isolate_page_range+0x14c/0x1f0 [ 0.279137] [] alloc_contig_range+0xec/0x354 [ 0.279203] [] cma_alloc+0x100/0x1fc [ 0.279263] [] dma_alloc_from_contiguous+0x3c/0x44 [ 0.279336] [] atomic_pool_init+0x7c/0x208 [ 0.279399] [] arm64_dma_init+0x44/0x4c [ 0.279461] [] do_one_initcall+0x38/0x128 [ 0.279525] [] kernel_init_freeable+0x1a0/0x240 [ 0.279596] [] kernel_init+0x10/0xfc [ 0.279654] [] ret_from_fork+0x10/0x20 Fix this by moving the whole setup_vmstat which is an initcall right now to init_mm_internals which will be called right after the WQ subsystem is initialized. Reported-and-tested-by: Yang Li Signed-off-by: Michal Hocko --- include/linux/mm.h | 2 ++ init/main.c | 2 ++ mm/vmstat.c | 4 +--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 21ee5503c702..8362dca071cb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -32,6 +32,8 @@ struct user_struct; struct writeback_control; struct bdi_writeback; +void init_mm_internals(void); + #ifndef CONFIG_NEED_MULTIPLE_NODES /* Don't use mapnrs, do it properly */ extern unsigned long max_mapnr; diff --git a/init/main.c b/init/main.c index 51aa8f336819..c72d35250e84 100644 --- a/init/main.c +++ b/init/main.c @@ -1023,6 +1023,8 @@ static noinline void __init kernel_init_freeable(void) workqueue_init(); + init_mm_internals(); + do_pre_smp_initcalls(); lockup_detector_init(); diff --git a/mm/vmstat.c b/mm/vmstat.c index 4bbc775f9d08..d0871fc1aeca 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1762,7 +1762,7 @@ static int vmstat_cpu_dead(unsigned int cpu) struct workqueue_struct *mm_percpu_wq; -static int __init setup_vmstat(void) +void __init init_mm_internals(void) { int ret __maybe_unused; @@ -1792,9 +1792,7 @@ static int __init setup_vmstat(void) proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); #endif - return 0; } -module_init(setup_vmstat) #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)