On Wed, Apr 01, 2020 at 09:23:59AM +0200, Michal Hocko wrote: > > Can you suggest what prevents other users of GFP_MEMALLOC from doing that > > also? > > There is no explicit mechanism which is indeed unfortunate. The only > user real user of the flag is Swap over NFS AFAIK. I have never dared to > look into details on how the complete reserves depletion is prevented. > Mel would be much better fit here. > It's "prevented" by the fact that every other memory allocation request that is not involved with reclaiming memory gets stalled in the allocator with only the swap subsystem making any progress until the machine recovers. Potentially only kswapd is still running until the system recovers if stressed hard enough. The naming is terrible but is mased on kswapd's use of the PF_MEMALLOC flag. For swap-over-nfs, GFP_MEMALLOC saying "this allocation request is potentially needed for kswapd to make forward progress and not freeze". I would not be comfortable with kfree_rcu() doing the same thing because there can be many callers in parallel and it's freeing slab objects. Swap over NFS should free at least one page, freeing a slab object is not guaranteed to free anything. -- Mel Gorman SUSE Labs