linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* folio_map
@ 2022-08-16 18:08 Matthew Wilcox
  2022-08-16 21:23 ` folio_map John Hubbard
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Matthew Wilcox @ 2022-08-16 18:08 UTC (permalink / raw)
  To: Thomas Gleixner, Ira Weiny, Fabio M. De Francesco,
	Luis Chamberlain, linux-fsdevel, linux-mm

Some of you will already know all this, but I'll go into a certain amount
of detail for the peanut gallery.

One of the problems that people want to solve with multi-page folios
is supporting filesystem block sizes > PAGE_SIZE.  Such filesystems
already exist; you can happily create a 64kB block size filesystem on
a PPC/ARM/... today, then fail to mount it on an x86 machine.

kmap_local_folio() only lets you map a single page from a folio.
This works for the majority of cases (eg ->write_begin() works on a
per-page basis *anyway*, so we can just map a single page from the folio).
But this is somewhat hampering for ext2_get_page(), used for directory
handling.  A directory record may cross a page boundary (because it
wasn't a page boundary on the machine which created the filesystem),
and juggling two pages being mapped at once is tricky with the stack
model for kmap_local.

I don't particularly want to invest heavily in optimising for HIGHMEM.
The number of machines which will use multi-page folios and HIGHMEM is
not going to be large, one hopes, as 64-bit kernels are far more common.
I'm happy for 32-bit to be slow, as long as it works.

For these reasons, I proposing the logical equivalent to this:

+void *folio_map_local(struct folio *folio)
+{
+       if (!IS_ENABLED(CONFIG_HIGHMEM))
+               return folio_address(folio);
+       if (!folio_test_large(folio))
+               return kmap_local_page(&folio->page);
+       return vmap_folio(folio);
+}
+
+void folio_unmap_local(const void *addr)
+{
+       if (!IS_ENABLED(CONFIG_HIGHMEM))
+               return;
+       if (is_vmalloc_addr(addr))
+               vunmap(addr);
+	else
+       	kunmap_local(addr);
+}

(where vmap_folio() is a new function that works a lot like vmap(),
chunks of this get moved out-of-line, etc, etc., but this concept)

Does anyone have any better ideas?  If it'd be easy to map N pages
locally, for example ... looks like we only support up to 16 pages
mapped per CPU at any time, so mapping all of a 64kB folio would
almost always fail, and even mapping a 32kB folio would be unlikely
to succeed.


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

end of thread, other threads:[~2022-08-22 19:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-16 18:08 folio_map Matthew Wilcox
2022-08-16 21:23 ` folio_map John Hubbard
2022-08-17 10:29 ` folio_map Kirill A. Shutemov
2022-08-17 19:38   ` folio_map Matthew Wilcox
2022-08-17 20:23     ` folio_map Ira Weiny
2022-08-17 20:52       ` folio_map Ira Weiny
2022-08-17 21:34         ` folio_map Matthew Wilcox
2022-08-18  1:28           ` folio_map Ira Weiny
2022-08-18  0:25 ` folio_map Dave Chinner
2022-08-18 21:10 ` [RFC] vmap_folio() Matthew Wilcox
2022-08-19 10:53   ` Uladzislau Rezki
2022-08-19 15:45     ` Matthew Wilcox
2022-08-22 19:54       ` Uladzislau Rezki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).