Page MenuHomeFreeBSD

vm: Add kva_alloc_aligned
ClosedPublic

Authored by andrew on Nov 28 2023, 4:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 18, 6:36 AM
Unknown Object (File)
Sep 30 2024, 7:05 PM
Unknown Object (File)
Sep 18 2024, 7:40 AM
Unknown Object (File)
Sep 9 2024, 4:53 PM
Unknown Object (File)
Sep 4 2024, 10:54 AM
Unknown Object (File)
Sep 2 2024, 9:41 AM
Unknown Object (File)
Jul 29 2024, 7:34 AM
Unknown Object (File)
Jul 29 2024, 5:58 AM
Subscribers

Details

Summary

Add a function like kva_alloc that allows us to specify the alignment
of the virtual address space returned.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 54642
Build 51531: arc lint + arc unit

Event Timeline

sys/vm/vm_kern.c
172

See my comment in D42787 - I think this can simply use vmem_xalloc() when align > PAGE_SIZE. Using vmem_xalloc() unconditionally would also be fine.

sys/vm/vm_kern.c
171

This is unnecessary both here and in kva_alloc() and kva_free() because the kernel_arena is initialized with PAGE_SIZE as the allocation granularity.

172

Agreed. The only catch is that the documentation for vmem says that allocations obtained from vmem_xalloc() must be freed with vmem_xfree() (presumably so that freed allocations don't wind up in the quantum cache where vmem_xalloc() couldn't reallocate them). We don't enable the quantum cache for the kernel_arena, and I don't see us changing that, so we can simply change kva_alloc() and kva_free() to use vmem_xalloc() and vmem_xfree(), respectively.

sys/vm/vm_kern.c
172

The alignment should probably be at least PAGE_SIZE as the smallest allocation is a page. I don't have a check, but could add one.

This revision is now accepted and ready to land.Nov 29 2023, 4:05 PM
alc added inline comments.
sys/vm/vm_kern.c
172

It would be redundant. At initialization, we specify the page size as the granularity of allocation for this arena. Any such allocation will satisfy non-zero alignment values that are less than the page size.

This revision was automatically updated to reflect the committed changes.