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

[Minios-devel] [UNIKRAFT PATCH v3 02/12] lib/uksched: Add function for allocating scheduler common info


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Sun, 10 Mar 2019 22:09:55 +0200
  • Cc: Florian.Schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx, sharan.santhanam@xxxxxxxxx
  • Delivery-date: Sun, 10 Mar 2019 20:10:18 +0000
  • Ironport-phdr: 9a23:GNVhmBIJ1/CIgQkt3NmcpTZWNBhigK39O0sv0rFitYgXKvz5rarrMEGX3/hxlliBBdydt6sczbKP+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhUiDanfb9+MQi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkHKTA37W/ZhM93gq1ZrhKsvABzz5LObY2JLvdyYr/RcNUHTmRBRMZRUClBD5uiYosIFOoBIedYr4/grFUIsBu+HRSsD/7oxzBUgX/2xrE60+UnEQ3c2AwgAsoOsGnPodrpL6ceS/i1zLTTwjnZdfNW3i7w5Y7VeR4iufGBRa98fMXMxUU1FA7Ijk+cpZL7Mz6XzOgAvXCX4/dvWO6ykWIqqAF8riKxysoihITFnJ8Zx1/a+Sh/3Y07P8e3SFRhbt6hCJZQsiaaOJZoTc46WGFovTo6yqUBuZ6mYCgG0JQnyADba/yAa4WI/BfjW/yQITd8nn5qZKm/iwyq8Ui90eLwTNO00FFSoipElNnDqGwN2gTO5sWIV/dx5ESs1DaV2wzN9O1JI1o4mKTDJ54k2LEwl54TsUrZHi/xnUX7lLOZdkI/+ui06uTnZK/qppuBN49slwHzKbghmtelDeQgLwgBRHKX+f671LH75032XK1KjuEqkqneqJ3aIMUbpqi4Aw9SyYYv8guwACm40NsGmXkKN1ZFeBOcj4j1IFHCOv/5Aum5g1i2lzdr3f/GNKX7AprRNnjDjKvhfbFl5kBczAozyspf55NOBbEHOv79R1P+tNzdDh84LgO03/3qCNNj2YwCXWKAGLSWPLnMvl+V/ugvOfWDZJcJuDbhLPgo/+XujX8jll8HZ6ap24EbaGuiEfRgP0WZYWDjgtEbHmcPpQc+SvLlh0GGUTFJfHm+Rbwz5iwjAoK8EYjDXpytgKCG3CqjBZ1WZ2VGCleKEXvydIWERukDaCSTI8B/iDwJTr6hRJE92hGqrgD10KBrIfTJ+icAr5LsyMB15/HPlRE17TF1D9md03uMT21ugGMIQDs207x/oUx+zVeDz7N1g/pGGtNP4/NGSBw1OYTCwOxnWJjOXVfEf9GIT03jTti4DDUZStMq38RIc0t7XdK4gUPtxS2vVpQSjKCKAtQQ77rBlyz6IN1hynCA0LQ5knEtWY1XKGfgnKkppFubPJLAj0jMz/XiTq8bxiOYrGo=
  • Ironport-sdr: Tss9wolsJ9aWExoXC7Gw9cOX2pDzq5BEuBsO4fr6Dl94wY+51+HjAxjxnasSP9heLskAqNPaFS or4+xZPqqE9w==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

We introduce uk_sched_create function which allocates the memory
needed for schedulers data. It also initializes data that is
common to all schedulers.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 lib/uksched/exportsyms.uk      |  1 +
 lib/uksched/include/uk/sched.h |  2 ++
 lib/uksched/sched.c            | 18 ++++++++++++++++++
 lib/ukschedcoop/schedcoop.c    | 26 ++++----------------------
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/lib/uksched/exportsyms.uk b/lib/uksched/exportsyms.uk
index 9dc133ca..45a9694a 100644
--- a/lib/uksched/exportsyms.uk
+++ b/lib/uksched/exportsyms.uk
@@ -2,6 +2,7 @@ uk_sched_default_init
 uk_sched_register
 uk_sched_get_default
 uk_sched_set_default
+uk_sched_create
 uk_sched_start
 uk_sched_idle_init
 uk_sched_thread_create
diff --git a/lib/uksched/include/uk/sched.h b/lib/uksched/include/uk/sched.h
index bbfe4423..d2fc8df3 100644
--- a/lib/uksched/include/uk/sched.h
+++ b/lib/uksched/include/uk/sched.h
@@ -114,6 +114,8 @@ static inline void uk_sched_thread_remove(struct uk_sched 
*s,
  * Internal scheduler functions
  */
 
+struct uk_sched *uk_sched_create(struct uk_alloc *a, size_t prv_size);
+
 void uk_sched_idle_init(struct uk_sched *sched,
                void *stack, void (*function)(void *));
 
diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c
index 12780ec8..c3be2060 100644
--- a/lib/uksched/sched.c
+++ b/lib/uksched/sched.c
@@ -109,6 +109,24 @@ int uk_sched_set_default(struct uk_sched *s)
        return 0;
 }
 
+struct uk_sched *uk_sched_create(struct uk_alloc *a, size_t prv_size)
+{
+       struct uk_sched *sched = NULL;
+
+       UK_ASSERT(a != NULL);
+
+       sched = uk_malloc(a, sizeof(struct uk_sched) + prv_size);
+       if (sched == NULL) {
+               uk_pr_warn("Could not allocate scheduler.");
+               return NULL;
+       }
+
+       sched->allocator = a;
+       sched->prv = (void *) sched + sizeof(struct uk_sched);
+
+       return sched;
+}
+
 void uk_sched_start(struct uk_sched *sched)
 {
        UK_ASSERT(sched != NULL);
diff --git a/lib/ukschedcoop/schedcoop.c b/lib/ukschedcoop/schedcoop.c
index 6f51eceb..3e3a92f5 100644
--- a/lib/ukschedcoop/schedcoop.c
+++ b/lib/ukschedcoop/schedcoop.c
@@ -194,26 +194,16 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
 
        uk_pr_info("Initializing cooperative scheduler\n");
 
-       sched = uk_malloc(a, sizeof(struct uk_sched));
-       if (sched == NULL) {
-               uk_pr_warn("Could not allocate memory for scheduler.\n");
-               goto out_err;
-       }
-
-       sched->allocator = a;
+       sched = uk_sched_create(a, sizeof(struct schedcoop_private));
+       if (sched == NULL)
+               return NULL;
 
        ukplat_ctx_callbacks_init(&sched->plat_ctx_cbs, ukplat_ctx_sw);
 
-       prv = uk_malloc(a, sizeof(struct schedcoop_private));
-       if (prv == NULL) {
-               uk_pr_warn("Could not allocate memory for scheduler private 
data.\n");
-               goto out_err;
-       }
-
+       prv = sched->prv;
        UK_TAILQ_INIT(&prv->exited_threads);
        UK_TAILQ_INIT(&prv->thread_list);
        prv->threads_started = 0;
-       sched->prv = prv;
 
        uk_sched_idle_init(sched, NULL, idle_thread_fn);
 
@@ -223,12 +213,4 @@ struct uk_sched *uk_schedcoop_init(struct uk_alloc *a)
                        schedcoop_thread_remove);
 
        return sched;
-
-out_err:
-       if (prv)
-               uk_free(a, prv);
-       if (sched)
-               uk_free(a, sched);
-
-       return NULL;
 }
-- 
2.11.0


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