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

From: Mikulas Patocka
Date: Fri Aug 09 2019 - 07:30:06 EST




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