linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Michal Hocko <mhocko@suse.com>, Peter Zijlstra <peterz@infradead.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Shakeel Butt <shakeelb@google.com>,
	tglx@linutronix.de, john.ogness@linutronix.de, urezki@gmail.com,
	ast@fb.com, Eric Dumazet <edumazet@google.com>,
	Mina Almasry <almasrymina@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hugetlb: select PREEMPT_COUNT if HUGETLB_PAGE for in_atomic use
Date: Thu, 11 Mar 2021 09:25:49 -0800	[thread overview]
Message-ID: <90abce15-9ece-d290-98ec-771addef9748@oracle.com> (raw)
In-Reply-To: <YEoGyQJucV6FV3zY@dhcp22.suse.cz>

On 3/11/21 4:02 AM, Michal Hocko wrote:
> 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);
>>>   <IRQ>
>>>         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.

Thanks you Michal and Peter.  This patch was mostly about starting a
discussion, as this topic came up in a couple different places.  I
included the 'train wreck' of how we got here just for a bit of history.

I'll start working on a proper fix.
-- 
Mike Kravetz


  reply	other threads:[~2021-03-11 17:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  2:13 Mike Kravetz
2021-03-11  5:43 ` Andrew Morton
2021-03-11  8:20   ` Michal Hocko
2021-03-11  8:26 ` Michal Hocko
2021-03-11  8:27   ` Michal Hocko
2021-03-11  8:46 ` Peter Zijlstra
2021-03-11  9:01   ` Michal Hocko
2021-03-11  9:32     ` Peter Zijlstra
2021-03-11  9:44       ` Michal Hocko
2021-03-11  9:52         ` Peter Zijlstra
2021-03-11 11:09           ` Michal Hocko
2021-03-11 11:36             ` Peter Zijlstra
2021-03-11 12:02               ` Michal Hocko
2021-03-11 17:25                 ` Mike Kravetz [this message]
2021-03-11 12:49               ` Michal Hocko
2021-03-11 17:50               ` Paul E. McKenney
2021-03-11  9:49 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90abce15-9ece-d290-98ec-771addef9748@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=ast@fb.com \
    --cc=edumazet@google.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shakeelb@google.com \
    --cc=tglx@linutronix.de \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox