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

From: Fabio M. De Francesco
Date: Thu Jul 14 2022 - 03:46:47 EST


On giovedì 14 luglio 2022 02:25:20 CEST Wang Yugui wrote:
> Hi,
>
> Compiler warning:
>
> fs/btrfs/zstd.c:478:55: warning: passing argument 1 of ‘__kunmap_local’
discards ‘const’ qualifier from pointer target type [-Wdiscarded-
qualifiers]
> 478 | kunmap_local(workspace->in_buf.src);
> ./include/linux/highmem-internal.h:284:24: note: in definition of macro
‘kunmap_local’
> 284 | __kunmap_local(__addr); \
> | ^~~~~~
> ./include/linux/highmem-internal.h:200:41: note: expected ‘void *’ but
argument is of type ‘const void *’
> 200 | static inline void __kunmap_local(void *addr)
> | ~~~~~~^~~~
>
> Best Regards
> Wang Yugui (wangyugui@xxxxxxxxxxxx)
> 2022/07/14

Thanks for the build test, but you're a little late :)

This patch is superseded by a series of two: please see
[PATCH v6 0/2] btrfs: Replace kmap() with kmap_local_page() in zstd.c
at https://lore.kernel.org/lkml/20220706111520.12858-1-fmdefrancesco@xxxxxxxxx/

In that series, patch 1/2 changes __kunmap_{local,atomic}() prototypes to
take pointers to const void.

Regards,

Fabio

> > 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 zstd.c because in
> > this file the mappings are per thread and are not visible in other
> > contexts; meanwhile refactor zstd_compress_pages() to comply with
nested
> > local mapping / unmapping ordering rules.
> >