Re: [PATCH v2] mm: might_sleep warning

From: Pavel Tatashin
Date: Wed Mar 07 2018 - 13:01:56 EST


> Hi,
>
> I've noticed that this function first disables the on-demand
> initialization, and then runs the kthreads. Doesn't that leave a window
> where allocations can fail? The chances are probably small, but I think
> it would be better to avoid it completely, rare failures suck.
>
> Fixing that probably means rethinking the whole synchronization more
> dramatically though :/
>
> Vlastimil

Hi Vlastimil,

You are right, there is a window, it is short, and probably not
possible to reproduce, as it happens before user threads are started,
and after init calls done by smp_init() are finished. The only way it
can happen, as far as I can see, is if some device fires an interrupt,
and interrupt handler decides to allocate a large chunk of memory. The
small allocations will succeed, as zone grow function growth more than
strictly requested, and also there are zones without deferred pages.

I will, however, think some more how to solve this problem to be future proof.

Thank you,
Pavel