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 16, 11:44 AM
Unknown Object (File)
Sat, Nov 15, 6:05 PM
Unknown Object (File)
Sat, Nov 8, 10:37 PM
Unknown Object (File)
Wed, Nov 5, 7:18 AM
Unknown Object (File)
Mon, Nov 3, 10:34 AM
Unknown Object (File)
Sat, Nov 1, 2:34 AM
Unknown Object (File)
Sep 28 2025, 2:12 PM
Unknown Object (File)
Sep 27 2025, 5:32 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