Received: by 10.223.185.116 with SMTP id b49csp4278813wrg; Tue, 6 Mar 2018 12:57:20 -0800 (PST) X-Google-Smtp-Source: AG47ELu4C+gFzDEU+wZQyX8XM/KMqBN4X5eh1qA9RcvNFjBrpbOV1chVv8hrIw20vTKxzV3183Da X-Received: by 10.98.33.204 with SMTP id o73mr20268734pfj.54.1520369840166; Tue, 06 Mar 2018 12:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520369840; cv=none; d=google.com; s=arc-20160816; b=YZ7yI955SFfIgNEI6vS+ogRUgzWD5E3/WAxr+DqtOm6mMT73foAnx7RXiW5wksLCAe 7NHjjZn/iNTqXFH2ryLkY+PmvrZ8Wk6PWzPO04EroY1spzHr4ZcLmLWnfMCitfZv+iG3 nle5OdvO6YahpaxsLWeJ/E2JtNEBkktlZNNfSAyqoQVnDHCe3iw6HO+FAIl2Rt/f6AuW U8AglG9oHZ58MNyjOA9Pe4+B9C5NEtFMga5s28EHHmbV19jhcjDd7EDqz3qxfigWRsvK UABx2Tuu6jqym9GsDhj9bk1C9NjXcFoBhQRHhj5gC4Y/4nOiSOBSuB+hEzOD+cp1qa7a DTPg== 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=iEqaBhUbD43Je6wM8i+XSfad0s+u8dBKc9PXCrDBedQ=; b=nwj1t3O8JVEDlqMNqg7DBokvekZ4EV6z1rardyu2T+RNUuFUPON6v9JF10BIEaBlYm 7xq8rYZDZW2RuXA2rLvKCz95y5YqWPYAEgo0Ba8Ep82b7c9HWVk0mBS96z684ZyGnNQC IBOMWa3rUrBZCSZIsEGTlgW5OtpHIUcuYlJNVTQVUMB/fPsrx8RiVj6qMs1rnML2b8hY 5CczbnE9C9zP2n2aZ4QpWNwihPotpDfJRAZxcR0FUePVRn1E6vQlbhQxDWjw5Df8wvCO C7JCmyf79FuKRUHnmOI8tExi9xJ0RNSR8gzGh0tBUO5YCJajYBZ6EmmL5LLPJjG09DsP nfjQ== 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 t9si12482689pfh.101.2018.03.06.12.57.05; Tue, 06 Mar 2018 12:57:20 -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 S1754015AbeCFU4H (ORCPT + 99 others); Tue, 6 Mar 2018 15:56:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:32990 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753065AbeCFU4G (ORCPT ); Tue, 6 Mar 2018 15:56:06 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3CC0D113B; Tue, 6 Mar 2018 20:56:05 +0000 (UTC) Date: Tue, 6 Mar 2018 12:56:04 -0800 From: Andrew Morton To: Pavel Tatashin Cc: Steven Sistare , Daniel Jordan , Masayoshi Mizuma , Michal Hocko , Catalin Marinas , AKASHI Takahiro , Gioh Kim , Heiko Carstens , Yaowei Bai , Wei Yang , Paul Burton , Miles Chen , Vlastimil Babka , Mel Gorman , Johannes Weiner , LKML , linux-mm@kvack.org Subject: Re: [PATCH] mm: might_sleep warning Message-Id: <20180306125604.c394a25a50cae0e36c546855@linux-foundation.org> In-Reply-To: References: <20180306192022.28289-1-pasha.tatashin@oracle.com> <20180306123655.957e5b6b20b200505544ea7a@linux-foundation.org> 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 Tue, 6 Mar 2018 15:48:26 -0500 Pavel Tatashin wrote: > On Tue, Mar 6, 2018 at 3:36 PM, Andrew Morton > wrote: > > > On Tue, 6 Mar 2018 14:20:22 -0500 Pavel Tatashin < > > pasha.tatashin@oracle.com> wrote: > > > > > spin_lock(&deferred_zone_grow_lock); > > > - static_branch_disable(&deferred_pages); > > > + deferred_zone_grow = false; > > > spin_unlock(&deferred_zone_grow_lock); > > > + static_branch_disable(&deferred_pages); > > > > > > /* There will be num_node_state(N_MEMORY) threads */ > > > atomic_set(&pgdat_init_n_undone, num_node_state(N_MEMORY)); > > > > Kinda ugly, but I can see the logic behind the decisions. > > > > Can we instead turn deferred_zone_grow_lock into a mutex? (top-posting repaired. Please don't top-post). > [CCed everyone] > > Hi Andrew, > > I afraid we cannot change this spinlock to mutex > because deferred_grow_zone() might be called from an interrupt context if > interrupt thread needs to allocate memory. > OK. But if deferred_grow_zone() can be called from interrupt then page_alloc_init_late() should be using spin_lock_irq(), shouldn't it? I'm surprised that lockdep didn't detect that. --- a/mm/page_alloc.c~mm-initialize-pages-on-demand-during-boot-fix-4-fix +++ a/mm/page_alloc.c @@ -1689,9 +1689,9 @@ void __init page_alloc_init_late(void) * context. Since, spin_lock() disables preemption, we must use an * extra boolean deferred_zone_grow. */ - spin_lock(&deferred_zone_grow_lock); + spin_lock_irq(&deferred_zone_grow_lock); deferred_zone_grow = false; - spin_unlock(&deferred_zone_grow_lock); + spin_unlock_irq(&deferred_zone_grow_lock); static_branch_disable(&deferred_pages); /* There will be num_node_state(N_MEMORY) threads */ _