mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
core-linux: make RAM quota configurable
Add the option to configure the RAM quota for core on base-linux. The environment variable GENODE_RAM_QUOTA if it exists is interpreted as number of bytes to provide to the first init. Issue #3762
This commit is contained in:
parent
51104454aa
commit
7f6b6d7e13
@ -24,6 +24,29 @@
|
|||||||
#include <synced_range_allocator.h>
|
#include <synced_range_allocator.h>
|
||||||
#include <assertion.h>
|
#include <assertion.h>
|
||||||
|
|
||||||
|
#include <util/arg_string.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of Unix environment variables, initialized by the startup code
|
||||||
|
*/
|
||||||
|
extern char **lx_environ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read environment variable as long value
|
||||||
|
*/
|
||||||
|
static unsigned long ram_quota_from_env()
|
||||||
|
{
|
||||||
|
for (char **curr = lx_environ; curr && *curr; curr++) {
|
||||||
|
|
||||||
|
Genode::Arg arg = Genode::Arg_string::find_arg(*curr, "GENODE_RAM_QUOTA");
|
||||||
|
if (arg.valid())
|
||||||
|
return arg.ulong_value(~0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ~0;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
@ -87,7 +110,7 @@ namespace Genode {
|
|||||||
int remove_range(addr_t, size_t) override { return 0; }
|
int remove_range(addr_t, size_t) override { return 0; }
|
||||||
void free(void *) override { }
|
void free(void *) override { }
|
||||||
void free(void *, size_t) override { }
|
void free(void *, size_t) override { }
|
||||||
size_t avail() const override { return ~0; }
|
size_t avail() const override { return ram_quota_from_env(); }
|
||||||
bool valid_addr(addr_t) const override { return true; }
|
bool valid_addr(addr_t) const override { return true; }
|
||||||
size_t overhead(size_t) const override { return 0; }
|
size_t overhead(size_t) const override { return 0; }
|
||||||
bool need_size_for_free() const override { return true; }
|
bool need_size_for_free() const override { return true; }
|
||||||
|
Loading…
Reference in New Issue
Block a user