All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/3] btrfs: Convert zlib.c to use kmap_local_page()
@ 2022-06-17 12:05 Fabio M. De Francesco
  2022-06-17 12:05 ` [RFC PATCH v2 1/3] btrfs: Convert zlib_decompress_bio() " Fabio M. De Francesco
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Fabio M. De Francesco @ 2022-06-17 12:05 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Nick Terrell, Chris Down,
	Filipe Manana, Qu Wenruo, Nikolay Borisov, Gabriel Niebler,
	Ira Weiny, linux-btrfs, linux-kernel
  Cc: Fabio M. De Francesco

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.

This is an RFC because patch 3/3 uses an horrid hack. I'm using an array
based stack which tracks local mappings / un-mappings. I understand that
it is not the better solution, but it works and it is easy to implement :)

I've decided to decompose RFC v1 into a series of three patches in order to
make clear that I encountered problems with conversions in patch 3/3. I'm
pretty sure that people who are familiar with these functions could refactor
this code and provide much more elegant and efficient solutions.

Since this code currently uses kmap() / kunmap(), I think that the functions
I'm converting had been designed without taking into account the rules of
ordering of nesting local mappings / un-mappings.

I've been trying to refactor this code but it is something beyond my current
level of knowledge and skills...

Can anyone please provide any better suited solutions for patch 3/3?

Tested with xfstests on QEMU + KVM 32 bits VM with 4GB of RAM and
HIGHMEM64G enabled. Each patch of this series passes 26/26 tests of group
"compress".

tweed32:/usr/lib/xfstests # ./check -g compress
FSTYP         -- btrfs
PLATFORM      -- Linux/i686 tweed32 5.19.0-rc2-vanilla-debug+ #45 SMP PREEMPT_DYNAMIC Fri Jun 17 11:14:11 CEST 2022
MKFS_OPTIONS  -- /dev/loop1
MOUNT_OPTIONS -- /dev/loop1 /mnt/scratch

btrfs/024 2s ...  3s
btrfs/026 5s ...  5s
btrfs/037 3s ...  3s
btrfs/038 3s ...  2s
btrfs/041 3s ...  3s
btrfs/062 41s ...  41s
btrfs/063 22s ...  23s
btrfs/067 39s ...  40s
btrfs/068 14s ...  14s
btrfs/070	[not run] btrfs and this test needs 5 or more disks in SCRATCH_DEV_POOL
btrfs/071	[not run] btrfs and this test needs 5 or more disks in SCRATCH_DEV_POOL
btrfs/072 39s ...  41s
btrfs/073 20s ...  20s
btrfs/074 41s ...  41s
btrfs/076 3s ...  3s
btrfs/103 3s ...  3s
btrfs/106 3s ...  3s
btrfs/109 3s ...  3s
btrfs/113 3s ...  3s
btrfs/138 53s ...  54s
btrfs/149 3s ...  3s
btrfs/183 3s ...  2s
btrfs/205 4s ...  3s
btrfs/234 4s ...  4s
btrfs/246 2s ...  3s
btrfs/251 3s ...  2s
Ran: btrfs/024 btrfs/026 btrfs/037 btrfs/038 btrfs/041 btrfs/062 btrfs/063 btrfs/067 btrfs/068 btrfs/070 btrfs/071 btrfs/072 btrfs/073 btrfs/074 btrfs/076 btrfs/103 btrfs/106 btrfs/109 btrfs/113 btrfs/138 btrfs/149 btrfs/183 btrfs/205 btrfs/234 btrfs/246 btrfs/251
Not run: btrfs/070 btrfs/071
Passed all 26 tests

Fabio M. De Francesco (3):
  btrfs: Convert zlib_decompress_bio() to use kmap_local_page()
  btrfs: Use kmap_local_page() on "out_page" in zlib_compress_pages()
  btrfs: Use kmap_local_page() on "in_page" in zlib_compress_pages()

 fs/btrfs/zlib.c | 91 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 67 insertions(+), 24 deletions(-)

-- 
2.36.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-18  9:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-17 12:05 [RFC PATCH v2 0/3] btrfs: Convert zlib.c to use kmap_local_page() Fabio M. De Francesco
2022-06-17 12:05 ` [RFC PATCH v2 1/3] btrfs: Convert zlib_decompress_bio() " Fabio M. De Francesco
2022-06-17 12:51   ` Qu Wenruo
2022-06-17 17:35     ` Fabio M. De Francesco
2022-06-17 12:05 ` [RFC PATCH v2 2/3] btrfs: Use kmap_local_page() on "out_page" in zlib_compress_pages() Fabio M. De Francesco
2022-06-17 12:54   ` Qu Wenruo
2022-06-17 17:46     ` Fabio M. De Francesco
2022-06-17 12:05 ` [RFC PATCH v2 3/3] btrfs: Use kmap_local_page() on "in_page" " Fabio M. De Francesco
2022-06-17 13:09   ` Qu Wenruo
2022-06-17 14:20     ` David Sterba
2022-06-17 18:25       ` Fabio M. De Francesco
2022-06-17 18:13     ` Fabio M. De Francesco
2022-06-17 22:16       ` Qu Wenruo
2022-06-18  9:04         ` Fabio M. De Francesco

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.