|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v6 4/5] lib/uksched: use posix_memalign to allocate stack
uk_thread_current indentifies the current stack using STACK_MASK_TOP. As a
consequence the stack should be aligned at STACK_SIZE. However the stack is
allocated using palloc which only guarantees page alignment.
Allocate the stack using posix_memalign, explicitely requesting an
alignment at STACK_SIZE.
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@xxxxxxxxx>
diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c
index 281846d..94ac5aa 100644
--- a/lib/uksched/sched.c
+++ b/lib/uksched/sched.c
@@ -141,7 +141,7 @@ static void *create_stack(struct uk_alloc *allocator)
{
void *stack;
- stack = uk_palloc(allocator, 1ul << STACK_SIZE_PAGE_ORDER);
+ uk_posix_memalign(allocator, &stack, STACK_SIZE, STACK_SIZE);
if (stack == NULL) {
uk_pr_warn("Error allocating thread stack.");
return NULL;
@@ -250,7 +250,7 @@ void uk_sched_thread_destroy(struct uk_sched *sched, struct
uk_thread *thread)
UK_TAILQ_REMOVE(&sched->exited_threads, thread, thread_list);
uk_thread_fini(thread, sched->allocator);
- uk_pfree(sched->allocator, thread->stack, 1ul << STACK_SIZE_PAGE_ORDER);
+ uk_free(sched->allocator, thread->stack);
if (thread->tls)
uk_free(sched->allocator, thread->tls);
uk_free(sched->allocator, thread);
--
2.7.4
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |