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

[Minios-devel] [UNIKRAFT PATCH 14/17] lib/ukschedcoop: Updates for inlining with uksched API changes


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Wed, 4 Apr 2018 16:54:05 +0300
  • Cc: simon.kuenzer@xxxxxxxxx
  • Delivery-date: Wed, 04 Apr 2018 13:54:24 +0000
  • Ironport-phdr: 9a23:SFkopxT4W4nkQp174/A5Xt9FGdpsv+yvbD5Q0YIujvd0So/mwa6yZBKN2/xhgRfzUJnB7Loc0qyK6/umATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfb1/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4qF2QxHqlSgHLSY0/mHJhMJtgqxVoxWvqB5xw4PPfI2ZKOBzcr/HcN8GWWZMWNtaWSxbAoO7aosCF/QMPeFDr4nhplsOqwa1Cw+xBOP31z9Dm3j70rE90+Q6DQHG3QogE8gKsHTJtNX1KbwfXvyuzKXS1TXDcuhZ1S3n6IjPax0sp+yHU7FoccfJ1EUiGB7Jgk+TpIHlJT+ZyPoBvmqB4+duTe6jlmEqpxxrrjWsxsogkJfFi4wbx1ze6Cl0z5g5KNulQ0Bhe9GkCoFftySCOotzRcMtXn9ntT4hyr0DpZ67ZC8KyIk7xxLHa/yIbYyI4hX7WeaPJDd3nnNleLalixmu6kis0PX8VtSv31pQtCpFlcHAtnEL1xPN9siKUuZx80i81TqV1A3e6vtILV4qmafZMZIszKY8lp8JvkTCGi/2ll/2jKiTdkg85ueo7P/nYqnnpp+aLYN0jhz+MrwzmsGkHes4KRICX3CG+eunzrHj50r5TK1QjvIqiqnZrIzaJcMDq668Ag9V1Icj6xGkDzu/zdsXg2cHI0xBeB+ci4jpOkrOIOzjDfuljFWjjjFry+rBPr37DZXHNmLDn6v5fbZh905czxI+zcte55JRDbEBJuj/WkzstNPGCB84MhK7w/z8BdV7yIwRRWaPDbWCP6/Ir1CI+7FnH+7ZYY4TuTHmbvQo+fPqpXs4gkMGO7mk290Qcn/rMO5hJhCyZmHwg9FJNXoSo0JqR+vxlFyEFzpOf2uaVLl6/iwxTpihW9SQDruxiaCMiX/oVqZdYXpLXwiB
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

Changes:
- using new context callbacks abstraction
- idle thread is specific to all schedulers

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 lib/ukschedcoop/schedcoop.c | 45 ++++++++++++++++++++-------------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/lib/ukschedcoop/schedcoop.c b/lib/ukschedcoop/schedcoop.c
index 6201c7b..dd22209 100644
--- a/lib/ukschedcoop/schedcoop.c
+++ b/lib/ukschedcoop/schedcoop.c
@@ -35,7 +35,6 @@
 #include <uk/schedcoop.h>
 
 struct schedcoop_private {
-       struct uk_thread *idle_thread;
        struct uk_thread_list thread_list;
        struct uk_thread_list exited_threads;
        int threads_started;
@@ -56,7 +55,7 @@ static void print_runqueue(struct uk_sched *s)
 
 static void schedcoop_schedule(struct uk_sched *s)
 {
-       struct schedcoop_private *prv = s->private;
+       struct schedcoop_private *prv = s->prv;
        struct uk_thread *prev, *next, *thread, *tmp;
        unsigned long flags;
 
@@ -122,7 +121,7 @@ static void schedcoop_schedule(struct uk_sched *s)
         * interrupted at the return instruction. And therefore at safe point.
         */
        if (prev != next)
-               uk_thread_switch(prev, next);
+               uk_sched_thread_switch(s, prev, next);
 
        UK_TAILQ_FOREACH_SAFE(thread, &prv->exited_threads, thread_list, tmp) {
                if (thread != prev) {
@@ -133,10 +132,10 @@ static void schedcoop_schedule(struct uk_sched *s)
        }
 }
 
-static void schedcoop_thread_start(struct uk_sched *s, struct uk_thread *t)
+static void schedcoop_thread_add(struct uk_sched *s, struct uk_thread *t)
 {
        unsigned long flags;
-       struct schedcoop_private *prv = s->private;
+       struct schedcoop_private *prv = s->prv;
 
        set_runnable(t);
 
@@ -145,10 +144,10 @@ static void schedcoop_thread_start(struct uk_sched *s, 
struct uk_thread *t)
        ukplat_lcpu_restore_irqf(flags);
 }
 
-static void schedcoop_thread_stop(struct uk_sched *s, struct uk_thread *t)
+static void schedcoop_thread_remove(struct uk_sched *s, struct uk_thread *t)
 {
        unsigned long flags;
-       struct schedcoop_private *prv = s->private;
+       struct schedcoop_private *prv = s->prv;
 
        flags = ukplat_lcpu_save_irqf();
 
@@ -172,24 +171,20 @@ static void idle_thread_fn(void *unused __unused)
 {
        struct uk_thread *current = uk_thread_current();
        struct uk_sched *s = current->sched;
-       struct schedcoop_private *prv = s->private;
-
-       UK_ASSERT(current == prv->idle_thread);
+       struct schedcoop_private *prv = s->prv;
 
        prv->threads_started = 1;
+       ukplat_lcpu_enable_irq();
+
        while (1) {
                uk_thread_block(current);
-               uk_sched_schedule(s);
+               schedcoop_schedule(s);
        }
 }
 
-static void schedcoop_run(struct uk_sched *s) __noreturn;
-static void schedcoop_run(struct uk_sched *s)
+static void schedcoop_yield(struct uk_sched *s)
 {
-       struct schedcoop_private *prv = s->private;
-       struct uk_thread *idle_thread = prv->idle_thread;
-
-       ukplat_thread_ctx_run_idle(&idle_thread->plat_ctx);
+       schedcoop_schedule(s);
 }
 
 struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
@@ -207,6 +202,8 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
 
        sched->allocator = a;
 
+       ukplat_ctx_callbacks_init(&sched->plat_ctx_cbs, ukplat_ctx_sw);
+
        prv = uk_malloc(a, sizeof(struct schedcoop_private));
        if (prv == NULL) {
                uk_printd(DLVL_WARN,
@@ -217,16 +214,14 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
        UK_TAILQ_INIT(&prv->exited_threads);
        UK_TAILQ_INIT(&prv->thread_list);
        prv->threads_started = 0;
-       sched->private = prv;
-
-       uk_sched_init(sched, schedcoop_schedule, schedcoop_run,
-                       schedcoop_thread_start, schedcoop_thread_stop);
+       sched->prv = prv;
 
-       prv->idle_thread = uk_thread_create("Idle", idle_thread_fn, NULL);
-       if (prv->idle_thread == NULL)
-               goto out_err;
+       uk_sched_idle_init(sched, NULL, idle_thread_fn);
 
-       uk_thread_start(prv->idle_thread);
+       uk_sched_init(sched,
+                       schedcoop_yield,
+                       schedcoop_thread_add,
+                       schedcoop_thread_remove);
 
        return sched;
 
-- 
2.1.4


_______________________________________________
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®.