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 += -DNOSTDIO
#CFLAGS += -DSTANDALONE #CFLAGS += -DSTANDALONE
CFLAGS += -DUSE_UVIO CFLAGS += -DUSE_UVIO
CFLAGS += -DSBOX_SCALE_ALLOC
#CFLAGS += -DUSE_SYSCALL #CFLAGS += -DUSE_SYSCALL
#CFLAGS += -DPREEMPT_DISABLE #CFLAGS += -DPREEMPT_DISABLE
CACHE_LINESIZE := $(shell getconf LEVEL1_DCACHE_LINESIZE) CACHE_LINESIZE := $(shell getconf LEVEL1_DCACHE_LINESIZE)

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

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

Loading…
Cancel
Save