Skip to contentSkip to conversation

implement runqueue per cpupool

PATCH In review anshulmakkar 4 participants 16 messages Sep 12, 2017 – Jan 17, 2019 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

Attached patch series introduces the concept of runqueue per cpupool.

"runqueue" configuration option can be specified with xl command while configuring cpupool. This will define the basis for grouping of cpus (cpu, core, socket, all) in that cpupool.

Series is combined of following patches:
[PATCH 1/3]: libxc related changes to add support for runqueue per cpupool [PATCH 2/3]: libxl related changes to add support for runqueue per cpupool [PATCH 3/3]: xen related changes.

On similar lines we can also have runqueue per pool configuration parameter for Credit scheduler. I plan to send a separate patch series for credit specific implementation.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH 1/3 credit2: libxc related changes to add support for runqueue per cpupool.

libxc receives scheduler specific configuration parametes from libxl.

---
 tools/libxc/include/xenctrl.h     | 6 +++++-
 tools/libxc/xc_cpupool.c          | 4 +++-
 tools/python/xen/lowlevel/xc/xc.c | 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
tools/libxc/include/xenctrl.h +5 -1
index 43151cb..e2157e9 100644
@@ -1077,17 +1077,21 @@ typedef struct xc_cpupoolinfo {
 
 #define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF
 
+typedef xen_sysctl_sched_param_t xc_schedparam_t;
+
 /**
  * Create a new cpupool.
  *
  * @parm xc_handle a handle to an open hypervisor interface
  * @parm ppoolid pointer to the new cpupool id (in/out)
  * @parm sched_id id of scheduler to use for pool
+ * @parm sched_param parameter of the scheduler of the cpupool eg. runq for credit2
  * return 0 on success, -1 on failure
  */
 int xc_cpupool_create(xc_interface *xch,
                       uint32_t *ppoolid,
-                      uint32_t sched_id);
+                      uint32_t sched_id,
+                      xc_schedparam_t * sched_param);
 
 /**
  * Destroy a cpupool. Pool must be unused and have no cpu assigned.
tools/libxc/xc_cpupool.c +3 -1
index fbd8cc9..fb2d183 100644
@@ -36,7 +36,8 @@ static int do_sysctl_save(xc_interface *xch, struct xen_sysctl *sysctl)
 
 int xc_cpupool_create(xc_interface *xch,
                       uint32_t *ppoolid,
-                      uint32_t sched_id)
+                      uint32_t sched_id,
+                      xc_schedparam_t * sched_params)
 {
     int err;
     DECLARE_SYSCTL;
@@ -46,6 +47,7 @@ int xc_cpupool_create(xc_interface *xch,
     sysctl.u.cpupool_op.cpupool_id = (*ppoolid == XC_CPUPOOL_POOLID_ANY) ?
         XEN_SYSCTL_CPUPOOL_PAR_ANY : *ppoolid;
     sysctl.u.cpupool_op.sched_id = sched_id;
+    sysctl.u.cpupool_op.sched_param = *sched_params;
     if ( (err = do_sysctl_save(xch, &sysctl)) != 0 )
         return err;
 
tools/python/xen/lowlevel/xc/xc.c +2 -1
index aa9f8e4..a83a23f 100644
@@ -1704,6 +1704,7 @@ static PyObject *pyxc_cpupool_create(XcObject *self,
                                      PyObject *kwds)
 {
     uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched = XEN_SCHEDULER_CREDIT;
+    xc_schedparam_t param;
 
     static char *kwd_list[] = { "pool", "sched", NULL };
 
@@ -1711,7 +1712,7 @@ static PyObject *pyxc_cpupool_create(XcObject *self,
                                       &sched))
         return NULL;
 
-    if ( xc_cpupool_create(self->xc_handle, &cpupool, sched) < 0 )
+    if ( xc_cpupool_create(self->xc_handle, &cpupool, sched, &param) < 0 )
         return pyxc_error_to_exception(self->xc_handle);
 
     return PyLongOrInt_FromLong(cpupool);
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 1/3] credit2: libxc related changes to add support for runqueue per cpupool.

Quoted 17 lines · anshulmakkar

libxc receives scheduler specific configuration parametes from libxl.

---
 tools/libxc/include/xenctrl.h     | 6 +++++-
 tools/libxc/xc_cpupool.c          | 4 +++-
 tools/python/xen/lowlevel/xc/xc.c | 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
tools/libxc/include/xenctrl.h +0 -0
index 43151cb..e2157e9 100644
@@ -1077,17 +1077,21 @@ typedef struct xc_cpupoolinfo {
 
 #define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF

tools/libxc/include/xenctrl.h typedef struct xc_cpupoolinfo { · line 1088

Quoted 10 lines
tools/libxc/include/xenctrl.h +3 -0
 
+typedef xen_sysctl_sched_param_t xc_schedparam_t;
+
 /**
  * Create a new cpupool.
  *
  * @parm xc_handle a handle to an open hypervisor interface
  * @parm ppoolid pointer to the new cpupool id (in/out)
  * @parm sched_id id of scheduler to use for pool
+ * @parm sched_param parameter of the scheduler of the cpupool eg. runq for credit2

I would drop "eg. runq for credit2"

Quoted 15 lines
tools/libxc/include/xenctrl.h +2 -1
  * return 0 on success, -1 on failure
  */
 int xc_cpupool_create(xc_interface *xch,
                       uint32_t *ppoolid,
-                      uint32_t sched_id);
+                      uint32_t sched_id,
+                      xc_schedparam_t * sched_param);
 
 /**
  * Destroy a cpupool. Pool must be unused and have no cpu assigned.
tools/libxc/xc_cpupool.c +0 -0
index fbd8cc9..fb2d183 100644

tools/libxc/xc_cpupool.c static int do_sysctl_save(xc_interface *xch, struct xen_sysctl *sysctl) · line 40

Quoted 6 lines
tools/libxc/xc_cpupool.c +2 -1
@@ -36,7 +36,8 @@ static int do_sysctl_save(xc_interface *xch, struct xen_sysctl *sysctl)
 
 int xc_cpupool_create(xc_interface *xch,
                       uint32_t *ppoolid,
-                      uint32_t sched_id)
+                      uint32_t sched_id,
+                      xc_schedparam_t * sched_params)

Coding style (omit the space after "*").

Quoted 16 lines
tools/libxc/xc_cpupool.c +1 -0
 {
     int err;
     DECLARE_SYSCTL;
@@ -46,6 +47,7 @@ int xc_cpupool_create(xc_interface *xch,
     sysctl.u.cpupool_op.cpupool_id = (*ppoolid == XC_CPUPOOL_POOLID_ANY) ?
         XEN_SYSCTL_CPUPOOL_PAR_ANY : *ppoolid;
     sysctl.u.cpupool_op.sched_id = sched_id;
+    sysctl.u.cpupool_op.sched_param = *sched_params;
     if ( (err = do_sysctl_save(xch, &sysctl)) != 0 )
         return err;
 
tools/python/xen/lowlevel/xc/xc.c +0 -0
index aa9f8e4..a83a23f 100644

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_cpupool_create(XcObject *self, · line 1709

Quoted 6 lines
tools/python/xen/lowlevel/xc/xc.c +1 -0
@@ -1704,6 +1704,7 @@ static PyObject *pyxc_cpupool_create(XcObject *self,
                                      PyObject *kwds)
 {
     uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched = XEN_SCHEDULER_CREDIT;
+    xc_schedparam_t param;
 
     static char *kwd_list[] = { "pool", "sched", NULL };

This needs to be extended for the sched_params, or you need to set sane default values in param in case you don't want to support them in the python bindings.

Another possibility would be to drop the cpupool python bindings completely (which I would prefer, TBH).

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH 1/3] credit2: libxc related changes to add support for runqueue per cpupool.

Quoted 10 lines · Juergen Gross
Quoted 10 lines
tools/libxc/include/xenctrl.h +0 -0
@@ -1077,17 +1077,21 @@ typedef struct xc_cpupoolinfo {


 #define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF

tools/libxc/include/xenctrl.h +2 -0
+typedef xen_sysctl_sched_param_t xc_schedparam_t;
+

 /**
  * Create a new cpupool.

Quoted 9 lines
Quoted 6 lines

  *
  * @parm xc_handle a handle to an open hypervisor interface
  * @parm ppoolid pointer to the new cpupool id (in/out)
  * @parm sched_id id of scheduler to use for pool
+ * @parm sched_param parameter of the scheduler of the cpupool eg. runq for credit2

I would drop "eg. runq for credit2"

+1

Quoted 7 lines
Quoted 7 lines
tools/python/xen/lowlevel/xc/xc.c +0 -0
@@ -1704,6 +1704,7 @@ static PyObject *pyxc_cpupool_create(XcObject
 *self,
                                       PyObject *kwds)
  {

     uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched =

Quoted 9 lines
Quoted 4 lines

XEN_SCHEDULER_CREDIT;
+    xc_schedparam_t param;

     static char *kwd_list[] = { "pool", "sched", NULL };

[..]
Another possibility would be to drop the cpupool python bindings completely (which I would prefer, TBH).

+1

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#4 lore raw

Re: [PATCH 1/3] credit2: libxc related changes to add support for runqueue per cpupool.

Quoted 31 lines · Dario Faggioli
Quoted 6 lines · Juergen Gross
Quoted 6 lines
tools/libxc/include/xenctrl.h +0 -0
@@ -1077,17 +1077,21 @@ typedef struct xc_cpupoolinfo {
 
  #define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF
 
Quoted 12 lines
Quoted 10 lines
tools/libxc/include/xenctrl.h +3 -0
+typedef xen_sysctl_sched_param_t xc_schedparam_t;
+
  /**
   * Create a new cpupool.
   *
   * @parm xc_handle a handle to an open hypervisor interface
   * @parm ppoolid pointer to the new cpupool id (in/out)
   * @parm sched_id id of scheduler to use for pool
+ * @parm sched_param parameter of the scheduler of the cpupool eg.

runq for credit2

I would drop "eg. runq for credit2"

+1

Quoted 10 lines
Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +1 -0
@@ -1704,6 +1704,7 @@ static PyObject *pyxc_cpupool_create(XcObject
 *self,
                                       PyObject *kwds)
  {
      uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched =
 XEN_SCHEDULER_CREDIT;
+    xc_schedparam_t param;
 
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

     static char *kwd_list[] = { "pool", "sched", NULL };

[..]
Another possibility would be to drop the cpupool python bindings completely (which I would prefer, TBH).

+1

Juergen, please can you clarify on this. Do you mean that I should remove the

complete cpupool handling from python APIs i.e remove all of pyxc_cpupool_*

APIs .

Also, it was some time back when I floated this patch. Does the requirement to remove cpupool python bindings

still holds.

Quoted 3 lines

Regards,
Dario

Anshul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw

Re: [PATCH 1/3] credit2: libxc related changes to add support for runqueue per cpupool.

Quoted 35 lines · anshul
Quoted 33 lines · Dario Faggioli
Quoted 7 lines · Juergen Gross
Quoted 7 lines
tools/libxc/include/xenctrl.h +1 -0
@@ -1077,17 +1077,21 @@ typedef struct xc_cpupoolinfo {
     #define XC_CPUPOOL_POOLID_ANY 0xFFFFFFFF
   +typedef xen_sysctl_sched_param_t xc_schedparam_t;
+
   /**
Quoted 9 lines
Quoted 7 lines
tools/libxc/include/xenctrl.h +1 -0
    * Create a new cpupool.
    *
    * @parm xc_handle a handle to an open hypervisor interface
    * @parm ppoolid pointer to the new cpupool id (in/out)
    * @parm sched_id id of scheduler to use for pool
+ * @parm sched_param parameter of the scheduler of the cpupool eg.

runq for credit2

I would drop "eg. runq for credit2"

+1

Quoted 14 lines
Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +0 -0
@@ -1704,6 +1704,7 @@ static PyObject *pyxc_cpupool_create(XcObject
 *self,
                                        PyObject *kwds)
   {

      uint32_t cpupool = XC_CPUPOOL_POOLID_ANY, sched = XEN_SCHEDULER_CREDIT;
+    xc_schedparam_t param;
        static char *kwd_list[] = { "pool", "sched", NULL };

[..]
Another possibility would be to drop the cpupool python bindings completely (which I would prefer, TBH).

Quoted 7 lines
Quoted 1 line

+1

Juergen, please can you clarify on this. Do you mean that I should remove the

complete cpupool handling from python APIs i.e remove all of pyxc_cpupool_*

APIs .

Yes.

Quoted 4 lines

Also, it was some time back when I floated this patch. Does the requirement to remove cpupool python bindings

still holds.

Its not a requirement, but a suggestion.

There are hardly any users of the Python bindings and as far as we know none of them is using them for cpupool handling.

So instead of adapting them to interface modifications removing them seems to be the better option.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Re: [PATCH 1/3] credit2: libxc related changes to add support for runqueue per cpupool.

In reply to anshulmakkar

[Trimming the Cc-list a bit]

Quoted 5 lines · anshulmakkar

libxc receives scheduler specific configuration parametes from libxl.

Apart from what Juergen said (including the thing that the series won't compile with this patch at the front), this patch looks fine to me.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

PATCH 2/3 credit2: libxl related changes to add support for runqueue per cpupool.

In reply to anshulmakkar

Introduces scheduler specific parameter at libxl level which are passed on to libxc. eg runqueue for credit2

---
 tools/libxl/libxl.h         |  2 +-
 tools/libxl/libxl_cpupool.c | 15 +++++++++++++--
 tools/libxl/libxl_types.idl | 46 ++++++++++++++++++++++++++++++++++-----------
 tools/xl/xl_cpupool.c       | 16 ++++++++++++++--
 4 files changed, 63 insertions(+), 16 deletions(-)
tools/libxl/libxl.h +1 -1
index 91408b4..6617c64 100644
@@ -2150,7 +2150,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap);
 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                          libxl_scheduler sched,
                          libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid);
+                         uint32_t *poolid, const libxl_scheduler_params *sched_param);
 int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
 int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
tools/libxl/libxl_cpupool.c +13 -2
index 85b0688..e3ce7b3 100644
@@ -130,7 +130,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap)
 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                          libxl_scheduler sched,
                          libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid)
+                         uint32_t *poolid, const libxl_scheduler_params *sched_params)
 {
     GC_INIT(ctx);
     int rc;
@@ -138,6 +138,7 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
     xs_transaction_t t;
     char *uuid_string;
     uint32_t xcpoolid;
+    xc_schedparam_t xc_sched_param; 
 
     /* Accept '0' as 'any poolid' for backwards compatibility */
     if ( *poolid == LIBXL_CPUPOOL_POOLID_ANY
@@ -151,8 +152,18 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
         GC_FREE;
         return ERROR_NOMEM;
     }
