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=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 4B8F2ECE58C for ; Mon, 7 Oct 2019 11:33:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1D9420867 for ; Mon, 7 Oct 2019 11:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1D9420867 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 437C48E0005; Mon, 7 Oct 2019 07:33:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C1238E0003; Mon, 7 Oct 2019 07:33:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 288928E0005; Mon, 7 Oct 2019 07:33:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 00C2F8E0003 for ; Mon, 7 Oct 2019 07:33:04 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 561C5180AD803 for ; Mon, 7 Oct 2019 11:33:04 +0000 (UTC) X-FDA: 76016777088.17.stone56_8f30d8339d418 X-HE-Tag: stone56_8f30d8339d418 X-Filterd-Recvd-Size: 3534 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Oct 2019 11:33:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4BCF5ABD9; Mon, 7 Oct 2019 11:33:02 +0000 (UTC) Date: Mon, 7 Oct 2019 13:33:01 +0200 From: Michal Hocko To: Petr Mladek Cc: Qian Cai , akpm@linux-foundation.org, sergey.senozhatsky.work@gmail.com, rostedt@goodmis.org, peterz@infradead.org, david@redhat.com, john.ogness@linutronix.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/page_isolation: fix a deadlock with printk() Message-ID: <20191007113301.GG2381@dhcp22.suse.cz> References: <1570228005-24979-1-git-send-email-cai@lca.pw> <20191007080742.GD2381@dhcp22.suse.cz> <20191007090553.g5cq7qa4tj5yrtaa@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191007090553.g5cq7qa4tj5yrtaa@pathway.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 07-10-19 11:05:53, Petr Mladek wrote: > On Mon 2019-10-07 10:07:42, Michal Hocko wrote: > > On Fri 04-10-19 18:26:45, Qian Cai wrote: > > > It is unsafe to call printk() while zone->lock was held, i.e., > > > > > > zone->lock --> console_lock > > > > > > because the console could always allocate some memory in different code > > > paths and form locking chains in an opposite order, > > > > > > console_lock --> * --> zone->lock > > > > > > As the result, it triggers lockdep splats like below and in different > > > code paths in this thread [1]. Since has_unmovable_pages() was only used > > > in set_migratetype_isolate() and is_pageblock_removable_nolock(). Only > > > the former will set the REPORT_FAILURE flag which will call printk(). > > > Hence, unlock the zone->lock just before the dump_page() there where > > > when has_unmovable_pages() returns true, there is no need to hold the > > > lock anyway in the rest of set_migratetype_isolate(). > > > > > > While at it, remove a problematic printk() in __offline_isolated_pages() > > > only for debugging as well which will always disable lockdep on debug > > > kernels. > > > > I do not think that removing the printk is the right long term solution. > > While I do agree that removing the debugging printk __offline_isolated_pages > > does make sense because it is essentially of a very limited use, this > > doesn't really solve the underlying problem. There are likely other > > printks from zone->lock. It would be much more saner to actually > > disallow consoles to allocate any memory while printk is called from an > > atomic context. > > The current "standard" solution for these situations is to replace > the problematic printk() with printk_deferred(). It would deffer > the console handling. > > Of course, this is a whack a mole approach. The long term solution > is to deffer printk() by default. We have finally agreed on this > few weeks ago on Plumbers conference. It is going to be added > together with fully lockless log buffer hopefully soon. It will > be part of upstreaming Real-Time related code. OK, then we do not really have to do anything here. That is good to hear because I really detest putting printk_deferred or anything like that at random places. -- Michal Hocko SUSE Labs