Received: by 10.213.65.68 with SMTP id h4csp265012imn; Mon, 12 Mar 2018 13:05:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELu8NUocp7sHC2egmaz0FX+OpYUbtgofSTj/ldtD8xBKQuKebRmDjrEH2myB67GzXzN/SW6D X-Received: by 2002:a17:902:227:: with SMTP id 36-v6mr1157055plc.134.1520885152804; Mon, 12 Mar 2018 13:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520885152; cv=none; d=google.com; s=arc-20160816; b=R2eNAUFvn6rWJQcfyYXiPT5W9LMNw83hELNLkMYG0XZ5IHbVnRg3uKVxujF6b9LG5Q UeBA9R1KIdLt3ejSs3Nag+4j1plMPFh8qvrQ8038GpSwM5lXBxgttF935tkFZeM7D6dq 3qr80BqX9Zj1lP1PGfryNLYxZzsw4THDw9t5pqUJ+4jla2VOmwQrOf3oq130bJqxcrJw KmWkM4VEAyPUQNw4H/Peaj5ECnjU59TDOCiYd22wbPFXZQV+fDIXOSP1syKHS4B3MN+n w8+nCi77WW+PjZ4fMB1BfoEtVc96ENfDJKNXMh2U631PQM918bKoJt9g4L1CAOn3N+0g ZzQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=/i0Agh+cxB99GpoiVIJwPAM3cDXjikRVvJ9KIAySsaY=; b=tATvNXrDHe5ONXgmBfDeWiv1CgaCABKgPTq/377YgvTUP5DCT/Hp5nRiYjTuhk0Mn3 gh/Ilg/ZBIkmXj+cjZcefW/7kWa+tXeTivkThL+REXAlGQuSVowEg6Qt6XCJzn5VTSez 0B5+BXwWI3oX8WE/IyrmVAyvsE9yRkY4Cyc60kgyAOm7x6QIXARMLJ1cY3VH+VbJ9yWK 37h0NXI34G28jWLCKV8LsidWdB5g/BjmA8jWKwDlYl4rv7UzRrUl/UcPo1p3pLYXFfxk zHCLPHjRg40i/RTQCtGXeQgDnMqt9wkq7wdpgNL5W0z4bPNGjxsIhwO9thPUSAokijFm PXVw== 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 o86si6325230pfi.253.2018.03.12.13.05.35; Mon, 12 Mar 2018 13:05:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932252AbeCLUEN (ORCPT + 99 others); Mon, 12 Mar 2018 16:04:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42190 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbeCLUEM (ORCPT ); Mon, 12 Mar 2018 16:04:12 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8E1E3EA5; Mon, 12 Mar 2018 20:04:11 +0000 (UTC) Date: Mon, 12 Mar 2018 13:04:10 -0700 From: Andrew Morton To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, m.mizuma@jp.fujitsu.com, mhocko@suse.com, catalin.marinas@arm.com, takahiro.akashi@linaro.org, gi-oh.kim@profitbricks.com, heiko.carstens@de.ibm.com, baiyaowei@cmss.chinamobile.com, richard.weiyang@gmail.com, paul.burton@mips.com, miles.chen@mediatek.com, vbabka@suse.cz, mgorman@suse.de, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [v5 1/2] mm: disable interrupts while initializing deferred pages Message-Id: <20180312130410.e2fce8e5e38bc2086c7fd924@linux-foundation.org> In-Reply-To: <20180309220807.24961-2-pasha.tatashin@oracle.com> References: <20180309220807.24961-1-pasha.tatashin@oracle.com> <20180309220807.24961-2-pasha.tatashin@oracle.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Mar 2018 17:08:06 -0500 Pavel Tatashin wrote: > Vlastimil Babka reported about a window issue during which when deferred > pages are initialized, and the current version of on-demand initialization > is finished, allocations may fail. While this is highly unlikely scenario, > since this kind of allocation request must be large, and must come from > interrupt handler, we still want to cover it. > > We solve this by initializing deferred pages with interrupts disabled, and > holding node_size_lock spin lock while pages in the node are being > initialized. The on-demand deferred page initialization that comes later > will use the same lock, and thus synchronize with deferred_init_memmap(). > > It is unlikely for threads that initialize deferred pages to be > interrupted. They run soon after smp_init(), but before modules are > initialized, and long before user space programs. This is why there is no > adverse effect of having these threads running with interrupts disabled. > > ... > > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > > +#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) > +/* > + * pgdat resizing functions > + */ > +static inline > +void pgdat_resize_lock(struct pglist_data *pgdat, unsigned long *flags) > +{ > + spin_lock_irqsave(&pgdat->node_size_lock, *flags); > +} > +static inline > +void pgdat_resize_unlock(struct pglist_data *pgdat, unsigned long *flags) > +{ > + spin_unlock_irqrestore(&pgdat->node_size_lock, *flags); > +} > +static inline > +void pgdat_resize_init(struct pglist_data *pgdat) > +{ > + spin_lock_init(&pgdat->node_size_lock); > +} > + > +/* Disable interrupts and save previous IRQ state in flags before locking */ > +static inline > +void pgdat_resize_lock_irq(struct pglist_data *pgdat, unsigned long *flags) > +{ > + unsigned long tmp_flags; > + > + local_irq_save(*flags); > + local_irq_disable(); > + pgdat_resize_lock(pgdat, &tmp_flags); > +} As far as I can tell, this ugly-looking thing is identical to pgdat_resize_lock(). > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1506,7 +1506,6 @@ static void __init deferred_free_pages(int nid, int zid, unsigned long pfn, > } else if (!(pfn & nr_pgmask)) { > deferred_free_range(pfn - nr_free, nr_free); > nr_free = 1; > - cond_resched(); > } else { > nr_free++; And how can we simply remove these cond_resched()s? I assume this is being done because interrupts are now disabled? But those were there for a reason, weren't they?