+    if (sched_params)
+    {
+        xc_sched_param.u.sched_credit2.ratelimit_us = 
+                                                    sched_params->u.credit2.ratelimit_us;
+        xc_sched_param.u.sched_credit2.runq = sched_params->u.credit2.runqueue;
+        xc_sched_param.u.sched_credit.tslice_ms = sched_params->u.credit.tslice_ms;
+        xc_sched_param.u.sched_credit.ratelimit_us = sched_params->u.credit.ratelimit_us; 
+    }
+    else 
+        xc_sched_param.u.sched_credit2.runq = LIBXL_CREDIT2_RUNQUEUE_DEFAULT; 
 
-    rc = xc_cpupool_create(ctx->xch, &xcpoolid, sched);
+    rc = xc_cpupool_create(ctx->xch, &xcpoolid, sched, &xc_sched_param);
     if (rc) {
         LOGEV(ERROR, rc, "Could not create cpupool");
         GC_FREE;
tools/libxl/libxl_types.idl +35 -11

71 lines not on this page · raw message

tools/xl/xl_cpupool.c +14 -2
index 273811b..dc419eb 100644
@@ -43,6 +43,7 @@ int main_cpupoolcreate(int argc, char **argv)
     char *name = NULL;
     uint32_t poolid;
     libxl_scheduler sched = 0;
+    libxl_scheduler_params sched_params;
     XLU_ConfigList *cpus;
     XLU_ConfigList *nodes;
     int n_cpus, n_nodes, i, n;
@@ -207,16 +208,27 @@ int main_cpupoolcreate(int argc, char **argv)
     } else
         n_cpus = 0;
 
