chore: alignment debugging

master
Sean McBride 3 years ago
parent 38532dec63
commit c1dcc7b176

@ -121,7 +121,8 @@
"stdint.h": "c",
"scheduler_options.h": "c",
"route_config_parse.h": "c",
"route.h": "c"
"route.h": "c",
"pool.h": "c"
},
"files.exclude": {
"**/.git": true,

@ -43,10 +43,6 @@ http_router_add_route(struct http_router *router, struct route_config *config, s
.response_content_type = config->http_resp_content_type
};
/* Move strings from config */
config->route = NULL;
config->http_resp_content_type = NULL;
/* Admissions Control */
uint64_t expected_execution = (uint64_t)config->expected_execution_us * runtime_processor_speed_MHz;
admissions_info_initialize(&router->routes[router->routes_length].admissions_info,

@ -42,7 +42,7 @@ struct module {
struct sledge_abi__wasm_table *indirect_table;
struct module_pools pools[MAX_WORKER_THREADS];
};
} __attribute__((aligned(CACHE_PAD)));
/********************************
* Public Methods from module.c *

@ -32,9 +32,12 @@ struct route_config {
static inline void
route_config_deinit(struct route_config *config)
{
free(config->path);
free(config->route);
free(config->http_resp_content_type);
/* ownership of the route and http_resp_content_type strings was moved during http_router_add_route */
assert(config->route == NULL);
assert(config->http_resp_content_type == NULL);
/* ownership of the path stringswas moved during module_alloc */
assert(config->path == NULL);
}
static inline void

@ -39,10 +39,16 @@ tenant_alloc(struct tenant_config *config)
module_database_init(&tenant->module_db);
for (int i = 0; i < config->routes_len; i++) {
/* Resolve module */
struct module *module = module_database_find_by_path(&tenant->module_db, config->routes[i].path);
/* Resolve module, Ownership of path moves here */
struct module *module = module_database_find_by_path(&tenant->module_db, config->routes[i].path);
config->routes[i].path = NULL;
assert(module != NULL);
/* Ownership of config's route and http_resp_content_type move here */
http_router_add_route(&tenant->router, &config->routes[i], module);
config->routes[i].route = NULL;
config->routes[i].http_resp_content_type = NULL;
}
return tenant;

@ -11,12 +11,16 @@
#define CACHE_PAD (CACHE_LINE * 2)
/* For this family of macros, do NOT pass zero as the pow2 */
#define round_to_pow2(x, pow2) (((unsigned long)(x)) & (~((pow2)-1)))
#define round_up_to_pow2(x, pow2) (round_to_pow2(((unsigned long)(x)) + (pow2)-1, (pow2)))
#define round_to_pow2(x, pow2) (((unsigned long)(x)) & (~(((unsigned long)(pow2)) - 1)))
#define round_up_to_pow2(x, pow2) \
(round_to_pow2(((unsigned long)(x)) + ((unsigned long)(pow2)) - 1, (unsigned long)((pow2))))
#define round_to_page(x) round_to_pow2(x, PAGE_SIZE)
#define round_up_to_page(x) round_up_to_pow2(x, PAGE_SIZE)
#define round_to_cache_pad(x) round_to_pow2((unsigned long)(x), CACHE_PAD)
#define round_up_to_cache_pad(x) round_up_to_pow2((unsigned long)(x), CACHE_PAD)
#define EXPORT __attribute__((visibility("default")))
#define IMPORT __attribute__((visibility("default")))
#define INLINE __attribute__((always_inline))

@ -56,7 +56,7 @@ static INLINE void wasm_memory_set_f64(struct wasm_memory *wasm_memory, uint3
static INLINE struct wasm_memory *
wasm_memory_alloc(uint64_t initial, uint64_t max)
{
struct wasm_memory *wasm_memory = aligned_alloc(4096, sizeof(struct wasm_memory));
struct wasm_memory *wasm_memory = aligned_alloc(4096, round_up_to_page(sizeof(struct wasm_memory)));
if (wasm_memory == NULL) return wasm_memory;
int rc = wasm_memory_init(wasm_memory, initial, max);

@ -120,10 +120,9 @@ wasm_stack_reinit(struct wasm_stack *wasm_stack)
{
assert(wasm_stack != NULL);
assert(wasm_stack->buffer != NULL);
wasm_stack->low = wasm_stack->buffer + /* guard page */ PAGE_SIZE;
assert(wasm_stack->low == wasm_stack->buffer + /* guard page */ PAGE_SIZE);
assert(wasm_stack->high == wasm_stack->low + wasm_stack->capacity);
memset(wasm_stack->low, 0, wasm_stack->capacity);
ps_list_init_d(wasm_stack);
wasm_stack->high = wasm_stack->low + wasm_stack->capacity;
}

@ -3,7 +3,7 @@
#include "local_completion_queue.h"
#include "sandbox_functions.h"
thread_local static struct ps_list_head local_completion_queue;
thread_local static struct ps_list_head local_completion_queue __attribute__((aligned(16)));
void

@ -94,14 +94,19 @@ module_free(struct module *module)
*/
struct module *
module_alloc(char *path)
module_alloc(IN char *path)
{
struct module *module = (struct module *)calloc(1, sizeof(struct module));
size_t alignment = (size_t)CACHE_PAD;
size_t size_to_alloc = (size_t)round_to_cache_pad(sizeof(struct module));
struct module *module = aligned_alloc(alignment, size_to_alloc);
if (!module) {
fprintf(stderr, "Failed to allocate module: %s\n", strerror(errno));
goto err;
};
memset(module, 0, size_to_alloc);
int rc = module_init(module, path);
if (rc < 0) goto init_err;
@ -109,6 +114,7 @@ done:
return module;
init_err:
free(path);
free(module);
err:
module = NULL;

@ -12,6 +12,9 @@ run:
debug:
SLEDGE_DISABLE_PREEMPTION=true SLEDGE_NWORKERS=1 LD_LIBRARY_PATH=${SLEDGE_BINARY_DIR} gdb ${SLEDGE_BINARY_DIR}/sledgert --eval-command="run spec.json"
valgrind:
SLEDGE_DISABLE_PREEMPTION=true SLEDGE_NWORKERS=1 LD_LIBRARY_PATH=${SLEDGE_BINARY_DIR} valgrind --leak-check=full --max-stackframe=11150456 --run-libc-freeres=no --run-cxx-freeres=no ${SLEDGE_BINARY_DIR}/sledgert spec.json
client:
curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary "@hyde.pnm" "${HOSTNAME}:10000/gocr"

Loading…
Cancel
Save