Re: [RFC PATCH] btrfs: Replace kmap() with kmap_local_page() in zlib.c

From: Fabio M. De Francesco
Date: Fri Jun 17 2022 - 08:18:37 EST


On martedì 14 giugno 2022 12:47:18 CEST Fabio M. De Francesco wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page(). With
> kmap_local_page(), the mapping is per thread, CPU local and not globally
> visible.
>
> Therefore, use kmap_local_page() / kunmap_local() in zlib.c because in
> this file the mappings are per thread and are not visible in other
> contexts; meanwhile refactor zlib_compress_pages() to comply with nested
> local mapping / unmapping ordering rules.
>
> Tested with xfstests on QEMU + KVM 32 bits VM with 4GB of RAM and
> HIGHMEM64G enabled.
>
> This is an RFC PATCH because it passes all tests of the "compress"
> group, with the only two exceptions of tests/btrfs/138 (it freezes the
> VM) and tests/btrfs/251 (it runs forever but doesn't freeze the VM).
>
> Can anyone please take a look and tell me what I'm still overlooking
> after days of code inspections?
>
> Suggested-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@xxxxxxxxx>
> ---
> fs/btrfs/zlib.c | 75 ++++++++++++++++++++++++++++++++-----------------
> 1 file changed, 50 insertions(+), 25 deletions(-)
>
Please don't respond to this RFC and drop it. I've just split it into three
new versions and send a series of RFC PATCH(es) which seems to work
properly.

They can pass all tests of the group "compress", but I decided to implement
some questionable solutions. Therefore, I'd like to hear about them:

https://lore.kernel.org/lkml/20220617120538.18091-1-fmdefrancesco@xxxxxxxxx/T/#t

Thanks,

Fabio