base-hw: upgrade cap-space slab less eagerly

This patch upgrades the cap-space slab only if the kernel runs out of
entries, instead of consuming as much PD-session quota as possible.
Until now, the behavior worked well because the cap-space slab was the
only consumer of PD-session quota. However, once we start accounting all
PD session meta data - and eventually merging the PD and RAM services -
the aggressive scheme stands in the way.

Issue #2398
This commit is contained in:
Norman Feske 2017-05-08 11:25:11 +02:00 committed by Christian Helmuth
parent 5b1e3466be
commit 82a98065a0
1 changed files with 6 additions and 9 deletions

View File

@ -115,17 +115,14 @@ Cap_space::Cap_space() : _slab(nullptr, &_initial_sb) { }
void Cap_space::upgrade_slab(Allocator &alloc)
{
for (;;) {
void *block = nullptr;
enum { NEEDED_AVAIL_ENTRIES_FOR_SUCCESSFUL_SYSCALL = 8 };
/*
* On every upgrade we try allocating as many blocks as possible.
* If the underlying allocator complains that its quota is exceeded
* this is normal as we use it as indication when to exit the loop.
*/
if (!alloc.alloc(SLAB_SIZE, &block)) return;
if (_slab.avail_entries() > NEEDED_AVAIL_ENTRIES_FOR_SUCCESSFUL_SYSCALL)
return;
void *block = nullptr;
if (alloc.alloc(SLAB_SIZE, &block))
_slab.insert_sb(block);
}
}