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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 BE479C433DB for ; Thu, 11 Mar 2021 12:02:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A70564FBA for ; Thu, 11 Mar 2021 12:02:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A70564FBA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 249758D02B4; Thu, 11 Mar 2021 07:02:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 220168D02B2; Thu, 11 Mar 2021 07:02:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E8838D02B4; Thu, 11 Mar 2021 07:02:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id F03D98D02B2 for ; Thu, 11 Mar 2021 07:02:27 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B7AA9180ACEEB for ; Thu, 11 Mar 2021 12:02:27 +0000 (UTC) X-FDA: 77907455934.16.0DA471D Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf20.hostedemail.com (Postfix) with ESMTP id 33E88F4 for ; Thu, 11 Mar 2021 12:02:20 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615464143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=M+OxKdOwj9xa7tsZOhdYegq5nkjAQ3QXloTE+/Q9m0Y=; b=bPhG46sHrlmPCblpOdNr0xZ4mQ+YEg0IM10HMhpAdQ0z6Mb/PjyxiQf3LQ+nUk9h2qdyYr 6bJJ3bC+Ibkthe/mH4bphIJeADBf36GsRcn7UwdQ4ZalXDhAWtt9/449m4RXUpzJC2xa9t bi1iVLUPORSbfdIIKbE2JNH3tATn6Xc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5E619AC17; Thu, 11 Mar 2021 12:02:23 +0000 (UTC) Date: Thu, 11 Mar 2021 13:02:17 +0100 From: Michal Hocko To: Peter Zijlstra Cc: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , 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: 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: X-Stat-Signature: rqezofnebpaeqarayr181anfikpmsbn4 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 33E88F4 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615464140-522159 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 11-03-21 12:36:51, 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. OK, then I understand your point now. I thought you were arguing an actual deadlock scenario. As I've said irq_disabled check would be needed for sleeping operations that we already do. > Also, Linus hates constructs like this: > > https://lkml.kernel.org/r/CAHk-=wht7kAeyR5xEW2ORj7m0hibVxZ3t+2ie8vNHLQfdbN2_g@mail.gmail.com > > > 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. Fair enough. As I've said I am not a great fan of this patch either but it is a quick fix for a likely long term problem. If reworking the hugetlb locking is preferable then be it. -- Michal Hocko SUSE Labs