From 82a98065a015c63bf07d74378104c40160b936c3 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 8 May 2017 11:25:11 +0200 Subject: [PATCH] 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 --- repos/base-hw/src/core/platform_pd.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/repos/base-hw/src/core/platform_pd.cc b/repos/base-hw/src/core/platform_pd.cc index 0da0e87af..930511357 100644 --- a/repos/base-hw/src/core/platform_pd.cc +++ b/repos/base-hw/src/core/platform_pd.cc @@ -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); - } }