Re: [PATCH] direct-io: use GFP_NOIO to avoid deadlock

Mikulas Patocka
2019-08-09T11:30:04Z

On Fri, 9 Aug 2019, Dave Chinner wrote:

> And, FWIW, there's an argument to be made here that the underlying
> bug is dm_bufio_shrink_scan() blocking kswapd by waiting on IO
> completions while holding a mutex that other IO-level reclaim
> contexts require to make progress.
>
> Cheers,
>
> Dave.

The IO-level reclaim contexts should use GFP_NOIO. If the dm-bufio
shrinker is called with GFP_NOIO, it cannot be blocked by kswapd, because:
* it uses trylock to acquire the mutex
* it doesn't attempt to free buffers that are dirty or under I/O (see
__try_evict_buffer)

I think that this logic is sufficient to prevent the deadlock.

Mikulas