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)
Fri, Sep 27, 6:51 PM
Unknown Object (File)
Tue, Sep 24, 4:30 AM
Unknown Object (File)
Mon, Sep 23, 1:06 PM
Unknown Object (File)
Sun, Sep 22, 2:06 AM
Unknown Object (File)
Tue, Sep 17, 2:20 AM
Unknown Object (File)
Aug 27 2024, 11:34 AM
Unknown Object (File)
Aug 24 2024, 4:55 PM
Unknown Object (File)
Aug 5 2024, 9:54 AM
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 58303
Build 55191: 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
198

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
198

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

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

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
198

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.