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=-7.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 83F02C433E0 for ; Thu, 11 Mar 2021 17:51:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E35FC64FD6 for ; Thu, 11 Mar 2021 17:51:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E35FC64FD6 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 4E7AF8D02D7; Thu, 11 Mar 2021 12:51:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 497B48D02B2; Thu, 11 Mar 2021 12:51:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3381D8D02D7; Thu, 11 Mar 2021 12:51:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id 1214C8D02B2 for ; Thu, 11 Mar 2021 12:51:02 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C020E365E for ; Thu, 11 Mar 2021 17:51:01 +0000 (UTC) X-FDA: 77908334322.30.04D113A Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP id 22C6DE005F05 for ; Thu, 11 Mar 2021 17:50:58 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id EB68264F93; Thu, 11 Mar 2021 17:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615485055; bh=QDASRPXhjMA2e2jMibB5HEDLwOxOvU8zcbAAQZpaVqo=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Hivnwp2FLA5U5LKOicyIaWSwa0af7vR6EsRbFWoJQV9T+kng1fdB9O9MfgD1ld1Jl Dm6oqKl4JNqQG8RNC4YUIXiuh6PNisuZqgXpeEJ6MtlBCKFX0EyLlziajiwXWVh3l2 DLb1yQagXkxMNzqUKZ574csqvn9Ma/fLwJUnT5QmoUCdXBieE9Wsqxbl9bsIDSmgzO RNkkHWW7BrNDvpq8v+Iay5VSynwZreUmtp1koNN4PmlZBAf2k1yUpltelbvscWiv/D sHBIhVI3Dr0oPUD2SHZxd24kU60KLVuiKK7/bK///sRyrZSja5VTls2wYxmAYfwl95 MblZMEA0TM9yQ== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 80CF83523945; Thu, 11 Mar 2021 09:50:54 -0800 (PST) Date: Thu, 11 Mar 2021 09:50:54 -0800 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Michal Hocko , Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt , tglx@linutronix.de, john.ogness@linutronix.de, urezki@gmail.com, ast@fb.com, Eric Dumazet , Mina Almasry , Andrew Morton Subject: Re: [PATCH] hugetlb: select PREEMPT_COUNT if HUGETLB_PAGE for in_atomic use Message-ID: <20210311175054.GA2696@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20210311021321.127500-1-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Stat-Signature: 1gpujx7qddq3moujxwybwewi5ru4rr3e X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 22C6DE005F05 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615485058-98194 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 Thu, Mar 11, 2021 at 12:36:51PM +0100, Peter Zijlstra wrote: > On Thu, Mar 11, 2021 at 12:09:15PM +0100, Michal Hocko wrote: > > > Sorry for being dense but I do not follow. You have provided the > > following example > > spin_lock(&A); > > > > spin_lock(&A); > > > > if A == hugetlb_lock then we should never reenter with > > free_huge_page > > What I'm saying is that if irq_disabled(), the that interrupt cannot > happen, so the second spin_lock cannot happen, so the deadlock cannot > happen. > > So: '!irqs_disabled() && in_atomic()' is sufficient to avoid the IRQ > recursion deadlock. > > Also, Linus hates constructs like this: > > https://lkml.kernel.org/r/CAHk-=wht7kAeyR5xEW2ORj7m0hibVxZ3t+2ie8vNHLQfdbN2_g@mail.gmail.com To be fair, later in that same thread Linus states that his main concern is not core code, but rather driver code: https://lore.kernel.org/lkml/CAHk-=wjsMycgMHJrCmeetR3r+K5bpSRtmVWfd8iaoQCYd_VYAg@mail.gmail.com/ Nevertheless, if the job can be done reasonably without checking the preemption/interrupt state, why not? And Mike's patch is still useful for people hitting this bug. Thanx, Paul > > From the code simplicity POV (and hugetlb has grown a lot of complexity) > > it would be really easiest to make sure __free_huge_page to be called > > from a non-atomic process context. There are few ways to do that > > - defer each call to a WQ - user visible which sucks > > - defer from atomic or otherwise non-sleeping contextx - requires > > reliable in_atomic AFAICS > > - defer sleeping operations - makes the code flow more complex and it > > would be again user visible in some cases. > > > > So I would say we are in "pick your own poison" kind of situation. > > Just to be clear: > > NAK on this patch and any and all ductape crap. Fix it properly, make > hugetlb_lock, spool->lock IRQ-safe, move the workqueue into the CMA > thing. > > The code really doesn't look _that_ complicated.