ZXFoundation™ 26h2
Loading...
Searching...
No Matches
core.cxxm File Reference

SLUB slab allocator — full SMP-aware implementation — core interface. More...

Include dependency graph for core.cxxm:

Functions

auto zxfoundation::memory::slub::kmem_alloc (kmem_cache &cache) noexcept -> void *
 Allocate one object from the given cache.
template<typename T>
auto zxfoundation::memory::slub::kmem_alloc_t (kmem_cache &cache) noexcept -> T *
 Typed allocation helper — returns a pointer to T.
auto zxfoundation::memory::slub::kmem_cache_count () noexcept -> u32
 Return the total number of registered caches.
auto zxfoundation::memory::slub::kmem_cache_create (const char *name, u32 object_size, u32 align, slub_flags flags) noexcept -> std::expected< kmem_cache_ref_active, lib::kernel_error >
 Create a new slab cache.
auto zxfoundation::memory::slub::kmem_cache_destroy (kmem_cache *cache) noexcept -> void
 Destroy a slab cache.
auto zxfoundation::memory::slub::kmem_cache_live_objects (const kmem_cache &cache) noexcept -> i64
 Return the number of live (allocated) objects in a cache.
auto zxfoundation::memory::slub::kmem_cache_shrink (kmem_cache *cache) noexcept -> u32
 Return empty node-partial slabs to PMM.
auto zxfoundation::memory::slub::kmem_free (kmem_cache &cache, void *obj) noexcept -> void
 Typed allocation helper — returns a pointer to T.
auto zxfoundation::memory::slub::kmem_free_raw (void *ptr) noexcept -> void
 Free a slab-allocated object without knowing its cache.
auto zxfoundation::memory::slub::kmem_get_cache (u32 idx) noexcept -> kmem_cache *
 Return a pointer to the Nth registered cache, or nullptr.
auto zxfoundation::memory::slub::slub_attach_authorities () noexcept -> void
 Attach memory_object authorities to all live kmem_caches.
auto zxfoundation::memory::slub::slub_init () noexcept -> void
 Initialise the SLUB allocator. Must be called before any kmem_cache_create(). Allocates the cache table from PMM (PMM must be initialized).

Detailed Description

SLUB slab allocator — full SMP-aware implementation — core interface.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ kmem_alloc()

auto zxfoundation::memory::slub::kmem_alloc ( kmem_cache & cache) ->void *
nodiscardexportnoexcept

Allocate one object from the given cache.

Returns
Pointer to the allocated object (HHDM virtual address), or nullptr on OOM.

◆ kmem_alloc_t()

template<typename T>
auto zxfoundation::memory::slub::kmem_alloc_t ( kmem_cache & cache) ->T *
nodiscardexportnoexcept

Typed allocation helper — returns a pointer to T.

Template Parameters
TObject type. sizeof(T) must equal cache.object_size.

◆ kmem_cache_create()

auto zxfoundation::memory::slub::kmem_cache_create ( const char * name,
u32 object_size,
u32 align,
slub_flags flags )->std::expected< kmem_cache_ref_active, lib::kernel_error >
nodiscardexportnoexcept

Create a new slab cache.

Parameters
[in]nameASCII name for diagnostics.
[in]object_sizesizeof(T) for the object type.
[in]alignRequired alignment. 0 → use object_size alignment.
[in]flagsslub_flags bitmask.

◆ kmem_free()

auto zxfoundation::memory::slub::kmem_free ( kmem_cache & cache,
void * obj )->void
exportnoexcept

Typed allocation helper — returns a pointer to T.

Free one object back to its cache.

Template Parameters
TObject type. sizeof(T) must equal cache.object_size.

Free one object back to its cache.

Parameters
[in]cacheThe cache the object was allocated from.
[in]objPointer to the object to free.
[in]cacheThe cache the object was allocated from.
[in]objPointer to the object to free.

◆ slub_init()

auto zxfoundation::memory::slub::slub_init ( ) ->void
exportnoexcept

Initialise the SLUB allocator. Must be called before any kmem_cache_create(). Allocates the cache table from PMM (PMM must be initialized).

Initialise the SLUB allocator.