Page MenuHomeFreeBSD

LinuxKPI: Add kvrealloc to linux/slab.h
Needs ReviewPublic

Authored by wulf on Sun, Jun 16, 8:31 PM.
Tags
None
Referenced Files
F86888255: D45616.diff
Thu, Jun 27, 1:58 AM
Unknown Object (File)
Sun, Jun 23, 6:48 AM
Unknown Object (File)
Thu, Jun 20, 4:40 PM
Unknown Object (File)
Sun, Jun 16, 10:27 PM
Subscribers

Details

Reviewers
bz
manu
dumbbell
emaste
Group Reviewers
linuxkpi
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.Sun, Jun 16, 8:31 PM
This revision is now accepted and ready to land.Mon, Jun 17, 5:34 AM
bz requested changes to this revision.Mon, Jun 17, 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.Mon, Jun 17, 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.Sat, Jun 22, 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