diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-06 22:08:50 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-06 22:08:50 +0300 |
| commit | 3528f88fc36df6964c0efed784ae223cfe93544e (patch) | |
| tree | 6e672c76fb4c899d5e454f724adfd4bae8182e31 /src/uapi/conf.c | |
| parent | 70afa4184544d244d804713fdee5836f4f20a9fe (diff) | |
| download | kmi-3528f88fc36df6964c0efed784ae223cfe93544e.tar.gz kmi-3528f88fc36df6964c0efed784ae223cfe93544e.zip | |
add RAM usage counting
+ Slightly more overhead but will help track down possible memory leaks
in the future. Could also add in a flag for turning off/on but I don't
think the difference in performance is that significant.
Diffstat (limited to 'src/uapi/conf.c')
| -rw-r--r-- | src/uapi/conf.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/uapi/conf.c b/src/uapi/conf.c index 685d294..be9abfc 100644 --- a/src/uapi/conf.c +++ b/src/uapi/conf.c @@ -21,12 +21,6 @@ size_t __thread_stack_size = SZ_2M; size_t __rpc_stack_size = SZ_512K; -/** IDs for configuration parameters. */ -/** @todo should probably be moved somewhere so it can be shared with userspace */ -enum conf_param { - CONF_THREAD_STACK = 0, - CONF_RPC_STACK, -}; /** * Configuration parameter read syscall handler. @@ -39,9 +33,8 @@ enum conf_param { */ SYSCALL_DEFINE1(conf_get)(struct tcb *t, sys_arg_t param) { - if (!has_cap(t->caps, CAP_CONF)) - return_args1(t, ERR_PERM); - + /* anyone can read any current parameter, I don't think they should be + * hidden. */ long val = 0; switch (param) { case CONF_THREAD_STACK: @@ -52,6 +45,14 @@ SYSCALL_DEFINE1(conf_get)(struct tcb *t, sys_arg_t param) val = __rpc_stack_size; break; + case CONF_RAM_USAGE: + val = query_used(); + break; + + case CONF_RAM_SIZE: + val = get_ram_size(); + break; + default: return_args1(t, ERR_NF); } @@ -87,6 +88,9 @@ SYSCALL_DEFINE2(conf_set)(struct tcb *t, sys_arg_t param, sys_arg_t val) __rpc_stack_size = size; break; + + default: + return_args1(t, ERR_INVAL); } return_args1(t, OK); |
