foc: use slab for meta-data in RPC cap factory

This commit is contained in:
Christian Helmuth 2017-06-15 15:20:19 +02:00
parent d6e41ae7e3
commit ba9ef7fdee
3 changed files with 24 additions and 9 deletions

View File

@ -16,9 +16,14 @@
/* Genode includes */
#include <base/rpc_server.h>
#include <base/allocator.h>
#include <base/heap.h>
#include <base/tslab.h>
#include <base/object_pool.h>
/* base-internal includes */
#include <base/internal/page_size.h>
namespace Genode { class Rpc_cap_factory; }
class Genode::Rpc_cap_factory
@ -31,11 +36,22 @@ class Genode::Rpc_cap_factory
};
Object_pool<Entry> _pool;
Allocator &_md_alloc;
/*
* Dimension '_entry_slab' such that slab blocks (including the
* meta-data overhead of the sliced-heap blocks) are page sized.
*/
static constexpr size_t SLAB_BLOCK_SIZE =
get_page_size() - Sliced_heap::meta_data_size();
uint8_t _initial_sb[SLAB_BLOCK_SIZE];
Tslab<Entry, SLAB_BLOCK_SIZE> _entry_slab;
public:
Rpc_cap_factory(Allocator &md_alloc) : _md_alloc(md_alloc) { }
Rpc_cap_factory(Allocator &md_alloc)
: _entry_slab(md_alloc, _initial_sb) { }
~Rpc_cap_factory();

View File

@ -144,7 +144,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
* so this is not an issue.
*/
if (cap.valid())
_pool.insert(new (_md_alloc) Entry(cap));
_pool.insert(new (_entry_slab) Entry(cap));
return cap;
}
@ -167,7 +167,7 @@ void Rpc_cap_factory::free(Native_capability cap)
} else
warning("Could not find capability to be deleted");
});
if (entry) destroy(_md_alloc, entry);
if (entry) destroy(_entry_slab, entry);
}
@ -175,7 +175,7 @@ Rpc_cap_factory::~Rpc_cap_factory()
{
_pool.remove_all([this] (Entry *e) {
if (!e) return;
destroy(_md_alloc, e);
destroy(_entry_slab, e);
});
}

View File

@ -26,12 +26,11 @@ install_config {
<default-route>
<any-service><parent/><any-child/></any-service>
</default-route>
<default caps="1000"/>
<start name="timer">
<start name="timer" caps="60">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="client">
<start name="client" caps="300">
<binary name="test-timer"/>
<resource name="RAM" quantum="10M"/>
</start>