mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-06 02:28:30 +00:00
slab: add option to free empty blocks
explictly by a method Issue #4014
This commit is contained in:
parent
19d0142e10
commit
1e84b46c3f
@ -340,7 +340,11 @@ class Genode::Allocator_avl_tpl : public Allocator_avl_base
|
|||||||
_metadata((metadata_chunk_alloc) ? metadata_chunk_alloc : this,
|
_metadata((metadata_chunk_alloc) ? metadata_chunk_alloc : this,
|
||||||
(Block *)&_initial_md_block) { }
|
(Block *)&_initial_md_block) { }
|
||||||
|
|
||||||
~Allocator_avl_tpl() { _revert_allocations_and_ranges(); }
|
~Allocator_avl_tpl()
|
||||||
|
{
|
||||||
|
_metadata.free_empty_blocks();
|
||||||
|
_revert_allocations_and_ranges();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return size of slab blocks used for meta data
|
* Return size of slab blocks used for meta data
|
||||||
|
@ -138,6 +138,12 @@ class Genode::Slab : public Allocator
|
|||||||
Allocator *backing_store() { return _backing_store; }
|
Allocator *backing_store() { return _backing_store; }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free memory of empty slab blocks
|
||||||
|
*/
|
||||||
|
void free_empty_blocks();
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
** Allocator interface **
|
** Allocator interface **
|
||||||
*************************/
|
*************************/
|
||||||
|
@ -208,6 +208,7 @@ _ZN6Genode4Lock4lockEv T
|
|||||||
_ZN6Genode4Lock6unlockEv T
|
_ZN6Genode4Lock6unlockEv T
|
||||||
_ZN6Genode4LockC1ENS0_5StateE T
|
_ZN6Genode4LockC1ENS0_5StateE T
|
||||||
_ZN6Genode4Slab13any_used_elemEv T
|
_ZN6Genode4Slab13any_used_elemEv T
|
||||||
|
_ZN6Genode4Slab17free_empty_blocksEv T
|
||||||
_ZN6Genode4Slab5Block11_slab_entryEi T
|
_ZN6Genode4Slab5Block11_slab_entryEi T
|
||||||
_ZN6Genode4Slab5Block14any_used_entryEv T
|
_ZN6Genode4Slab5Block14any_used_entryEv T
|
||||||
_ZN6Genode4Slab5Block5allocEv T
|
_ZN6Genode4Slab5Block5allocEv T
|
||||||
|
@ -416,6 +416,17 @@ void Slab::_free(void *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Slab::free_empty_blocks()
|
||||||
|
{
|
||||||
|
for (size_t blocks = _num_blocks; blocks > 0; blocks--) {
|
||||||
|
if (_curr_sb != _initial_sb && _curr_sb->avail() == _entries_per_block)
|
||||||
|
_free_curr_sb();
|
||||||
|
else
|
||||||
|
_curr_sb = _curr_sb->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void *Slab::any_used_elem()
|
void *Slab::any_used_elem()
|
||||||
{
|
{
|
||||||
if (_total_avail == _num_blocks*_entries_per_block)
|
if (_total_avail == _num_blocks*_entries_per_block)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user