[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v6 4/5] lib/uksched: use posix_memalign to allocate stack



On 23.01.20 16:30, Hugo Lefeuvre wrote:
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.

There is a typo in the message: "explicitly", I am can fix it while upstreaming. Thanks!

Reviewed-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>


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);


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.