+    sched_params.u.credit2.runqueue = LIBXL_CREDIT2_RUNQUEUE_CORE;
+    if (!xlu_cfg_get_string (config, "runqueue", &buf, 0) &&
+        sched == LIBXL_SCHEDULER_CREDIT2) {
+        if ((libxl_credit2_runqueue_from_string(buf, &sched_params.u.credit2.runqueue)) < 0 ) {
+            fprintf(stderr, "Unknown runqueue option\n");
+           sched_params.u.credit2.runqueue =  LIBXL_CREDIT2_RUNQUEUE_CORE; /*default CORE */
+        }
+    }
+
     libxl_uuid_generate(&uuid);
 
     printf("Using config file \"%s\"\n", config_src);
     printf("cpupool name:   %s\n", name);
     printf("scheduler:      %s\n", libxl_scheduler_to_string(sched));
+    if (sched == LIBXL_SCHEDULER_CREDIT2)
+        printf(" runq: %s\n", libxl_credit2_runqueue_to_string(sched_params.u.credit2.runqueue));
     printf("number of cpus: %d\n", n_cpus);
 
     if (!dryrun_only) {
         poolid = LIBXL_CPUPOOL_POOLID_ANY;
-        if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid)) {
+        if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid, &sched_params)) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out_cfg;
         }
@@ -587,7 +599,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
         xasprintf(&name, "Pool-node%d", node);
         libxl_uuid_generate(&uuid);
         poolid = 0;
-        if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid)) {
+        if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid, NULL)) {
             fprintf(stderr, "error on creating cpupool\n");
             goto out;
         }
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#8 lore raw

Re: [PATCH 2/3] credit2: libxl related changes to add support for runqueue per cpupool.

Quoted 16 lines · anshulmakkar

Introduces scheduler specific parameter at libxl level which are passed on to libxc. eg runqueue for credit2

---
 tools/libxl/libxl.h         |  2 +-
 tools/libxl/libxl_cpupool.c | 15 +++++++++++++--
 tools/libxl/libxl_types.idl | 46 ++++++++++++++++++++++++++++++++++-----------
 tools/xl/xl_cpupool.c       | 16 ++++++++++++++--
 4 files changed, 63 insertions(+), 16 deletions(-)
tools/libxl/libxl.h +0 -0
index 91408b4..6617c64 100644

tools/libxl/libxl.h int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap); · line 2153

Quoted 5 lines
tools/libxl/libxl.h +1 -1
@@ -2150,7 +2150,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap);
 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                          libxl_scheduler sched,
                          libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid);
+                         uint32_t *poolid, const libxl_scheduler_params *sched_param);

You are modifying an exported libxl function. This requires compatibility hooks (look e.g. how this is handled in libxl.h for functions like libxl_get_memory_target)

Quoted 25 lines
tools/libxl/libxl.h +0 -0
 int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
 int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
tools/libxl/libxl_cpupool.c +2 -1
index 85b0688..e3ce7b3 100644
@@ -130,7 +130,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap)
 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                          libxl_scheduler sched,
                          libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid)
