aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/uapi/conf.c6
-rw-r--r--common/uapi/ipc.c13
-rw-r--r--include/kmi/conf.h17
3 files changed, 21 insertions, 15 deletions
diff --git a/common/uapi/conf.c b/common/uapi/conf.c
index ba48d0f..ea06e06 100644
--- a/common/uapi/conf.c
+++ b/common/uapi/conf.c
@@ -86,8 +86,8 @@ SYSCALL_DEFINE2(conf_set)(struct tcb *t, sys_arg_t param, sys_arg_t val)
break;
case CONF_CALL_STACK:
- size = align_up(val, RPC_STACK_RATIO * BASE_PAGE_SIZE);
- if (size < __rpc_stack_size * RPC_STACK_RATIO)
+ size = align_up(val, BASE_PAGE_SIZE);
+ if (size < __rpc_stack_size)
return_args(t, SYS_RET1(ERR_MISC));
__call_stack_size = size;
@@ -95,7 +95,7 @@ SYSCALL_DEFINE2(conf_set)(struct tcb *t, sys_arg_t param, sys_arg_t val)
case CONF_RPC_STACK:
size = align_up(val, BASE_PAGE_SIZE);
- if (size > __call_stack_size / RPC_STACK_RATIO)
+ if (size > __call_stack_size)
return_args(t, SYS_RET1(ERR_MISC));
__rpc_stack_size = size;
diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c
index 1d48f71..9cbdce8 100644
--- a/common/uapi/ipc.c
+++ b/common/uapi/ipc.c
@@ -36,6 +36,11 @@ static void mark_rpc_inaccessible(struct tcb *t, vm_t start, vm_t end)
*/
static void mark_rpc_accessible(struct tcb *t, vm_t start, vm_t end)
{
+ /** @todo this could still be optimized with arch-specific stuff I would
+ * imagine, as set_vpage_flags() has to traverse the whole tree for each
+ * page to mark. Instead it should be possible to mark the pages
+ * continuously once they've been traversed once. Or maybe even keep
+ * around a pointer to where the last stack left off? */
size_t page_size = BASE_PAGE_SIZE;
size_t size = end - start;
size_t pages = size / page_size;
@@ -43,7 +48,7 @@ static void mark_rpc_accessible(struct tcb *t, vm_t start, vm_t end)
set_vpage_flags(t->rpc.vmem, start + pages * page_size, VM_U);
}
-/** Structure for maintaingin the required context data for an rpc call. */
+/** Structure for maintaining the required context data for an rpc call. */
struct call_ctx {
/** Execution continuation point. */
vm_t exec;
@@ -189,10 +194,14 @@ static void leave_rpc(struct tcb *t, struct sys_ret a)
*/
static bool enough_rpc_stack(struct tcb *t)
{
+ /* get top of call stack */
vm_t top = RPC_STACK_BASE + __call_stack_size;
+ /* get start of the next rpc stack instance */
vm_t rpc_stack = t->rpc_stack + BASE_PAGE_SIZE;
- return top - rpc_stack >= __call_stack_size / RPC_STACK_RATIO;
+ /* if we can still fit an rpc stack into the call stack, we can safely
+ * do the migration. */
+ return top - rpc_stack >= __rpc_stack_size;
}
/**
diff --git a/include/kmi/conf.h b/include/kmi/conf.h
index 84b9f06..8e33a5f 100644
--- a/include/kmi/conf.h
+++ b/include/kmi/conf.h
@@ -24,6 +24,13 @@ extern size_t __thread_stack_size;
/**
* Provides access to the runtime global parameter.
* Must be at most RPC_STACK_TOP - RPC_STACK_BASE.
+ * Essentially, each thread gets allocated this many bytes of total stack space
+ * that will be used during thread migrations. Each migration instance may at
+ * most take up __rpc_stack_size bytes, and during a thread migration the
+ * currently available free stack space is checked.
+ *
+ * Previous instances are unmapped, making them unaccessible to the current
+ * instance.
*
* \see __thread_stack_size.
* \global
@@ -35,18 +42,8 @@ extern size_t __call_stack_size;
* Provides access to the runtime global parameter. This sets the maximum size
* a single rpc stack instance can be.
*
- * Must be at most a fourth of \ref __call_stack_size?
- * (that way we can maybe pretty quickly check that we're running out of memory
- * for stack stuff and can return an error about it)
- *
* \global
*/
extern size_t __rpc_stack_size;
-/**
- * Convenience macro for requirement of ratio between \ref __rpc_stack_size and
- * \ref __call_stack_size.
- */
-#define RPC_STACK_RATIO 4
-
#endif /* KMI_CONF_H */