Skip to content

Conversation

@dkgupta-amzn
Copy link
Contributor

Fixes:
When we first implemented slab allocator for KTF, we never cared for freeing
memory when entire slab is freed up. Reason being we thought of it as short-
running kernel. However we're into a situation where we're allocating a lot of
memory, thanks for integration of external library doing malloc and free.
This change ensures that if a slab got completly freed up, we free up the memory
and put that meta slab back into free list.
Added a spinlock around allocation, free and initialization

Enhancement:
slab allocator was limited in the sense that it wouldn't allocate more if
meta_slab_t entries contained in globally allocated page at initializaiton
were all exhausted. This change makes a slight design change as follows:-

  • During allocation if meta_slab_t is not available then allocator will do
    • Allocate a fresh page
    • First entry is special meta_slab_t in this page
    • First entry will treat rest of meta_slab_t entries in page as normal
      meta_slab_t entry to allocate user requested memory allocations.
    • Link special meta_slab_t entry in a global list so that all such allocated
      pages are linked together

Note about special meta_slab_t entry:-
Special meta_slab_t is basically to manage meta_slab_t entries itself. It's metadata
of metadata of user allocations.

Signed-off-by: dkgupta [email protected]

@wipawel wipawel linked an issue Jan 5, 2022 that may be closed by this pull request
Fixes:
When we first implemented slab allocator for KTF, we never cared for freeing
memory when entire slab is freed up. Reason being we thought of it as short-
running kernel. However we're into a situation where we're allocating a lot of
memory, thanks for integration of external library doing malloc and free.
This change ensures that if a slab got completly freed up, we free up the memory
and put that meta slab back into free list.
Added a spinlock around allocation, free and initialization

Enhancement:
slab allocator was limited in the sense that it wouldn't allocate more if
meta_slab_t entries contained in globally allocated page at initializaiton
were all exhausted. This change makes a slight design change as follows:-
- During allocation if meta_slab_t is not available then allocator will do
	- Allocate a fresh page
	- First entry is special meta_slab_t in this page
	- First entry will treat rest of meta_slab_t entries in page as normal
	  meta_slab_t entry to allocate user requested memory allocations.
	- Link special meta_slab_t entry in a global list so that all such allocated
	  pages are linked together

Note about special meta_slab_t entry:-
Special meta_slab_t is basically to manage meta_slab_t entries itself. It's metadata
of metadata of user allocations.

Signed-off-by: dkgupta <[email protected]>
@dkgupta-amzn dkgupta-amzn merged commit 1638f4f into KernelTestFramework:mainline Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SLAB: only a limited number of slabs can be allocated

2 participants