scalable sandbox creation in each runtime core

main
phani 5 years ago
parent 576bc4b086
commit 69b1f94fe8

@ -16,6 +16,7 @@ CFLAGS += -D_GNU_SOURCE
#CFLAGS += -DNOSTDIO
#CFLAGS += -DSTANDALONE
CFLAGS += -DUSE_UVIO
CFLAGS += -DSBOX_SCALE_ALLOC
#CFLAGS += -DUSE_SYSCALL
#CFLAGS += -DPREEMPT_DISABLE
CACHE_LINESIZE := $(shell getconf LEVEL1_DCACHE_LINESIZE)

@ -77,6 +77,7 @@ struct sandbox {
} PAGE_ALIGNED;
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
struct sandbox_request {
struct module *mod;
char *args;
@ -87,6 +88,9 @@ typedef struct sandbox_request sbox_request_t;
#else
typedef struct sandbox sbox_request_t;
#endif
#else
typedef struct sandbox sbox_request_t;
#endif
DEQUE_PROTOTYPE(sandbox, sbox_request_t *);
@ -106,6 +110,7 @@ static inline sbox_request_t *
sbox_request_alloc(struct module *mod, char *args, int sock, const struct sockaddr *addr)
{
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
sbox_request_t *s = malloc(sizeof(sbox_request_t));
assert(s);
s->mod = mod;
@ -117,6 +122,9 @@ sbox_request_alloc(struct module *mod, char *args, int sock, const struct sockad
#else
return sandbox_alloc(mod, args, sock, addr);
#endif
#else
return sandbox_alloc(mod, args, sock, addr);
#endif
}
static inline struct sandbox *

@ -48,11 +48,16 @@ sandbox_pull(void)
if (!s) break;
#ifndef STANDALONE
#ifdef SBOX_SCALE_ALLOC
struct sandbox *sb = sandbox_alloc(s->mod, s->args, s->sock, s->addr);
assert(sb);
free(s);
sb->state = SANDBOX_RUNNABLE;
sandbox_local_run(sb);
#else
assert(s->state == SANDBOX_RUNNABLE);
sandbox_local_run(s);
#endif
#else
assert(s->state == SANDBOX_RUNNABLE);
sandbox_local_run(s);
@ -223,7 +228,9 @@ sandbox_run(sbox_request_t *s)
// sandbox_run adds to the global ready queue..
// each sandboxing thread pulls off of that global ready queue..
debuglog("[%p: %s]\n", s, s->mod->name);
// s->state = SANDBOX_RUNNABLE;
#ifndef SBOX_SCALE_ALLOC
s->state = SANDBOX_RUNNABLE;
#endif
sandbox_deque_push(s);
#else
sandbox_switch(s);

@ -314,6 +314,10 @@ sandbox_alloc(struct module *mod, char *args, int sock, const struct sockaddr *a
arch_context_init(&sb->ctxt, (reg_t)sandbox_entry, (reg_t)(sb->stack_start + sb->stack_size));
#ifdef STANDALONE
sandbox_run(sb);
#else
#ifndef SBOX_SCALE_ALLOC
sandbox_run(sb);
#endif
#endif
return sb;

Loading…
Cancel
Save