[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: Tue, 27 Mar 2018 15:29:47 +0300
  • Cc: simon.kuenzer@xxxxxxxxx
  • Delivery-date: Tue, 27 Mar 2018 12:30:13 +0000
  • Ironport-phdr: 9a23:+QEPqBeVKDWZyUCM1X8aFJPKlGMj4u6mDksu8pMizoh2WeGdxcS6Yh7h7PlgxGXEQZ/co6odzbaO6Oa4ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTahb75+Ngm6oRnMvcQKnIVuLbo8xAHUqXVSYeRWwm1oJVOXnxni48q74YBu/SdNtf8/7sBMSar1cbg2QrxeFzQmLns65Nb3uhnZTAuA/WUTX2MLmRdVGQfF7RX6XpDssivms+d2xSeXMdHqQb0yRD+v6bpgRh31hycdLzM38H/ZhNF+gqxYpxyupRJ/zpXIbI2JLvdyYrnQcc8GSWdHQ81fVzZBAoS5b4YXEecBOv1Yr5X8p1sIsBCwAxSsBPvyyjRVgXL5wao60/89EQHH2gwsBdYOsGnMrNXoL6odTfu1wLPQzTXedPxawy396I/Rfx0nvPqCXqpwfNLMxUQgCg/JlFadpIz/Mz+LyOgAsXKX4uR4We6yhGMrtht9rzuvy8s2lIXEiIwYxkrZ+Sh23oo4I8CzRlRhbt6+CpRQsjmXN45xQsw/XW5loD06yrgauZ6jeygK1Ygnywbfa/OZd4iI5QruVPiUIThihXJlfKiziAqp8US60u38S9K73ExQripCitXMt3YN2ALP6sWfV/dw8Vqt1SyM2g3T8O1IP144mKjBJ5Mv2rIwk4AcsUXHHi/4gkX2i6qWe1049eiv8OTnfrTmppmGO49wlwH+Krkul9ejDuQjKAQOR3Wb9v+m2L35+k31WK9KgeEukqnFrJDaItwWpqu4Aw9T04Yj7A2/Ay6739sGg3kIMlZFdQmDj4joIFHOPOv4Ae2wgluyljdn3ffGPqfuAp/VNHjMjK/hfaph605b0Acz1tFf55dTCrEHOv7zWVLxu8LeDh44LQO02f3qCNNj2YwCXWKAGLSWPLnMvl+VtaoTJLyJZYkUvy24J/U76vrGiX4ihURbbaSvm5wNZyOWBPNjdm6eembthJ8lDH8X9l41S/f2iVvEVSNLel65ROQk+zt9EoXwXtSLfZyknLHUhHTzJZZRfG0TUl0=
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

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