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);
> >   <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.
> 
> Also, Linus hates constructs like this:
> 
>   
> https://lkml.kernel.org/r/CAHk-=wht7kaeyr5xew2orj7m0hibvxz3t+2ie8vnhlqfdbn...@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_v...@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.

Reply via email to