Page MenuHomeFreeBSD

LinuxKPI: Add kvrealloc to linux/slab.h
ClosedPublic

Authored by wulf on Jun 16 2024, 8:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 3:22 AM
Unknown Object (File)
Tue, Nov 19, 3:22 AM
Unknown Object (File)
Tue, Nov 19, 3:21 AM
Unknown Object (File)
Tue, Nov 19, 3:21 AM
Unknown Object (File)
Tue, Nov 19, 3:01 AM
Unknown Object (File)
Oct 3 2024, 7:30 PM
Unknown Object (File)
Oct 3 2024, 5:25 PM
Unknown Object (File)
Sep 27 2024, 6:51 PM
Subscribers

Details

Summary

Sponsored by: Serenity Cyber Security, LLC
MFC after: 1 week

Diff Detail

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

Event Timeline

wulf requested review of this revision.Jun 16 2024, 8:31 PM
This revision is now accepted and ready to land.Jun 17 2024, 5:34 AM
bz requested changes to this revision.Jun 17 2024, 9:44 AM
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/slab.h
196

This should really use a kvrealloc (which we don't have yet).
See 8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf for the discussion. And I can say that the hypothetical case in that commit message is actually coming.
So this implementation as-is would likely be wrong in the future.

Alternatively please leave a comment /* XXX-BZ realloc */ here.

This revision now requires changes to proceed.Jun 17 2024, 9:44 AM
sys/compat/linuxkpi/common/include/linux/slab.h
196

In particular the comment at https://reviews.freebsd.org/D45181#1031077.

sys/compat/linuxkpi/common/include/linux/slab.h
196

Why do we need re-implementation of kv* functions?
According to https://www.kernel.org/doc/html/v5.0/core-api/memory-allocation.html kvalloc()/kvrealloc()/kvfree() is exactly what FreeBSD implements as malloc()/realloc()/free(). It combines both slab-based and vm page-based allocators.
Linux`s kmalloc() and vmalloc() is just stripped down of kvalloc(). The first one only for slab and the second one only for vm page allocations. FreeBSD combines both of them in single malloc().

Implement kvrealloc via kvmalloc/kvfree pair

wulf marked an inline comment as done.Jun 22 2024, 2:12 PM
wulf added inline comments.
sys/compat/linuxkpi/common/include/linux/slab.h
196

After glance over code kvmalloc appeared to be a different thing. It tries to allocate pages contiguously and fall-backs to noncontig allocations

This revision was not accepted when it landed; it landed in state Needs Review.Jul 21 2024, 1:15 PM
This revision was automatically updated to reflect the committed changes.