+                         uint32_t *poolid, const libxl_scheduler_params *sched_params)
 {
     GC_INIT(ctx);
     int rc;
@@ -138,6 +138,7 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
     xs_transaction_t t;
     char *uuid_string;
     uint32_t xcpoolid;
+    xc_schedparam_t xc_sched_param; 
 
     /* Accept '0' as 'any poolid' for backwards compatibility */
     if ( *poolid == LIBXL_CPUPOOL_POOLID_ANY

tools/libxl/libxl_cpupool.c int libxl_cpupool_create(libxl_ctx *ctx, const char *name, · line 161

Quoted 10 lines
tools/libxl/libxl_cpupool.c +7 -0
@@ -151,8 +152,18 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
         GC_FREE;
         return ERROR_NOMEM;
     }
+    if (sched_params)
+    {
+        xc_sched_param.u.sched_credit2.ratelimit_us = 
+                                                    sched_params->u.credit2.ratelimit_us;
+        xc_sched_param.u.sched_credit2.runq = sched_params->u.credit2.runqueue;
+        xc_sched_param.u.sched_credit.tslice_ms = sched_params->u.credit.tslice_ms;
+        xc_sched_param.u.sched_credit.ratelimit_us = sched_params->u.credit.ratelimit_us; 

Don't you need some input parameter validation here?

tools/libxl/libxl_cpupool.c int libxl_cpupool_create(libxl_ctx *ctx, const char *name, · line 164

Quoted 3 lines
tools/libxl/libxl_cpupool.c +3 -0
+    }
+    else 
+        xc_sched_param.u.sched_credit2.runq = LIBXL_CREDIT2_RUNQUEUE_DEFAULT; 

So you are passing the LIBXL defines down to the hypervisor expecting they match. I think this is a major layering violation.

Quoted 51 lines
tools/libxl/libxl_cpupool.c +1 -1
-    rc = xc_cpupool_create(ctx->xch, &xcpoolid, sched);
+    rc = xc_cpupool_create(ctx->xch, &xcpoolid, sched, &xc_sched_param);
     if (rc) {
         LOGEV(ERROR, rc, "Could not create cpupool");
         GC_FREE;
tools/libxl/libxl_types.idl +30 -0
index 173d70a..f25429d 100644
@@ -194,6 +194,16 @@ libxl_scheduler = Enumeration("scheduler", [
     (9, "null"),
     ])
 
+# consistent with sched_credit2.c
+libxl_credit2_runqueue = Enumeration("credit2_runqueue", [
+    (0, "CPU"),
+    (1, "CORE"),
+    (2, "SOCKET"),
+    (3, "NODE"),
+    (4, "ALL"),
+    (5, "DEFAULT"),
+    ])
+
 # Consistent with SHUTDOWN_* in sched.h (apart from UNKNOWN)
 libxl_shutdown_reason = Enumeration("shutdown_reason", [
     (-1, "unknown"),
@@ -326,15 +336,38 @@ libxl_dominfo = Struct("dominfo",[
     ("domain_type", libxl_domain_type),
     ], dir=DIR_OUT)
 
+libxl_sched_credit_params = Struct("sched_credit_params", [
+    ("tslice_ms", integer),
+    ("ratelimit_us", integer),
+    ], dispose_fn=None)
+
+libxl_sched_credit2_params = Struct("sched_credit2_params", [
+    ("ratelimit_us", integer),
+    ("runqueue", libxl_credit2_runqueue),
+    ], dispose_fn=None)
+ 
+libxl_scheduler_params = Struct("scheduler_params", [
+    ("u", KeyedUnion(None,libxl_scheduler_tpye "scheduler_type",
+          [("credit2", libxl_sched_credit2_params),
+           ("credit", libxl_sched_credit_params),
+           ("null", None),
+           ("arinc653", None),
+           ("rtds", None),
+           ("unknown", None),
+           ("sedf", None),
+          ])),

tools/libxl/libxl_types.idl libxl_dominfo = Struct("dominfo",[ · line 367

Quoted 10 lines
tools/libxl/libxl_types.idl +4 -1
+     ])
+
 libxl_cpupoolinfo = Struct("cpupoolinfo", [
     ("poolid",      uint32),
     ("pool_name",   string),
     ("sched",       libxl_scheduler),
     ("n_dom",       uint32),
-    ("cpumap",      libxl_bitmap)
+    ("cpumap",      libxl_bitmap),
+    ("sched_param", libxl_scheduler_params),

You need a LIBXL_HAVE_* define in libxl.h to indicate presence of the new struct member.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH 2/3] credit2: libxl related changes to add support for runqueue per cpupool.

[Trimming the Cc-list a bit]

Quoted 28 lines · Juergen Gross
Quoted 27 lines · anshulmakkar

Introduces scheduler specific parameter at libxl level which are passed on to libxc. eg runqueue for credit2

  int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
  int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
  int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
tools/libxl/libxl_cpupool.c +2 -1
index 85b0688..e3ce7b3 100644
@@ -130,7 +130,7 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap)
  int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                           libxl_scheduler sched,
                           libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid)
+                         uint32_t *poolid, const libxl_scheduler_params *sched_params)
  {
      GC_INIT(ctx);
      int rc;
@@ -138,6 +138,7 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
      xs_transaction_t t;
      char *uuid_string;
      uint32_t xcpoolid;
+    xc_schedparam_t xc_sched_param;
 
Quoted 14 lines

tools/libxl/libxl_cpupool.c int libxl_cpupool_create(libxl_ctx *ctx, const char *name, · line 161

Quoted 13 lines
tools/libxl/libxl_cpupool.c +7 -0
      /* Accept '0' as 'any poolid' for backwards compatibility */
      if ( *poolid == LIBXL_CPUPOOL_POOLID_ANY
@@ -151,8 +152,18 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
          GC_FREE;
          return ERROR_NOMEM;
      }
+    if (sched_params)
+    {
+        xc_sched_param.u.sched_credit2.ratelimit_us =
+                                                    sched_params->u.credit2.ratelimit_us;
+        xc_sched_param.u.sched_credit2.runq = sched_params->u.credit2.runqueue;
+        xc_sched_param.u.sched_credit.tslice_ms = sched_params->u.credit.tslice_ms;
+        xc_sched_param.u.sched_credit.ratelimit_us = sched_params->u.credit.ratelimit_us;

Don't you need some input parameter validation here?

Agree. Will perform validation.

Quoted 5 lines

tools/libxl/libxl_cpupool.c int libxl_cpupool_create(libxl_ctx *ctx, const char *name, · line 164

Quoted 3 lines
tools/libxl/libxl_cpupool.c +3 -0
+    }
+    else
+        xc_sched_param.u.sched_credit2.runq = LIBXL_CREDIT2_RUNQUEUE_DEFAULT;

So you are passing the LIBXL defines down to the hypervisor expecting they match. I think this is a major layering violation.

I need to pass the DEFAULT runq arrangement if the user has not selected any option and I want to do it near to the top level (libxc) so that consistency can be maintained at the lower scheduler layer.
Please can you suggest alternative that will maintain layering consistency.

Quoted 4 lines

Juergen

anshul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH 2/3] credit2: libxl related changes to add support for runqueue per cpupool.

Quoted 59 lines · Anshul Makkar

[Trimming the Cc-list a bit]

Quoted 42 lines · Juergen Gross
Quoted 41 lines · anshulmakkar

Introduces scheduler specific parameter at libxl level which are passed on to libxc. eg runqueue for credit2

  int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid); int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
  int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);

tools/libxl/libxl_cpupool.c +1 -1
index 85b0688..e3ce7b3 100644
@@ -130,7 +130,7 @@ int libxl_get_freecpus(libxl_ctx *ctx,
 libxl_bitmap *cpumap)
   int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
                            libxl_scheduler sched,
                            libxl_bitmap cpumap, libxl_uuid *uuid,
-                         uint32_t *poolid)
+                         uint32_t *poolid, const
 libxl_scheduler_params *sched_params)
   {

      GC_INIT(ctx);
      int rc;

tools/libxl/libxl_cpupool.c +1 -0
@@ -138,6 +138,7 @@ int libxl_cpupool_create(libxl_ctx *ctx, const
 char *name,
       xs_transaction_t t;
       char *uuid_string;
       uint32_t xcpoolid;
+    xc_schedparam_t xc_sched_param;
         /* Accept '0' as 'any poolid' for backwards compatibility */

      if ( *poolid == LIBXL_CPUPOOL_POOLID_ANY

tools/libxl/libxl_cpupool.c +4 -0
@@ -151,8 +152,18 @@ int libxl_cpupool_create(libxl_ctx *ctx, const
 char *name,
           GC_FREE;
           return ERROR_NOMEM;
       }
+    if (sched_params)
+    {
+        xc_sched_param.u.sched_credit2.ratelimit_us =
+                                                   
Quoted 8 lines

tools/libxl/libxl_cpupool.c int libxl_cpupool_create(libxl_ctx *ctx, const · line 166

Quoted 7 lines
tools/libxl/libxl_cpupool.c +3 -0
 sched_params->u.credit2.ratelimit_us;
+        xc_sched_param.u.sched_credit2.runq =
 sched_params->u.credit2.runqueue;
+        xc_sched_param.u.sched_credit.tslice_ms =
 sched_params->u.credit.tslice_ms;
+        xc_sched_param.u.sched_credit.ratelimit_us =
 sched_params->u.credit.ratelimit_us;

Don't you need some input parameter validation here?

Agree. Will perform validation.

Quoted 4 lines
Quoted 4 lines
tools/libxl/libxl_cpupool.c +3 -0
+    }
+    else
+        xc_sched_param.u.sched_credit2.runq =

LIBXL_CREDIT2_RUNQUEUE_DEFAULT;

Quoted 7 lines
Quoted 2 lines

So you are passing the LIBXL defines down to the hypervisor expecting they match. I think this is a major layering violation.

I need to pass the DEFAULT runq arrangement if the user has not selected any option and I want to do it near to the top level (libxc) so that consistency
can be maintained at the lower scheduler layer.
Please can you suggest alternative that will maintain layering consistency.

So either have some glue code translating the LIBXL defines to the hypervisor ones, or add some statements triggering a build failure in case they don't match.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

PATCH 3/3 credit2: xen related changes to add support for runqueue per cpupool.

In reply to anshulmakkar

Handles extra scheduler configuration paramers received at init stage.

---
 xen/common/cpupool.c        | 13 ++++++++-----
 xen/common/sched_arinc653.c |  2 +-
 xen/common/sched_credit.c   |  2 +-
 xen/common/sched_credit2.c  |  8 +++++++-
 xen/common/sched_null.c     |  3 ++-
 xen/common/sched_rt.c       |  2 +-
 xen/common/schedule.c       | 11 +++++++----
 xen/include/public/sysctl.h | 45 +++++++++++++++++++++++++++++----------------
 xen/include/xen/sched-if.h  |  3 ++-
 xen/include/xen/sched.h     |  4 +++-
 10 files changed, 61 insertions(+), 32 deletions(-)
xen/common/cpupool.c +8 -5
index 9998394..31bace4 100644
@@ -129,12 +129,13 @@ void cpupool_put(struct cpupool *pool)
  * - unknown scheduler
  */
 static struct cpupool *cpupool_create(
-    int poolid, unsigned int sched_id, int *perr)
+    int poolid, unsigned int sched_id,
+    xen_sysctl_sched_param_t param,
+    int *perr)
 {
     struct cpupool *c;
     struct cpupool **q;
     int last = 0;
-
     *perr = -ENOMEM;
     if ( (c = alloc_cpupool_struct()) == NULL )
         return NULL;
@@ -171,7 +172,7 @@ static struct cpupool *cpupool_create(
     }
     else
     {
-        c->sched = scheduler_alloc(sched_id, perr);
+        c->sched = scheduler_alloc(sched_id, param, perr);
         if ( c->sched == NULL )
         {
             spin_unlock(&cpupool_lock);
@@ -600,10 +601,11 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
     case XEN_SYSCTL_CPUPOOL_OP_CREATE:
     {
         int poolid;
+        xen_sysctl_sched_param_t param = op->sched_param;
 
         poolid = (op->cpupool_id == XEN_SYSCTL_CPUPOOL_PAR_ANY) ?
             CPUPOOLID_NONE: op->cpupool_id;
-        c = cpupool_create(poolid, op->sched_id, &ret);
+        c = cpupool_create(poolid, op->sched_id, param, &ret);
         if ( c != NULL )
         {
             op->cpupool_id = c->cpupool_id;
@@ -798,7 +800,8 @@ static int __init cpupool_presmp_init(void)
 {
     int err;
     void *cpu = (void *)(long)smp_processor_id();
-    cpupool0 = cpupool_create(0, 0, &err);
+    xen_sysctl_sched_param_t param;
+    cpupool0 = cpupool_create(0, 0, param, &err);
     BUG_ON(cpupool0 == NULL);
     cpupool_put(cpupool0);
     cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
xen/common/sched_arinc653.c +1 -1
index 0b1b849..1f5d0d0 100644
@@ -343,7 +343,7 @@ arinc653_sched_get(
  *                  </ul>
  */
 static int
-a653sched_init(struct scheduler *ops)
+a653sched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     a653sched_priv_t *prv;
 
xen/common/sched_credit.c +1 -1
index 4fdaa08..44ceaf7 100644
@@ -2160,7 +2160,7 @@ csched_dump(const struct scheduler *ops)
 }
 
 static int
-csched_init(struct scheduler *ops)
+csched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     struct csched_private *prv;
 
xen/common/sched_credit2.c +7 -1
index 0f93ad5..9b5bbbf 100644
@@ -391,6 +391,7 @@ struct csched2_private {
     unsigned int load_precision_shift; /* Precision of load calculations     */
     unsigned int load_window_shift;    /* Lenght of load decaying window     */
     unsigned int ratelimit_us;         /* Rate limiting for this scheduler   */
+    unsigned runqueue;                 /* cpupool has its own type of runq */
 
     cpumask_t active_queues;           /* Runqueues with (maybe) active cpus */
     struct csched2_runqueue_data *rqd; /* Data of the various runqueues      */
@@ -3349,7 +3350,7 @@ csched2_deinit_pdata(const struct scheduler *ops, void *pcpu, int cpu)
 }
 
 static int
-csched2_init(struct scheduler *ops)
+csched2_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     int i;
     struct csched2_private *prv;
@@ -3410,6 +3411,11 @@ csched2_init(struct scheduler *ops)
     /* initialize ratelimit */
     prv->ratelimit_us = sched_ratelimit_us;
 
+    /* not need of type checking here if sched_para.type = credit2. Code
+     * block is here means we have type as credit2.
+     */
+    prv->runqueue = sched_param.u.sched_credit2.runq;
+
     prv->load_precision_shift = opt_load_precision_shift;
     prv->load_window_shift = opt_load_window_shift - LOADAVG_GRANULARITY_SHIFT;
     ASSERT(opt_load_window_shift > 0);
xen/common/sched_null.c +2 -1
index b4a24ba..cab45c7 100644
@@ -135,7 +135,8 @@ static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu,
     return cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu));
 }
 
-static int null_init(struct scheduler *ops)
+static int null_init(struct scheduler *ops,
+                     xen_sysctl_sched_param_t sched_param)
 {
     struct null_private *prv;
 
xen/common/sched_rt.c +1 -1
index 0ac5816..6593489 100644
@@ -624,7 +624,7 @@ rt_cpu_pick(const struct scheduler *ops, struct vcpu *vc)
  * Init/Free related code
  */
 static int
-rt_init(struct scheduler *ops)
+rt_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     int rc = -ENOMEM;
     struct rt_private *prv = xzalloc(struct rt_private);
xen/common/schedule.c +7 -4
index 8827921..8945cf0 100644
@@ -1676,6 +1676,7 @@ void __init scheduler_init(void)
 {
     struct domain *idle_domain;
     int i;
+    xen_sysctl_sched_param_t param;
 
     open_softirq(SCHEDULE_SOFTIRQ, schedule);
 
@@ -1704,9 +1705,9 @@ void __init scheduler_init(void)
     if ( cpu_schedule_up(0) )
         BUG();
     register_cpu_notifier(&cpu_schedule_nfb);
-
+    
     printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name);
-    if ( SCHED_OP(&ops, init) )
+    if ( SCHED_OP(&ops, init, param) )
         panic("scheduler returned error on init");
 
     if ( sched_ratelimit_us &&
@@ -1835,7 +1836,9 @@ struct scheduler *scheduler_get_default(void)
     return &ops;
 }
 
-struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)
+struct scheduler *scheduler_alloc(unsigned int sched_id,
+                                  xen_sysctl_sched_param_t param,
+                                  int *perr)
 {
     int i;
     struct scheduler *sched;
@@ -1851,7 +1854,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)
     if ( (sched = xmalloc(struct scheduler)) == NULL )
         return NULL;
     memcpy(sched, schedulers[i], sizeof(*sched));
-    if ( (*perr = SCHED_OP(sched, init)) != 0 )
+    if ( (*perr = SCHED_OP(sched, init, param)) != 0 )
     {
         xfree(sched);
         sched = NULL;
xen/include/public/sysctl.h +29 -16

64 lines not on this page · raw message

xen/include/xen/sched-if.h +2 -1
index c4a4935..2272ea0 100644
@@ -136,7 +136,8 @@ struct scheduler {
 
     int          (*global_init)    (void);
 
-    int          (*init)           (struct scheduler *);
+    int          (*init)           (struct scheduler *,
+                                    xen_sysctl_sched_param_t);
     void         (*deinit)         (struct scheduler *);
 
     void         (*free_vdata)     (const struct scheduler *, void *);
xen/include/xen/sched.h +3 -1
index 5b8f8c6..43b7dae 100644
@@ -832,7 +832,9 @@ void cpu_init(void);
 struct scheduler;
 
 struct scheduler *scheduler_get_default(void);
-struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr);
+struct scheduler *scheduler_alloc(unsigned int sched_id,
+                                  xen_sysctl_sched_param_t param,
+                                  int *perr);
 void scheduler_free(struct scheduler *sched);
 int schedule_cpu_switch(unsigned int cpu, struct cpupool *c);
 void vcpu_force_reschedule(struct vcpu *v);
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#12 lore raw

Re: [PATCH 3/3] credit2: xen related changes to add support for runqueue per cpupool.

Quoted 22 lines · anshulmakkar

Handles extra scheduler configuration paramers received at init stage.

---
 xen/common/cpupool.c        | 13 ++++++++-----
 xen/common/sched_arinc653.c |  2 +-
 xen/common/sched_credit.c   |  2 +-
 xen/common/sched_credit2.c  |  8 +++++++-
 xen/common/sched_null.c     |  3 ++-
 xen/common/sched_rt.c       |  2 +-
 xen/common/schedule.c       | 11 +++++++----
 xen/include/public/sysctl.h | 45 +++++++++++++++++++++++++++++----------------
 xen/include/xen/sched-if.h  |  3 ++-
 xen/include/xen/sched.h     |  4 +++-
 10 files changed, 61 insertions(+), 32 deletions(-)
xen/common/cpupool.c +0 -0
index 9998394..31bace4 100644

xen/common/cpupool.c void cpupool_put(struct cpupool *pool) · line 133

Quoted 6 lines
xen/common/cpupool.c +2 -1
@@ -129,12 +129,13 @@ void cpupool_put(struct cpupool *pool)
  * - unknown scheduler
  */
 static struct cpupool *cpupool_create(
-    int poolid, unsigned int sched_id, int *perr)
+    int poolid, unsigned int sched_id,
+    xen_sysctl_sched_param_t param,

I'd prefer param to be passed via a pointer. Passing a struct as a function parameter isn't good practice, especially in case it is passed down multiple levels.

Quoted 32 lines
xen/common/cpupool.c +4 -3
+    int *perr)
 {
     struct cpupool *c;
     struct cpupool **q;
     int last = 0;
-
     *perr = -ENOMEM;
     if ( (c = alloc_cpupool_struct()) == NULL )
         return NULL;
@@ -171,7 +172,7 @@ static struct cpupool *cpupool_create(
     }
     else
     {
-        c->sched = scheduler_alloc(sched_id, perr);
+        c->sched = scheduler_alloc(sched_id, param, perr);
         if ( c->sched == NULL )
         {
             spin_unlock(&cpupool_lock);
@@ -600,10 +601,11 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
     case XEN_SYSCTL_CPUPOOL_OP_CREATE:
     {
         int poolid;
+        xen_sysctl_sched_param_t param = op->sched_param;
 
         poolid = (op->cpupool_id == XEN_SYSCTL_CPUPOOL_PAR_ANY) ?
             CPUPOOLID_NONE: op->cpupool_id;
-        c = cpupool_create(poolid, op->sched_id, &ret);
+        c = cpupool_create(poolid, op->sched_id, param, &ret);
         if ( c != NULL )
         {
             op->cpupool_id = c->cpupool_id;

xen/common/cpupool.c static int __init cpupool_presmp_init(void) · line 804

Quoted 6 lines
xen/common/cpupool.c +2 -1
@@ -798,7 +800,8 @@ static int __init cpupool_presmp_init(void)
 {
     int err;
     void *cpu = (void *)(long)smp_processor_id();
-    cpupool0 = cpupool_create(0, 0, &err);
+    xen_sysctl_sched_param_t param;
+    cpupool0 = cpupool_create(0, 0, param, &err);

param is uninitialized here!

Quoted 102 lines
xen/common/cpupool.c +0 -0
     BUG_ON(cpupool0 == NULL);
     cpupool_put(cpupool0);
     cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
xen/common/sched_arinc653.c +1 -1
index 0b1b849..1f5d0d0 100644
@@ -343,7 +343,7 @@ arinc653_sched_get(
  *                  </ul>
  */
 static int
-a653sched_init(struct scheduler *ops)
+a653sched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     a653sched_priv_t *prv;
 
xen/common/sched_credit.c +1 -1
index 4fdaa08..44ceaf7 100644
@@ -2160,7 +2160,7 @@ csched_dump(const struct scheduler *ops)
 }
 
 static int
-csched_init(struct scheduler *ops)
+csched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     struct csched_private *prv;
 
xen/common/sched_credit2.c +7 -1
index 0f93ad5..9b5bbbf 100644
@@ -391,6 +391,7 @@ struct csched2_private {
     unsigned int load_precision_shift; /* Precision of load calculations     */
     unsigned int load_window_shift;    /* Lenght of load decaying window     */
     unsigned int ratelimit_us;         /* Rate limiting for this scheduler   */
+    unsigned runqueue;                 /* cpupool has its own type of runq */
 
     cpumask_t active_queues;           /* Runqueues with (maybe) active cpus */
     struct csched2_runqueue_data *rqd; /* Data of the various runqueues      */
@@ -3349,7 +3350,7 @@ csched2_deinit_pdata(const struct scheduler *ops, void *pcpu, int cpu)
 }
 
 static int
-csched2_init(struct scheduler *ops)
+csched2_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     int i;
     struct csched2_private *prv;
@@ -3410,6 +3411,11 @@ csched2_init(struct scheduler *ops)
     /* initialize ratelimit */
     prv->ratelimit_us = sched_ratelimit_us;
 
+    /* not need of type checking here if sched_para.type = credit2. Code
+     * block is here means we have type as credit2.
+     */
+    prv->runqueue = sched_param.u.sched_credit2.runq;
+
     prv->load_precision_shift = opt_load_precision_shift;
     prv->load_window_shift = opt_load_window_shift - LOADAVG_GRANULARITY_SHIFT;
     ASSERT(opt_load_window_shift > 0);
xen/common/sched_null.c +2 -1
index b4a24ba..cab45c7 100644
@@ -135,7 +135,8 @@ static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu,
     return cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu));
 }
 
-static int null_init(struct scheduler *ops)
+static int null_init(struct scheduler *ops,
+                     xen_sysctl_sched_param_t sched_param)
 {
     struct null_private *prv;
 
xen/common/sched_rt.c +1 -1
index 0ac5816..6593489 100644
@@ -624,7 +624,7 @@ rt_cpu_pick(const struct scheduler *ops, struct vcpu *vc)
  * Init/Free related code
  */
 static int
-rt_init(struct scheduler *ops)
+rt_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param)
 {
     int rc = -ENOMEM;
     struct rt_private *prv = xzalloc(struct rt_private);
xen/common/schedule.c +1 -0
index 8827921..8945cf0 100644
@@ -1676,6 +1676,7 @@ void __init scheduler_init(void)
 {
     struct domain *idle_domain;
     int i;
+    xen_sysctl_sched_param_t param;
 
     open_softirq(SCHEDULE_SOFTIRQ, schedule);
 

xen/common/schedule.c void __init scheduler_init(void) · line 1708

Quoted 5 lines
xen/common/schedule.c +1 -1
@@ -1704,9 +1705,9 @@ void __init scheduler_init(void)
     if ( cpu_schedule_up(0) )
         BUG();
     register_cpu_notifier(&cpu_schedule_nfb);
-
+    

unrelated white space change

xen/common/schedule.c void __init scheduler_init(void) · line 1710

Quoted 3 lines
xen/common/schedule.c +1 -1
     printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name);
-    if ( SCHED_OP(&ops, init) )
+    if ( SCHED_OP(&ops, init, param) )

Again param not initialized.

Quoted 34 lines
xen/common/schedule.c +4 -2
         panic("scheduler returned error on init");
 
     if ( sched_ratelimit_us &&
@@ -1835,7 +1836,9 @@ struct scheduler *scheduler_get_default(void)
     return &ops;
 }
 
-struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)
+struct scheduler *scheduler_alloc(unsigned int sched_id,
+                                  xen_sysctl_sched_param_t param,
+                                  int *perr)
 {
     int i;
     struct scheduler *sched;
@@ -1851,7 +1854,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)
     if ( (sched = xmalloc(struct scheduler)) == NULL )
         return NULL;
     memcpy(sched, schedulers[i], sizeof(*sched));
-    if ( (*perr = SCHED_OP(sched, init)) != 0 )
+    if ( (*perr = SCHED_OP(sched, init, param)) != 0 )
     {
         xfree(sched);
         sched = NULL;
xen/include/public/sysctl.h +3 -0
index 7830b98..1182422 100644
@@ -538,7 +538,34 @@ struct xen_sysctl_numainfo {
 typedef struct xen_sysctl_numainfo xen_sysctl_numainfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_numainfo_t);
 
+struct xen_sysctl_credit_schedule {
+    /* Length of timeslice in milliseconds */
+#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000

xen/include/public/sysctl.h struct xen_sysctl_numainfo { · line 553

Quoted 10 lines
xen/include/public/sysctl.h +10 -0
+#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1
+    unsigned tslice_ms;
+    unsigned ratelimit_us;
+};
+typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t);
+
+struct xen_sysctl_credit2_schedule {
+    unsigned ratelimit_us;
+    unsigned runq;

While moving those structs mind to use unsigned int?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

Re: [PATCH 3/3] credit2: xen related changes to add support for runqueue per cpupool.

In reply to anshulmakkar
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 12.09.17 at 02:45, <[email protected]> wrote:
xen/include/public/sysctl.h +0 -0
@@ -538,7 +538,34 @@ struct xen_sysctl_numainfo {
 typedef struct xen_sysctl_numainfo xen_sysctl_numainfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_numainfo_t);

xen/include/public/sysctl.h struct xen_sysctl_numainfo { · line 549

Quoted 10 lines
xen/include/public/sysctl.h +9 -0
 
+struct xen_sysctl_credit_schedule {
+    /* Length of timeslice in milliseconds */
+#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000
+#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1
+    unsigned tslice_ms;
+    unsigned ratelimit_us;
+};
+typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t);

No new unnecessary typedefs and handles anymore please now that a patch is almost ready to go in to remove those.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#14 lore raw

Re: [PATCH 3/3] credit2: xen related changes to add support for runqueue per cpupool.

In reply to anshulmakkar
Quoted 11 lines · anshulmakkar
xen/common/cpupool.c +0 -0
@@ -129,12 +129,13 @@ void cpupool_put(struct cpupool *pool)
   * - unknown scheduler
   */

 static struct cpupool *cpupool_create(
-    int poolid, unsigned int sched_id, int *perr) +    int poolid, unsigned int sched_id,
+    xen_sysctl_sched_param_t param,
+    int *perr)

I second Juergen's opinion about as much as possible of these xen_sysctl_sched_param to move around functions as (const?) pointers.

Quoted 5 lines

 {
     struct cpupool *c;
     struct cpupool **q;
     int last = 0;
-

Spurious blank line deletion.

Quoted 7 lines

     *perr = -ENOMEM;
     if ( (c = alloc_cpupool_struct()) == NULL )
         return NULL;

xen/common/cpupool.c +0 -0
@@ -600,10 +601,11 @@ int cpupool_do_sysctl(struct
 xen_sysctl_cpupool_op *op)

     case XEN_SYSCTL_CPUPOOL_OP_CREATE:

Quoted 9 lines

     {
         int poolid;
+        xen_sysctl_sched_param_t param = op->sched_param;
         poolid = (op->cpupool_id == XEN_SYSCTL_CPUPOOL_PAR_ANY) ?
             CPUPOOLID_NONE: op->cpupool_id;
-        c = cpupool_create(poolid, op->sched_id, &ret); +        c = cpupool_create(poolid, op->sched_id, param, &ret);

Why you need the 'param' temporary variable?

xen/common/cpupool.c static int __init cpupool_presmp_init(void) · line 805

Quoted 8 lines
xen/common/cpupool.c +2 -1
@@ -798,7 +800,8 @@ static int __init cpupool_presmp_init(void)
  {
      int err;
      void *cpu = (void *)(long)smp_processor_id();
-    cpupool0 = cpupool_create(0, 0, &err);
+    xen_sysctl_sched_param_t param;
+    cpupool0 = cpupool_create(0, 0, param, &err);
 

And in fact, if you use pointers, here you can pass NULL (to mean "just use default parameters").

Quoted 12 lines
xen/common/cpupool.c +0 -0
      BUG_ON(cpupool0 == NULL);
      cpupool_put(cpupool0);

     cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);

xen/common/sched_arinc653.c +0 -0
@@ -343,7 +343,7 @@ arinc653_sched_get(
   *                  </ul>
   */

 static int

xen/common/sched_arinc653.c +1 -1
-a653sched_init(struct scheduler *ops)
+a653sched_init(struct scheduler *ops, xen_sysctl_sched_param_t
Quoted 4 lines

sched_param)
 {
     a653sched_priv_t *prv;

And here, and in other schedulers that doesn't take parameters, still if you use pointers, you can check that things are being done properly, by putting an

 ASSERT(sched_param == NULL);

Quoted 5 lines
xen/common/sched_credit2.c +0 -0
@@ -3410,6 +3411,11 @@ csched2_init(struct scheduler *ops)
      /* initialize ratelimit */
      prv->ratelimit_us = sched_ratelimit_us;
Quoted 7 lines


+    /* not need of type checking here if sched_para.type = credit2. Code
+     * block is here means we have type as credit2.
+     */
+    prv->runqueue = sched_param.u.sched_credit2.runq;
+

I don't understand what the comment is trying to say (and its style is
wrong: missing the opening 'wing').

Quoted 10 lines
xen/include/public/sysctl.h +0 -0
@@ -555,6 +582,8 @@ struct xen_sysctl_cpupool_op {

     uint32_t cpu;         /* IN: AR             */ uint32_t n_dom;       /*            OUT: I  */ struct xenctl_bitmap cpumap; /*     OUT: IF */ +    /* IN: scheduler param relevant for cpupool */ +    xen_sysctl_sched_param_t sched_param; };

For the comment, follow the same convention used for other fields (i.e., for now, 'IN: C').

We will certainly want to be able to also retrieve the scheduler parameter set for a certain pool, at which point this will have to become 'IN: C   OUT: I'... but that's for another patch series, I guess.

Quoted 24 lines

 typedef struct xen_sysctl_cpupool_op xen_sysctl_cpupool_op_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpupool_op_t);

xen/include/public/sysctl.h +0 -0
@@ -630,22 +659,6 @@
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t);
  #define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000
  #define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100

xen/include/public/sysctl.h +0 -8
-struct xen_sysctl_credit_schedule {
-    /* Length of timeslice in milliseconds */
-#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000
-#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1
-    unsigned tslice_ms;
-    unsigned ratelimit_us;
-};
-typedef struct xen_sysctl_credit_schedule

xen_sysctl_credit_schedule_t;

xen/include/public/sysctl.h +0 -6
-DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t);
-
-struct xen_sysctl_credit2_schedule {
-    unsigned ratelimit_us;
-};
-typedef struct xen_sysctl_credit2_schedule

xen_sysctl_credit2_schedule_t;

xen/include/public/sysctl.h DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t); · line 648

Quoted 2 lines
xen/include/public/sysctl.h +0 -2
-DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit2_schedule_t);
-

You're mixing moving and changing code. This is something we prefer to avoid. Please, so the moving in a pre-patch.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw
In reply to anshulmakkar
Quoted 7 lines · anshulmakkar

Attached patch series introduces the concept of runqueue per cpupool.

"runqueue" configuration option can be specified with xl command while configuring cpupool. This will define the basis for grouping of cpus (cpu, core, socket, all) in that cpupool.

Quoted 9 lines

Series is combined of following patches:
[PATCH 1/3]: libxc related changes to add support for runqueue per cpupool [PATCH 2/3]: libxl related changes to add support for runqueue per cpupool [PATCH 3/3]: xen related changes.

On similar lines we can also have runqueue per pool configuration parameter for Credit scheduler. I plan to send a separate patch series for credit specific implementation.

This series won't compile when patch 3 isn't applied.

You need to split patch 3 into two: one patch to extend the hypercall interface which should go in first, and the other part of the hypervisor code being the last patch.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel