From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAEEDC47404 for ; Sun, 6 Oct 2019 00:44:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 69558222C8 for ; Sun, 6 Oct 2019 00:44:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="p5R8C/TR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69558222C8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 01E526B0003; Sat, 5 Oct 2019 20:44:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F10606B0005; Sat, 5 Oct 2019 20:44:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E28666B0006; Sat, 5 Oct 2019 20:44:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id C0EE66B0003 for ; Sat, 5 Oct 2019 20:44:26 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 5951440FE for ; Sun, 6 Oct 2019 00:44:26 +0000 (UTC) X-FDA: 76011513732.12.tub37_60d8bc4768f06 X-HE-Tag: tub37_60d8bc4768f06 X-Filterd-Recvd-Size: 3365 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Sun, 6 Oct 2019 00:44:25 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 133D9222BE; Sun, 6 Oct 2019 00:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570322664; bh=dUxtV3Ibs0G3juj9sXutxwx0gZ5As2EPiNLj7fplnKQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=p5R8C/TRAM3HJGWS9MrFubrQpgBWerX+WPHkeIOg9125GDTs4xiBGy+zxaf+UKyw7 IqDy1QM8bL8oEHmsxA9WZLd1jwmEaVdHq3BVBu5WkfzrltLzKwGU5bnzfDgzoY+EMK HEyJwv9fs/1TbhB0VqFdLO13wftbwdzPxkB4Sy2A= Date: Sat, 5 Oct 2019 17:44:23 -0700 From: Andrew Morton To: Qian Cai Cc: mhocko@kernel.org, sergey.senozhatsky.work@gmail.com, pmladek@suse.com, rostedt@goodmis.org, peterz@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_isolation: fix a deadlock with printk() Message-Id: <20191005174423.23f2db80872a9365009f398a@linux-foundation.org> In-Reply-To: <49F0AD04-6F61-4A1D-BFD5-E0769EC6F103@lca.pw> References: <20191005162942.b392b9336b860e245106faa2@linux-foundation.org> <49F0AD04-6F61-4A1D-BFD5-E0769EC6F103@lca.pw> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000029, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 5 Oct 2019 20:10:47 -0400 Qian Cai wrote: > > > >> the existing dependency chain (in reverse order) is: > >> > >> -> #2 (&(&zone->lock)->rlock){-.-.}: > >> lock_acquire+0x21a/0x468 > >> _raw_spin_lock+0x54/0x68 > >> get_page_from_freelist+0x8b6/0x2d28 > >> __alloc_pages_nodemask+0x246/0x658 > >> __get_free_pages+0x34/0x78 > >> sclp_init+0x106/0x690 > >> sclp_register+0x2e/0x248 > >> sclp_rw_init+0x4a/0x70 > >> sclp_console_init+0x4a/0x1b8 > >> console_init+0x2c8/0x410 > >> start_kernel+0x530/0x6a0 > >> startup_continue+0x70/0xd0 > > > > This appears to be the core of our problem? > > No, that is just one of those many places could form the lock chain. > > console_lock -> other locks -> zone_lock > > Another example is, > > https://lore.kernel.org/lkml/1568823006.5576.178.camel@lca.pw/ There is no "console_lock". Please be much more specific. > It is easier to avoid, > > zone_lock -> console_lock > > rather than fixing the opposite. "ease" isn't the main objective. A more important question is "what makes sense". We should be able to call printk() from anywhere, any time under any conditions. That can't be done 100% but it is the objective. printk() should be robust and not being able to call printk() while holding zone->lock isn't robust! btw, this: : It is unsafe to call printk() while zone->lock was held, i.e., : : zone->lock --> console_sem doesn't make a lot of sense. console_sem is a sleeping lock so attempting to acquire it (with down()!) under spinlock is a huge bug. Again, please be careful with the descriptions.