Page MenuHomeFreeBSD

LinuxKPI; cleanup slab.h a bit; move more free() into slab.c
ClosedPublic

Authored by bz on Mar 29 2025, 6:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 30, 10:38 PM
Unknown Object (File)
Fri, Nov 28, 5:06 PM
Unknown Object (File)
Thu, Nov 27, 4:50 AM
Unknown Object (File)
Tue, Nov 25, 10:35 PM
Unknown Object (File)
Sun, Nov 16, 11:44 AM
Unknown Object (File)
Sat, Nov 15, 6:05 PM
Unknown Object (File)
Nov 8 2025, 10:37 PM
Unknown Object (File)
Nov 5 2025, 7:18 AM
Subscribers

Details

Summary

Move kfree() into slab.c as an implementation and hide the private
function linux_kfree_async() entirely.

Remove a ; at the end of a define and sort some defines into place.

Remove extern from function declarations and move the closer to where
they belong.

Sort the functions into "base allocator/free" functions--these have
an implementation in slab.c and are ensuring contiguous physical
memory allocations.

Followed by inline functions using these base allocators to implement
their functionality; vmalloc/kvalloc, and misc functions.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.Mar 29 2025, 6:35 PM

The patch makes the code a lot clearer, thank you!

I added two comments to further clean up the code.

sys/compat/linuxkpi/common/include/linux/slab.h
171–172

Should linux_check_m_flags() be used closer to the native *alloc() calls only?

The underlying lkpi___kmalloc() function already does it. Using it too early might clear some flags that lkpi___kmalloc() interprets in the future.

234–237

Likewise here, I think linux_check_m_flags() is called too early.

bz marked 2 inline comments as done.

Remove two extra calls to linux_check_m_flags() where the underlying alloc
functions deal with that as pointed out by @dumbbell.

sys/compat/linuxkpi/common/include/linux/slab.h
234–237

Good catches. Updated.

This revision is now accepted and ready to land.Apr 1 2025, 3:52 PM