diff --git a/dde_rump/include/util/allocator_fap.h b/dde_rump/include/util/allocator_fap.h index 3d8e9a327..b19c071b2 100644 --- a/dde_rump/include/util/allocator_fap.h +++ b/dde_rump/include/util/allocator_fap.h @@ -88,11 +88,11 @@ namespace Allocator { /* lookup phys. address */ _ds_phys[_index] = Genode::Dataspace_client(_ds_cap[_index]).phys_addr(); } catch (Genode::Ram_session::Quota_exceeded) { - PERR("Backend allocator exhausted"); + PWRN("Backend allocator exhausted"); _quota_exceeded = true; return false; } catch (Genode::Rm_session::Attach_failed) { - PERR("Backend VM region exhausted"); + PWRN("Backend VM region exhausted"); _quota_exceeded = true; return false; } @@ -116,7 +116,7 @@ namespace Allocator { } /** - * Allocate + * Allocate */ bool alloc(size_t size, void **out_addr) { @@ -126,10 +126,8 @@ namespace Allocator { return done; done = _alloc_block(); - if (!done) { - PERR("Backend allocator exhausted\n"); + if (!done) return false; - } return _range.alloc(size, out_addr); } diff --git a/dde_rump/include/util/hard_context.h b/dde_rump/include/util/hard_context.h index 374fcd6e3..e31f2c472 100644 --- a/dde_rump/include/util/hard_context.h +++ b/dde_rump/include/util/hard_context.h @@ -33,14 +33,33 @@ namespace Timer { class Connection; }; -class Hard_context : public Genode::Thread + +class Hard_context { private: - func _func; - void *_arg; - int _cookie; - lwp *_lwp; + int _cookie; + lwp *_lwp = 0; + + public: + + Hard_context(int cookie) + : _cookie(cookie){ } + + void set_lwp(lwp *l) { _lwp = l; } + lwp *get_lwp() { return _lwp; } + + static Timer::Connection *timer(); +}; + + +class Hard_context_thread : public Hard_context, + public Genode::Thread +{ + private: + + func _func; + void *_arg; protected: @@ -52,14 +71,10 @@ class Hard_context : public Genode::Thread public: - Hard_context(char const *name, func f, void *arg, int cookie, bool run = true) - : Thread(name), - _func(f), _arg(arg), _cookie(cookie), _lwp(0) { if (run) start(); } - - void set_lwp(lwp *l) { _lwp = l; } - lwp *get_lwp() { return _lwp; } - - static Timer::Connection *timer(); + Hard_context_thread(char const *name, func f, void *arg, int cookie, bool run = true) + : Hard_context(cookie), Thread(name), + _func(f), _arg(arg) { if (run) start(); } }; + #endif /* _INCLUDE__HARD_CONTEXT_H_ */ diff --git a/dde_rump/src/lib/rump/hypercall.cc b/dde_rump/src/lib/rump/hypercall.cc index 617ae9cba..a75de708a 100644 --- a/dde_rump/src/lib/rump/hypercall.cc +++ b/dde_rump/src/lib/rump/hypercall.cc @@ -61,7 +61,7 @@ int rumpuser_init(int version, const struct rumpuser_hyperup *hyp) ** Threads ** *************/ -static Hard_context _main_thread("main thread", 0, 0, 0, false); +static Hard_context _main_thread(0); static Hard_context *myself() { @@ -108,7 +108,7 @@ int rumpuser_thread_create(func f, void *arg, const char *name, if (mustjoin) *cookie = (void *)++count; - new (Genode::env()->heap()) Hard_context(name, f, arg, mustjoin ? count : 0); + new (Genode::env()->heap()) Hard_context_thread(name, f, arg, mustjoin ? count : 0); return 0; } @@ -123,6 +123,8 @@ void rumpuser_seterrno(int e) { errno = e; } int rumpuser_getparam(const char *name, void *buf, size_t buflen) { + enum { RESERVE_MEM = 2U * 1024 * 1024 }; + /* support one cpu */ PDBG("%s", name); if (!Genode::strcmp(name, "_RUMPUSER_NCPU")) { @@ -139,11 +141,18 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen) if (!Genode::strcmp(name, "RUMP_MEMLIMIT")) { /* leave 2 MB for the Genode */ - size_t rump_ram = Genode::env()->ram_session()->avail() - (2 * 1024 * 1024); + size_t rump_ram = Genode::env()->ram_session()->avail(); + + if (rump_ram <= RESERVE_MEM) { + PERR("Insufficient quota need left: %zu < %u bytes", rump_ram, RESERVE_MEM); + return -1; + } + + rump_ram -= RESERVE_MEM; /* convert to string */ Genode::snprintf((char *)buf, buflen, "%zu", rump_ram); - PINF("Asserting rump kernel %zu KB of RAM", rump_ram / 1024); + PERR("Asserting rump kernel %zu KB of RAM", rump_ram / 1024); return 0; } diff --git a/dde_rump/src/lib/rump/io.cc b/dde_rump/src/lib/rump/io.cc index 27c59a6a5..737608280 100644 --- a/dde_rump/src/lib/rump/io.cc +++ b/dde_rump/src/lib/rump/io.cc @@ -39,7 +39,7 @@ struct Packet : Genode::List::Element }; -class Backend : public Hard_context +class Backend : public Hard_context_thread { private: @@ -211,7 +211,7 @@ class Backend : public Hard_context public: Backend() - : Hard_context("block_io", 0, 0, 0, false), + : Hard_context_thread("block_io", 0, 0, 0, false), _alloc(Genode::env()->heap()), _session(&_alloc), _alloc_sem(COUNT), diff --git a/dde_rump/src/server/rump_fs/main.cc b/dde_rump/src/server/rump_fs/main.cc index 65bd63314..4e30e74e7 100644 --- a/dde_rump/src/server/rump_fs/main.cc +++ b/dde_rump/src/server/rump_fs/main.cc @@ -426,7 +426,8 @@ class File_system::Root : public Root_component struct File_system::Main { - Server::Entrypoint &ep; + Server::Entrypoint &ep; + Server::Signal_rpc_member
resource_dispatcher; /* * Initialize root interface @@ -436,12 +437,17 @@ struct File_system::Main Root fs_root = { ep, sliced_heap }; + /* return immediately from resource requests */ + void resource_handler(unsigned) { } + Main(Server::Entrypoint &ep) : - ep(ep) + ep(ep), + resource_dispatcher(ep, *this, &Main::resource_handler) { File_system::init(ep); env()->parent()->announce(ep.manage(fs_root)); + env()->parent()->resource_avail_sigh(resource_dispatcher); } };