Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp739889ybb; Wed, 1 Apr 2020 08:46:31 -0700 (PDT) X-Google-Smtp-Source: APiQypKdxF5xb82pZr2nqrwCiYHeWwjTy+9BZBWA+Vwwy7YiQZHEP92S676eB4+QNAMBT8UkEccE X-Received: by 2002:aca:5191:: with SMTP id f139mr3350613oib.140.1585755991399; Wed, 01 Apr 2020 08:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585755991; cv=none; d=google.com; s=arc-20160816; b=EeeOsq62bByVI8AQzmAWDPd+H2j++FVtVhwCF2erbpHszXchFJjHd/OBYBbw0MWVKS mp02R16yd/Tn1+GJp1q6JWVoqPuJ2S2Yk8ELUk5loDZwCrgiuBemoVcjDhHbUN1d+YHE 6wKowymmodkqiohJrXc/kfk8TdA6NFKkWBDxTc1QgomCBUMKqbcCJbssOQKRBLo7pkVg lt62uzpip02voTSvZjMOIbhhVZn1jzvviMG6J8oKY40DrKT8h6lgG0z0mZZ7RdjvOOt3 lnQ3NkDKvsiXFgZ3jzobPxLPYNO2DmXFhTnoAxP/NpNbDPKGJ7P/+VSteJ6NQ32S0eEt uyJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7MLCp8s76lSsk+DiQNRqZwGK9qED/+vAz643HBEYdNE=; b=H0KGJg2KsdbAkx8o+og2/hDbS8BnUWlken9oG8iMpUyrYjmg6NXLEu0pUGgymEYLEZ TwmX9YyeSYexv17V7LpzZtifwQNMHs/1L8RkXoU17CaykJJzhoD/Cs1iAitAI1mcydIk Zvz3kmPNJu+r41BcmvFIGGJHp2cj+dQlKsIcYFUvsiSTWWT4tdxUh7PNF82G6217O+gC 47uP7VIsr11ValJ5VFovPILnh7B448SgjRGhydEneF4LVcIBlj5zhv+d5EcS9KTdgyNS c1OsLLNp+ZE3jPdvct1CrykM1q2d5oHMwBPGf+x12sh1moQXtY8svFDYEXWJ4kj7dUwo IVYw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18si917876otp.73.2020.04.01.08.46.18; Wed, 01 Apr 2020 08:46:31 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733008AbgDAPpR (ORCPT + 99 others); Wed, 1 Apr 2020 11:45:17 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52544 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732705AbgDAPpR (ORCPT ); Wed, 1 Apr 2020 11:45:17 -0400 Received: by mail-wm1-f67.google.com with SMTP id t8so209813wmi.2 for ; Wed, 01 Apr 2020 08:45:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7MLCp8s76lSsk+DiQNRqZwGK9qED/+vAz643HBEYdNE=; b=lNzNVLI2Nfd2CBrNjO9sTS86rNEfEHux07KUBRgp9gyU7qXhISR2AQJcwHJFZlCYMI yD7o5PVyeFeg9V/Soc1k1EB/BuqZrEJJiWqvSUIoelDzilTs7YSGlZ25ITd5Ya1yQmsW ZFUabeb3lEUBZQu+c7odeQ4bCkR43ObNB/cCTfu2UN19caE0P6k21f+yxhQJ3/Eq2id/ ISfyZq+Byci59uL+9HF8qMeXOe+j+T6uCpLDIYJtGoGLNTcO2bGk/3DX39HG3STUNNYg QSE1wnjhOWwrbTRgnlZ+7idwbeopB96UDeTKSXdT8SUq3VhQLfIqckwgfAjIc4OoJtrR PIfg== X-Gm-Message-State: AGi0PuZkpD/J/BhHCG9f1NUZisKSwxnjIDqySS8G1GmcioA8a96quRgF Ic6EpwE7/iMcYlCUXJyuoQ0= X-Received: by 2002:a7b:cfc9:: with SMTP id f9mr5088227wmm.137.1585755915209; Wed, 01 Apr 2020 08:45:15 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id m8sm3012913wmc.28.2020.04.01.08.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 08:45:14 -0700 (PDT) Date: Wed, 1 Apr 2020 17:45:11 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yiqian Wei , Andrew Morton , Kirill Tkhai , Shile Zhang , Pavel Tatashin , Daniel Jordan , Alexander Duyck , Baoquan He , Oscar Salvador Subject: Re: [PATCH v1 1/2] mm/page_alloc: fix RCU stalls during deferred page initialization Message-ID: <20200401154511.GR22681@dhcp22.suse.cz> References: <20200401104156.11564-1-david@redhat.com> <20200401104156.11564-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401104156.11564-2-david@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 01-04-20 12:41:55, David Hildenbrand wrote: > With CONFIG_DEFERRED_STRUCT_PAGE_INIT and without CONFIG_PREEMPT, it can > happen that we get RCU stalls detected when booting up. > > [ 60.474005] rcu: INFO: rcu_sched detected stalls on CPUs/tasks: > [ 60.475000] rcu: 1-...0: (0 ticks this GP) idle=02a/1/0x4000000000000000 softirq=1/1 fqs=15000 > [ 60.475000] rcu: (detected by 0, t=60002 jiffies, g=-1199, q=1) > [ 60.475000] Sending NMI from CPU 0 to CPUs 1: > [ 1.760091] NMI backtrace for cpu 1 > [ 1.760091] CPU: 1 PID: 20 Comm: pgdatinit0 Not tainted 4.18.0-147.9.1.el8_1.x86_64 #1 > [ 1.760091] Hardware name: Red Hat KVM, BIOS 1.13.0-1.module+el8.2.0+5520+4e5817f3 04/01/2014 > [ 1.760091] RIP: 0010:__init_single_page.isra.65+0x10/0x4f > [ 1.760091] Code: 48 83 cf 63 48 89 f8 0f 1f 40 00 48 89 c6 48 89 d7 e8 6b 18 80 ff 66 90 5b c3 31 c0 b9 10 00 00 00 49 89 f8 48 c1 e6 33 f3 ab 07 00 00 00 48 c1 e2 36 41 c7 40 34 01 00 00 00 48 c1 e0 33 41 > [ 1.760091] RSP: 0000:ffffba783123be40 EFLAGS: 00000006 > [ 1.760091] RAX: 0000000000000000 RBX: fffffad34405e300 RCX: 0000000000000000 > [ 1.760091] RDX: 0000000000000000 RSI: 0010000000000000 RDI: fffffad34405e340 > [ 1.760091] RBP: 0000000033f3177e R08: fffffad34405e300 R09: 0000000000000002 > [ 1.760091] R10: 000000000000002b R11: ffff98afb691a500 R12: 0000000000000002 > [ 1.760091] R13: 0000000000000000 R14: 000000003f03ea00 R15: 000000003e10178c > [ 1.760091] FS: 0000000000000000(0000) GS:ffff9c9ebeb00000(0000) knlGS:0000000000000000 > [ 1.760091] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 1.760091] CR2: 00000000ffffffff CR3: 000000a1cf20a001 CR4: 00000000003606e0 > [ 1.760091] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > [ 1.760091] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > [ 1.760091] Call Trace: > [ 1.760091] deferred_init_pages+0x8f/0xbf > [ 1.760091] deferred_init_memmap+0x184/0x29d > [ 1.760091] ? deferred_free_pages.isra.97+0xba/0xba > [ 1.760091] kthread+0x112/0x130 > [ 1.760091] ? kthread_flush_work_fn+0x10/0x10 > [ 1.760091] ret_from_fork+0x35/0x40 > [ 89.123011] node 0 initialised, 1055935372 pages in 88650ms > > The issue becomes visible when having a lot of memory (e.g., 4TB) > assigned to a single NUMA node - a system that can easily be created > using QEMU. Inside VMs on a hypervisor with quite some memory > overcommit, this is fairly easy to trigger. > > Adding the cond_resched() makes RCU happy. I believe the patch you depend on is a wrong way to go so please let's wait until that settles down. But your cond_resched makes a perfect sense. Just have it called $FOO pages - e.g. hotplug is once per section. This is not bound to SPARSEMEM so you would have to use a differen't constant but something along those lines would work. > > Reported-by: Yiqian Wei > Cc: Andrew Morton > Cc: Kirill Tkhai > Cc: Shile Zhang > Cc: Pavel Tatashin > Cc: Daniel Jordan > Cc: Michal Hocko > Cc: Alexander Duyck > Cc: Baoquan He > Cc: Oscar Salvador > Signed-off-by: David Hildenbrand > --- > mm/page_alloc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index ca1453204e66..084cabffc90d 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1877,6 +1877,7 @@ static int __init deferred_init_memmap(void *data) > prev_nr_pages = nr_pages; > pgdat->first_deferred_pfn = spfn; > pgdat_resize_unlock(pgdat, &flags); > + cond_resched(); > goto again; > } > } > -- > 2.25.1 -- Michal Hocko SUSE Labs