Re: dm bufio: Reduce dm_bufio_lock contention

From: Mikulas Patocka
Date: Fri Jun 15 2018 - 08:48:00 EST




On Fri, 15 Jun 2018, Michal Hocko wrote:

> On Fri 15-06-18 07:35:07, Mikulas Patocka wrote:
> >
> > Because mempool uses it. Mempool uses allocations with "GFP_NOIO |
> > __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN". An so dm-bufio uses
> > these flags too. dm-bufio is just a big mempool.
>
> This doesn't answer my question though. Somebody else is doing it is not
> an explanation. Prior to your 41c73a49df31 there was no GFP_NOIO
> allocation AFAICS. So why do you really need it now? Why cannot you

dm-bufio always used "GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC |
__GFP_NOWARN" since the kernel 3.2 when it was introduced.

In the kernel 4.10, dm-bufio was changed so that it does GFP_NOWAIT
allocation, then drops the lock and does GFP_NOIO with the dropped lock
(because someone was likely experiencing the same issue that is reported
in this thread) - there are two commits that change it - 9ea61cac0 and
41c73a49df31.

> simply keep retrying GFP_NOWAIT with your own throttling?
>
> Note that I am not trying to say that 41c73a49df31, I am merely trying
> to understand why this blocking allocation is done in the first place.
>
> > If you argue that these flags are incorrect - then fix mempool_alloc.
>
> AFAICS there is no report about mempool_alloc stalling here. Maybe this

If the page allocator can stall dm-bufio, it can stall mempool_alloc as
well. dm-bufio is just bigger, so it will hit this bug sooner.

> is the same class of problem, honestly, I dunno. And I've already said
> that stalling __GFP_NORETRY might be a good way around that but that
> needs much more consideration and existing users examination. I am not
> aware anybody has done that. Doing changes like that based on a single
> user is certainly risky.

Why don't you set any rules how these flags should be used?

If you use GFP_NOIO | __GFP_NORETRY in your own code and blame other
people for doing so - you are as much evil as Linus, who praised people
for reverse-engineering hardware and blamed them for reverse-engineering
bitkeeper :-)

Mikulas