Re: [PATCH 2/2] fuse: Adjust readdir() buffer to requesting buffer size.

From: Jaco Kroon
Date: Wed Apr 02 2025 - 04:53:14 EST


Hi,

On 2025/04/02 10:18, Miklos Szeredi wrote:
On Wed, 2 Apr 2025 at 09:55, Jaco Kroon <jaco@xxxxxxxxx> wrote:
Hi,

I can definitely build on that, thank you.

What's the advantage of kvmalloc over folio's here, why should it be
preferred?
It offers the best of both worlds: first tries plain malloc (which
just does a folio alloc internally for size > PAGE_SIZE) and if that
fails, falls back to vmalloc, which should always succeed since it
uses order 0 pages.

So basically assigns the space, but doesn't commit physical pages for the allocation, meaning first access will cause a page fault, and single page allocation at that point in time?  Or is it merely the fact that vmalloc may return a virtual contiguous block that's not physically contiguous?

Sorry if I'm asking notoriously dumb questions, I've got a VERY BASIC grasp of memory management at kernel level, I work much more in userspace, and I know there usually first access generates a page fault which will then result in memory being physically allocated by the kernel.  Generally I ignore these complexities and just assume that the "lower down" layers know what they're doing and I've got a "flat, contiguous" memory space, and that malloc knows what it's doing and will communicate with the kernel regarding which regions of virtual space should be mapped.  Love the learning though, so appreciate the feedback very much.


This saves the trouble of iterating the folio alloc until it succeeds,
which is both undeterministic and complex, neither of which is
desirable.

Agreed.



Thanks,
Miklos