Re: [f2fs-dev] [PATCH] f2fs: handle decompress only post processing in softirq

From: Gao Xiang
Date: Tue Jun 14 2022 - 05:12:49 EST


Hi all,

On Mon, Jun 13, 2022 at 10:38:25PM -0700, Eric Biggers wrote:
> [+Cc Nathan Huckleberry who is looking into a similar problem in dm-verity]
>
> On Mon, Jun 13, 2022 at 08:56:12AM -0700, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@xxxxxxxxxx>
> >
> > Now decompression is being handled in workqueue and it makes read I/O
> > latency non-deterministic, because of the non-deterministic scheduling
> > nature of workqueues. So, I made it handled in softirq context only if
> > possible.
> >
> > Signed-off-by: Daeho Jeong <daehojeong@xxxxxxxxxx>

...

>
> One question: is this (the bio endio callback) actually guaranteed to be
> executed from a softirq? If you look at dm-crypt's support for workqueue-less
> decryption, for example, it explicitly checks 'in_hardirq() || irqs_disabled()'
> and schedules a tasklet if either of those is the case.
>
> - Eric
>

Some my own previous thoughts about this strategy:

- If we allocate all memory and map these before I/Os, all inflight I/Os
will keep such temporary pages all the time until decompression is
finished. In contrast, if we allocate or reuse such pages just before
decompression, it would minimize the memory footprints.

I think it will impact the memory numbers at least on the very
low-ended devices with bslow storage. (I've seen f2fs has some big
mempool already)

- Many compression algorithms are not suitable in the softirq contexts,
also I vaguely remembered if softirq context lasts for > 2ms, it will
push into ksoftirqd instead so it's actually another process context.
And it may delay other important interrupt handling.

- Go back to the non-deterministic scheduling of workqueues. I guess it
may be just due to scheduling punishment due to a lot of CPU consuming
due to decompression before so the priority becomes low, but that is
just a pure guess. May be we need to use RT scheduling policy instead.

At least with WQ_HIGHPRI for dm-verity at least, but I don't find
WQ_HIGHPRI mark for dm-verity.

Thanks,
Gao Xiang