Skip to contentSkip to conversation

xl doesn't honour the parameter cpu_weight from my config file while xm does honour it

Xen-users Ian Campbell 4 participants 24 messages Apr 20, 2012 – Apr 25, 2012 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Dieter,

thanks for the report.

It seems that support for this config file variable is not present in xl at the moment. We should try and add this for 4.2 IMHO.

If you know a little bit of C (or are interested in learning) then this should be a pretty simple thing to implement -- please let me know if you want more details.

Ian.

Quoted 47 lines · Dieter Bloms

Hi,

I've installed xen-unstable 4.2 from actual git (last commit was 4dc7dbef5400f0608321d579aebb57f933e8f707).

When I start a domU with xm all is fine include the cpu_weight I configured in my domU config.

When I start the domU with xl then all my domU have the default cpu_weight of 256 instead of the configured one.

Was the name of cpu_weight being changed for xl command ?

My domU config looks like this:

--snip--
name="vdrserver"
description="vdrserver for my clients"
memory=768
maxmem=2048
vcpus=1
cpus="1"
cpu_weight = 128
on_poweroff="destroy"
on_reboot="restart"
on_crash="destroy"

localtime=0
keymap="de"

builder="linux"
bootloader="/usr/bin/pygrub"
bootargs=""
extra="console=hvc0 tmem cgroup_disable=memory independent_wallclock=1 iommu=soft" nographic=1
keymap = 'de'

disk=[
'phy:/dev/mapper/xenimages-vdrserver,xvda1,w', 'phy:/dev/mapper/xenimages-swap_vdrserver,xvda2,w',
]
vif=[ 'mac=00:00:00:00:00:80,bridge=br0', ]

pci = [ '06:00.0', '06:01.0', '00:12.2', '00:13.2'] --snip--

#2 lore raw

Hi,

I'am not a programmer, but will have a look at it the next days and let you know if my skills are good enough.

Quoted 63 lines · Ian Campbell

Hi Dieter,

thanks for the report.

It seems that support for this config file variable is not present in xl at the moment. We should try and add this for 4.2 IMHO.

If you know a little bit of C (or are interested in learning) then this should be a pretty simple thing to implement -- please let me know if you want more details.

Ian.

Quoted 47 lines · Dieter Bloms

Hi,

I've installed xen-unstable 4.2 from actual git (last commit was 4dc7dbef5400f0608321d579aebb57f933e8f707).

When I start a domU with xm all is fine include the cpu_weight I configured in my domU config.

When I start the domU with xl then all my domU have the default cpu_weight of 256 instead of the configured one.

Was the name of cpu_weight being changed for xl command ?

My domU config looks like this:

--snip--
name="vdrserver"
description="vdrserver for my clients"
memory=768
maxmem=2048
vcpus=1
cpus="1"
cpu_weight = 128
on_poweroff="destroy"
on_reboot="restart"
on_crash="destroy"

localtime=0
keymap="de"

builder="linux"
bootloader="/usr/bin/pygrub"
bootargs=""
extra="console=hvc0 tmem cgroup_disable=memory independent_wallclock=1 iommu=soft" nographic=1
keymap = 'de'

disk=[
'phy:/dev/mapper/xenimages-vdrserver,xvda1,w', 'phy:/dev/mapper/xenimages-swap_vdrserver,xvda2,w',
]
vif=[ 'mac=00:00:00:00:00:80,bridge=br0', ]

pci = [ '06:00.0', '06:01.0', '00:12.2', '00:13.2'] --snip--

Signature · 8 lines
Gruß

  Dieter

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

#3 lore raw
In reply to Ian Campbell

Hello Ian,

I've made a little patch to set the cpu_weight for credit, credit2 and sedf scheduler from the config file.

Btw.: for the sedf scheduler there seems to be some type mismatch. The functions xc_sedf_domain_set and xc_sedf_domain_get expect the type 'uint16_t' for variables 'extratime' and 'weight' while the structure 'xen_domctl_sched_sedf' defines the type uint32_t for them. I think they should be the same, or not ?

Anyway, I've tested this patch for the credit scheduler and it works so far.

Quoted 68 lines · Ian Campbell

Hi Dieter,

thanks for the report.

It seems that support for this config file variable is not present in xl at the moment. We should try and add this for 4.2 IMHO.

If you know a little bit of C (or are interested in learning) then this should be a pretty simple thing to implement -- please let me know if you want more details.

Ian.

Quoted 37 lines · Dieter Bloms

Hi,

I've installed xen-unstable 4.2 from actual git (last commit was 4dc7dbef5400f0608321d579aebb57f933e8f707).

When I start a domU with xm all is fine include the cpu_weight I configured in my domU config.

When I start the domU with xl then all my domU have the default cpu_weight of 256 instead of the configured one.

Was the name of cpu_weight being changed for xl command ?

My domU config looks like this:

--snip--
name="vdrserver"
description="vdrserver for my clients"
memory=768
maxmem=2048
vcpus=1
cpus="1"
cpu_weight = 128
on_poweroff="destroy"
on_reboot="restart"
on_crash="destroy"

localtime=0
keymap="de"

builder="linux"
bootloader="/usr/bin/pygrub"
bootargs=""
extra="console=hvc0 tmem cgroup_disable=memory independent_wallclock=1 iommu=soft" nographic=1
keymap = 'de'

Quoted 10 lines

disk=[
'phy:/dev/mapper/xenimages-vdrserver,xvda1,w', 'phy:/dev/mapper/xenimages-swap_vdrserver,xvda2,w',
]
vif=[ 'mac=00:00:00:00:00:80,bridge=br0', ]

pci = [ '06:00.0', '06:01.0', '00:12.2', '00:13.2'] --snip--

_______________________________________________
Xen-users mailing list
[email protected]
http://lists.xen.org/xen-users

Signature · 9 lines
Gruß

  Dieter

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
From field.
tools/libxl/libxl_create.c +4 -0
index e63c7bd..706e282 100644
@@ -110,6 +110,10 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         return ERROR_INVAL;
     }
 
+    if (!b_info->weight)
+        b_info->weight = 256;
+    if (!b_info->cap)
+        b_info->cap = 0;
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
     if (!b_info->cur_vcpus)
tools/libxl/libxl_dom.c +29 -0
index 0bdd654..f858a42 100644
@@ -65,9 +65,38 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int tsc_mode;
     char *xs_domid, *con_domid;
+    libxl_scheduler sched;
+    struct xen_domctl_scheduler_op sched_op;
+
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
     libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus, &info->cpumap);
     xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
+
+    sched = libxl_get_scheduler (ctx);
+    
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      xc_sedf_domain_get (ctx->xch, domid, &(sched_op.u.sedf.period), &(sched_op.u.sedf.slice), &(sched_op.u.sedf.latency), (uint16_t *) &(sched_op.u.sedf.extratime), (uint16_t *) &(sched_op.u.sedf.weight));
+      sched_op.u.sedf.weight = info->weight;
+      xc_sedf_domain_set (ctx->xch, domid, sched_op.u.sedf.period, sched_op.u.sedf.slice, sched_op.u.sedf.latency, (uint16_t) sched_op.u.sedf.extratime, (uint16_t) sched_op.u.sedf.weight);
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+//      struct xen_domctl_sched_credit sdom;
+      sched_op.u.credit.weight = info->weight;
+      sched_op.u.credit.cap = info->cap;
+      xc_sched_credit_domain_set(ctx->xch, domid, &(sched_op.u.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      sched_op.u.credit2.weight = info->weight;
+      xc_sched_credit2_domain_set(ctx->xch, domid, &(sched_op.u.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }
+
     if (info->type == LIBXL_DOMAIN_TYPE_PV)
         xc_domain_set_memmap_limit(ctx->xch, domid,
                 (info->max_memkb + info->u.pv.slack_memkb));
tools/libxl/libxl_types.idl +2 -0
index 5cf9708..f185d4c 100644
@@ -232,6 +232,8 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
 libxl_domain_build_info = Struct("domain_build_info",[
     ("max_vcpus",       integer),
     ("cur_vcpus",       integer),
+    ("weight",          integer),
+    ("cap",             integer),
     ("cpumap",          libxl_cpumap),
     ("tsc_mode",        libxl_tsc_mode),
     ("max_memkb",       MemKB),
tools/libxl/xl_cmdimpl.c +5 -0
index 5703512..d7dcb84 100644
@@ -587,6 +587,11 @@ static void parse_config_data(const char *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in the structures */
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->weight = l;
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->cap = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;

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

#4 lore raw

(xen-users to BCC, this seems like a devel thing for now)

Quoted 4 lines · Dieter Bloms

Hello Ian,

I've made a little patch to set the cpu_weight for credit, credit2 and sedf scheduler from the config file.

Awesome, thank you!

Quoted 5 lines

Btw.: for the sedf scheduler there seems to be some type mismatch. The functions xc_sedf_domain_set and xc_sedf_domain_get expect the type 'uint16_t' for variables 'extratime' and 'weight' while the structure 'xen_domctl_sched_sedf' defines the type uint32_t for them. I think they should be the same, or not ?

I'm not clear enough on the scheduling stuff to be able to say one way or another. I'd be inclined to suggest that if this needs to change for some reason then we should leave it for post 4.2.

Quoted 2 lines

Anyway, I've tested this patch for the credit scheduler and it works so far.

Cool. One thing which we need in order to able to apply a patch is a "Signed-off-by" per the DCO as described in
http://wiki.xen.org/wiki/SubmittingXenPatches.

I've also a few minor comments on the patch itself below.

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc · line 115

Quoted 11 lines
tools/libxl/libxl_create.c +2 -0
index e63c7bd..706e282 100644
@@ -110,6 +110,10 @@ int libxl__domain_build_info_setdefault(libxl__gc
 *gc,
         return ERROR_INVAL;
     }
 
+    if (!b_info->weight)
+        b_info->weight = 256;

I suppose that weight=0 does not make sense and therefore 0 is available as a discriminating value meaning "the default".

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 116

Quoted 2 lines
tools/libxl/libxl_create.c +2 -0
+    if (!b_info->cap)
+        b_info->cap = 0;

!b_info->cap means that b_info_cap is already 0, although I guess this serves as a more explicit indication of the default.

Quoted 29 lines
tools/libxl/libxl_create.c +0 -0
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
     if (!b_info->cur_vcpus)
tools/libxl/libxl_dom.c +9 -0
index 0bdd654..f858a42 100644
@@ -65,9 +65,38 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int tsc_mode;
     char *xs_domid, *con_domid;
+    libxl_scheduler sched;
+    struct xen_domctl_scheduler_op sched_op;
+
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
     libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus,
 &info->cpumap);
     xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
 LIBXL_MAXMEM_CONSTANT);
+
+    sched = libxl_get_scheduler (ctx);
+    
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      xc_sedf_domain_get (ctx->xch, domid, &(sched_op.u.sedf.period),
 &(sched_op.u.sedf.slice), &(sched_op.u.sedf.latency), (uint16_t *)

&(sched_op.u.sedf.extratime), (uint16_t *) &(sched_op.u.sedf.weight));

tools/libxl/libxl_dom.c +2 -0
+      sched_op.u.sedf.weight = info->weight;
+      xc_sedf_domain_set (ctx->xch, domid, sched_op.u.sedf.period,
Quoted 2 lines

sched_op.u.sedf.slice, sched_op.u.sedf.latency, (uint16_t) sched_op.u.sedf.extratime, (uint16_t) sched_op.u.sedf.weight);

Wow, that's a pretty sucky interface at the libxc level! Anyway no need for you to fix it here but please do wrap your lines to <80 columns for readability.

tools/libxl/libxl_dom.c int libxl__build_pre(libxl__gc *gc, uint32_t domid, · line 84

Quoted 3 lines
tools/libxl/libxl_dom.c +3 -0
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+//      struct xen_domctl_sched_credit sdom;

Please don't leave commented out code in place.

Quoted 25 lines
tools/libxl/libxl_dom.c +3 -0
+      sched_op.u.credit.weight = info->weight;
+      sched_op.u.credit.cap = info->cap;
+      xc_sched_credit_domain_set(ctx->xch, domid,

&(sched_op.u.credit));

tools/libxl/libxl_dom.c +4 -0
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      sched_op.u.credit2.weight = info->weight;
+      xc_sched_credit2_domain_set(ctx->xch, domid,

&(sched_op.u.credit2));

tools/libxl/libxl_dom.c +8 -0
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }
+
     if (info->type == LIBXL_DOMAIN_TYPE_PV)
         xc_domain_set_memmap_limit(ctx->xch, domid,
                 (info->max_memkb + info->u.pv.slack_memkb));
tools/libxl/libxl_types.idl +0 -0
index 5cf9708..f185d4c 100644

tools/libxl/libxl_types.idl MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT") · line 236

Quoted 5 lines
tools/libxl/libxl_types.idl +2 -0
@@ -232,6 +232,8 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
 libxl_domain_build_info = Struct("domain_build_info",[
     ("max_vcpus",       integer),
     ("cur_vcpus",       integer),
+    ("weight",          integer),
+    ("cap",             integer),

Are these values common parameters to all schedulers? Do they always have the same meaning/units/etc?

I wonder if perhaps including each of libxl_sched_*_params in build_info might be a preferable interface? I would probably cleanup the above code in build_pre too since you could just call the appropriate libxl_sched_*_params_set.

Ideally libxl_sched_*_params would be in a union in libxl_domain_build_info but that would require that xl could easily determine which scheduler was going to be used for the domain, having a non-union here would keep things somewhat simpler from that PoV.

I've CC'd George and Dario for their thoughts on this interface. We should try and keep it simple so that we can get this into 4.2.

Quoted 21 lines
tools/libxl/libxl_types.idl +0 -0
     ("cpumap",          libxl_cpumap),
     ("tsc_mode",        libxl_tsc_mode),
     ("max_memkb",       MemKB),
tools/libxl/xl_cmdimpl.c +0 -0
index 5703512..d7dcb84 100644
@@ -587,6 +587,11 @@ static void parse_config_data(const char
 *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding

values in the structures */

tools/libxl/xl_cmdimpl.c +5 -0
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->weight = l;
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->cap = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;
#5 lore raw
Quoted 5 lines · Ian Campbell
Quoted 2 lines

I've made a little patch to set the cpu_weight for credit, credit2 and sedf scheduler from the config file.

Awesome, thank you!

Agreed, nice work and thank you for doing it!

Quoted 10 lines
Quoted 5 lines

Btw.: for the sedf scheduler there seems to be some type mismatch. The functions xc_sedf_domain_set and xc_sedf_domain_get expect the type 'uint16_t' for variables 'extratime' and 'weight' while the structure 'xen_domctl_sched_sedf' defines the type uint32_t for them. I think they should be the same, or not ?

I'm not clear enough on the scheduling stuff to be able to say one way or another. I'd be inclined to suggest that if this needs to change for some reason then we should leave it for post 4.2.

In Xen's SEDF code weight is a 'short', while extratime is nothing more than a boolean flag (it can store only the EXTRA_AWARE flag). So I think it would be worth looking at this, but I agree we ca defer that for now, especially considering the whole SEDF interface might need some restructuring! :-/

Quoted 18 lines
Quoted 15 lines
     xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);
     libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus,
&info->cpumap);
     xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +

LIBXL_MAXMEM_CONSTANT);

tools/libxl/libxl_dom.c +6 -0
+
+    sched = libxl_get_scheduler (ctx);
+    
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      xc_sedf_domain_get (ctx->xch, domid, &(sched_op.u.sedf.period),

&(sched_op.u.sedf.slice), &(sched_op.u.sedf.latency), (uint16_t *) &(sched_op.u.sedf.extratime), (uint16_t *) &(sched_op.u.sedf.weight));

(quoted diff) +2 -0
+      sched_op.u.sedf.weight = info->weight;
+      xc_sedf_domain_set (ctx->xch, domid, sched_op.u.sedf.period,
Quoted 2 lines

sched_op.u.sedf.slice, sched_op.u.sedf.latency, (uint16_t) sched_op.u.sedf.extratime, (uint16_t) sched_op.u.sedf.weight);

Quoted 4 lines

Wow, that's a pretty sucky interface at the libxc level! Anyway no need for you to fix it here but please do wrap your lines to <80 columns for readability.

Indeed! I really think we have to do something about this, but that definitely will happen post-release. :-)

Quoted 5 lines
Quoted 5 lines
tools/libxl/libxl_types.idl +0 -0
index 5cf9708..f185d4c 100644
@@ -232,6 +232,8 @@ MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
Quoted 9 lines

tools/libxl/libxl_types.idl MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT") · line 236

Quoted 5 lines
tools/libxl/libxl_types.idl +2 -0
 libxl_domain_build_info = Struct("domain_build_info",[
     ("max_vcpus",       integer),
     ("cur_vcpus",       integer),
+    ("weight",          integer),
+    ("cap",             integer),

Are these values common parameters to all schedulers? Do they always have the same meaning/units/etc?

Maybe weight is, but still, I think having some mechanism for specifying the full set of parameter of a specific scheduler is to be preferred...

Quoted 5 lines

I wonder if perhaps including each of libxl_sched_*_params in build_info might be a preferable interface? I would probably cleanup the above code in build_pre too since you could just call the appropriate libxl_sched_*_params_set.

... Exactly, that's much better looking to me.

Quoted 5 lines

Ideally libxl_sched_*_params would be in a union in libxl_domain_build_info but that would require that xl could easily determine which scheduler was going to be used for the domain, having a non-union here would keep things somewhat simpler from that PoV.

Yes, again, I agree that a union will be even better, but maybe not so much a big deal for now (we can turn it into an union later, right? Or you think there will be some API implications?)

Regards,
Dario

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

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

#6 lore raw

Hi,

Quoted 9 lines

Maybe weight is, but still, I think having some mechanism for specifying the full set of parameter of a specific scheduler is to be preferred...

Quoted 5 lines

I wonder if perhaps including each of libxl_sched_*_params in build_info might be a preferable interface? I would probably cleanup the above code in build_pre too since you could just call the appropriate libxl_sched_*_params_set.

... Exactly, that's much better looking to me.

that's a good hint.

Quoted 8 lines
Quoted 5 lines

Ideally libxl_sched_*_params would be in a union in libxl_domain_build_info but that would require that xl could easily determine which scheduler was going to be used for the domain, having a non-union here would keep things somewhat simpler from that PoV.

Yes, again, I agree that a union will be even better, but maybe not so much a big deal for now (we can turn it into an union later, right? Or you think there will be some API implications?)

ok, I see the point and will change it to a union.
I checked out the source with git not hg, may I produce a diff with git and send it via mail ?

Signature · 8 lines
Best regards

  Dieter Bloms

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

#7 lore raw
Quoted 2 lines · Dieter Bloms

ok, I see the point and will change it to a union.

Cool!

Quoted 3 lines

I checked out the source with git not hg, may I produce a diff with git and send it via mail ?

I think you should. Either use something automatic like git `send-email' or just produce the diff and then inline or attach, following also the other instructions Ian pointed you to (on the wiki)... Was it this you were asking?

Regads,
Dario

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

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

#8 lore raw

Hi,

Quoted 7 lines · Dario Faggioli
Quoted 3 lines

I checked out the source with git not hg, may I produce a diff with git and send it via mail ?

I think you should. Either use something automatic like git `send-email' or just produce the diff and then inline or attach, following also the other instructions Ian pointed you to (on the wiki)... Was it this you were asking?

yes.

ok, second try ;)
I hope this fit more your needs.

I've defined a new union in the libxl_domain_build_info structure. For this I had to move some structure definition like libxl_sched_credit_domain more to the top.
I named the union 'us' for union scheduler, because the letter 'u' was already used for the type of domain.

Signature · 9 lines
Best regards

  Dieter Bloms

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
From field.

libxl: set domain scheduling parameters while creating the dom

the domain specific scheduling parameters like cpu_weight, cap, slice, ... will be set during creating the domain, so this parameters can be defined in the domain config file

tools/libxl/libxl_dom.c +19 -0
index 0bdd654..38acff4 100644
@@ -124,8 +124,27 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
     char *dom_path, *vm_path;
     xs_transaction_t t;
     char **ents, **hvm_ents;
+    libxl_scheduler sched;
     int i;
 
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      libxl_sched_credit2_domain_set(ctx, domid, &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }
+
     libxl_cpuid_apply_policy(ctx, domid);
     if (info->cpuid != NULL)
         libxl_cpuid_set(ctx, domid, info->cpuid);
tools/libxl/libxl_types.idl +28 -16

68 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +17 -0
index 5703512..db51ca6 100644
@@ -587,6 +587,23 @@ static void parse_config_data(const char *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in the structures */
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->us.credit.weight = l;
+        b_info->us.credit2.weight = l;
+        b_info->us.sedf.weight = l;
+
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->us.credit.cap = l;
+
+    if (!xlu_cfg_get_long (config, "period", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "latency", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "extratime", &l, 0))
+        b_info->us.sedf.period = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;

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

#9 lore raw
Quoted 3 lines · Dieter Bloms

ok, second try ;)
I hope this fit more your needs.

This really looks much better to me!

Quoted 4 lines

I've defined a new union in the libxl_domain_build_info structure. For this I had to move some structure definition like libxl_sched_credit_domain more to the top.

That's fine.

What might be missing is some documentation in docs/man/xl.cfg.pod.5, explaining about the new options... :-)

Thanks and Regards,
Dario

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

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

#10 lore raw

Hi,

Quoted 2 lines · Dario Faggioli

What might be missing is some documentation in docs/man/xl.cfg.pod.5, explaining about the new options... :-)

I've added a little documentation, so now I hope it is ok.

Signature · 8 lines
best regards

  Dieter Bloms

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

libxl: set domain scheduling parameters while creating the dom

the domain specific scheduling parameters like cpu_weight, cap, slice, ... will be set during creating the domain, so this parameters can be defined in the domain config file

docs/man/xl.cfg.pod.5 +38 -0
index e2cd251..4060933 100644
@@ -112,6 +112,44 @@ List of which cpus the guest is allowed to use. Default behavior is
 (all vcpus will run on cpus 0,2,3,5), or `cpus=["2", "3"]` (all vcpus
 will run on cpus 2 and 3).
 
+=item B<cpu-weight="weight of cpu (default 256)">
+
+A domain with a weight of 512 will get twice as much CPU as a domain
+with a weight of 256 on a contended host.
+Legal weights range from 1 to 65535 and the default is 256.
+Can be set for credit, credit2 and sedf scheduler.
+
+=item B<cap="max amount of cpu (default 0)">
+
+The cap optionally fixes the maximum amount of CPU a domain will be
+able to consume, even if the host system has idle CPU cycles.
+The cap is expressed in percentage of one physical CPU:
+100 is 1 physical CPU, 50 is half a CPU, 400 is 4 CPUs, etc.
+The default, 0, means there is no upper cap.
+Can be set for the credit and credit2 scheduler.
+
+=item B<period="time in nanoseconds (default 0)">
+
+The normal EDF scheduling usage in nanoseconds. This means every period
+the domain gets cpu time defined in slice.
+Can be set for sedf scheduler.
+
+=item B<slice="time in nanoseconds (default 0)">
+
+The normal EDF scheduling usage in nanoseconds. it defines the time 
+a domain get every period time.
+Can be set for sedf scheduler.
+
+=item B<latency=" (default 0)">
+
+Scaled period if domain is doing heavy I/O.
+Can be set for sedf scheduler.
+
+=item B<extratime="BOOLEAN (default 0)">
+
+Flag for allowing domain to run in extra time.
+Can be set for sedf scheduler.
+
 =item B<memory=MBYTES>
 
 Start the guest with MBYTES megabytes of RAM.
tools/libxl/libxl_dom.c +19 -0
index 0bdd654..38acff4 100644
@@ -124,8 +124,27 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
     char *dom_path, *vm_path;
     xs_transaction_t t;
     char **ents, **hvm_ents;
+    libxl_scheduler sched;
     int i;
 
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      libxl_sched_credit2_domain_set(ctx, domid, &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }
+
     libxl_cpuid_apply_policy(ctx, domid);
     if (info->cpuid != NULL)
         libxl_cpuid_set(ctx, domid, info->cpuid);
tools/libxl/libxl_types.idl +28 -16

68 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +17 -0
index 5703512..db51ca6 100644
@@ -587,6 +587,23 @@ static void parse_config_data(const char *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in the structures */
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->us.credit.weight = l;
+        b_info->us.credit2.weight = l;
+        b_info->us.sedf.weight = l;
+
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->us.credit.cap = l;
+
+    if (!xlu_cfg_get_long (config, "period", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "latency", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "extratime", &l, 0))
+        b_info->us.sedf.period = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;

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

#11 lore raw
Quoted 19 lines · Dieter Bloms

libxl: set domain scheduling parameters while creating the dom

the domain specific scheduling parameters like cpu_weight, cap, slice, ...
will be set during creating the domain, so this parameters can be defined
in the domain config file

docs/man/xl.cfg.pod.5 +0 -0
index e2cd251..4060933 100644
@@ -112,6 +112,44 @@ List of which cpus the guest is allowed to use.

Default behavior is
(all vcpus will run on cpus 0,2,3,5), or cpus=["2", "3"] (all vcpus will run on cpus 2 and 3).

Quoted 1 line

+=item B<cpu-weight="weight of cpu (default 256)">

I think you mean cpu_weight rather than cpu-weight.

The typography in this file isn't exactly strict but it seems that we normally put the default in the text rather than in the header and use a SHOUTY name for the value. e.g.

=item B<cpu_weight=WEIGHT>

Specifies the weight of the domain. A domain with a weight of 512 will get twice as much CPU as a domain with a weight of 256 on a contended host. Legal weights range from 1 to 65535 and the default is 256. Can be set for credit, credit2 and sedf scheduler.

This also avoids the ambiguous use of " in the title, since depending on the item the quotes may be a required part of the syntax but not in this case.

[...]

Quoted 1 line

+=item B<latency=" (default 0)">

=item B<latency=N>

I think you missed the value here.

[...]

Quoted 73 lines
tools/libxl/libxl_dom.c +19 -0
index 0bdd654..38acff4 100644
@@ -124,8 +124,27 @@ int libxl__build_post(libxl__gc *gc, uint32_t
 domid,
     char *dom_path, *vm_path;
     xs_transaction_t t;
     char **ents, **hvm_ents;
+    libxl_scheduler sched;
     int i;
 
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      libxl_sched_credit2_domain_set(ctx, domid,
 &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }
+
     libxl_cpuid_apply_policy(ctx, domid);
     if (info->cpuid != NULL)
         libxl_cpuid_set(ctx, domid, info->cpuid);
tools/libxl/libxl_types.idl +0 -0
index 5cf9708..c1cdc3c 100644
@@ -224,6 +224,27 @@ libxl_domain_create_info =

Struct("domain_create_info",[

MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")

tools/libxl/libxl_types.idl +21 -0
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),
+    ("cap", integer),
+    ])
+
+libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
+    ("weight", integer),
+    ])
+
+libxl_sched_sedf_domain = Struct("sched_sedf_domain", [
+    ("period", integer),
+    ("slice", integer),
+    ("latency", integer),
+    ("extratime", integer),
+    ("weight", integer),
+    ])
+
+libxl_sched_arinc653_domain = Struct("sched_arinc653_domain", [
+    ("weight", integer),
+    ])
+
 # Instances of libxl_file_reference contained in this struct which
 # have been mapped (with libxl_file_reference_map) will be unmapped
 # by libxl_domain_build/restore. If either of these are never called
@@ -256,6 +277,13 @@ libxl_domain_build_info =

Struct("domain_build_info",[

     # extra parameters pass directly to qemu for HVM guest, NULL
terminated
     ("extra_hvm",        libxl_string_list),

tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 285

Quoted 6 lines
tools/libxl/libxl_types.idl +6 -0
+    ("us", KeyedUnion(None, libxl_scheduler, "sched",
+                 [("credit", libxl_sched_credit_domain),
+                 ("credit2", libxl_sched_credit2_domain),
+                 ("sedf", libxl_sched_sedf_domain),
+                 ("arinc653", libxl_sched_arinc653_domain),
+                 ], keyvar_init_val = "-1")),

I don't think a KeyedUnion is right here, since the user of libxl doesn't really have a choice about which scheduler is in user (that's set at boot time or via cpupool interfaces).

You could use a Union, but below I'll make an argument that perhaps a Struct would be better.

[...]

Quoted 10 lines
tools/libxl/xl_cmdimpl.c +0 -0
index 5703512..db51ca6 100644
@@ -587,6 +587,23 @@ static void parse_config_data(const char
 *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding

values in the structures */

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char *configfile_filename_report, · line 593

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +4 -0
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->us.credit.weight = l;
+        b_info->us.credit2.weight = l;
+        b_info->us.sedf.weight = l;

You need {} here otherwise only the credit setting is associated with the if.

However, since b_info->us is a union this is actually setting the same value into different places in overlapping memory (since all member of a union occupy the same storage). One solution would be to use libxl_get_scheduler to get the scheduler and fill in only the correct option, but then that gets complex when you have to deal with cpupools etc.

I think you should make "us" a Struct and call it sched_params or something along those lines. It's just simpler all around, libxl can internally figure out which set of parms to use (as you do correctly in this patch).

Does the above make sense?

Ian.

Quoted 16 lines
tools/libxl/xl_cmdimpl.c +12 -0
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->us.credit.cap = l;
+
+    if (!xlu_cfg_get_long (config, "period", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "latency", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "extratime", &l, 0))
+        b_info->us.sedf.period = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;
#22 lore raw
In reply to Dieter Bloms

Dieter Bloms writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 5 lines · Dario Faggioli
Quoted 2 lines

What might be missing is some documentation in docs/man/xl.cfg.pod.5, explaining about the new options... :-)

I've added a little documentation, so now I hope it is ok.

This is better, thanks. I have some comments.

Quoted 1 line

+=item B<cpu-weight="weight of cpu (default 256)">

I'm not qualified to review the documented semantics here.

Quoted 12 lines
tools/libxl/libxl_dom.c +7 -0
index 0bdd654..38acff4 100644
@@ -124,8 +124,27 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));

tools/libxl/libxl_dom.c int libxl__build_post(libxl__gc *gc, uint32_t domid, · line 140

Quoted 10 lines
tools/libxl/libxl_dom.c +10 -0
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      libxl_sched_credit2_domain_set(ctx, domid, &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }

This is a very repetitive piece of code. Can't it be autogenerated somehow by the idl compiler ? Ian C ?

Also, we use 4-character indents and you have used 2. (If this were the only thing that needed changing I would fix it when I committed.)

tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 227

Quoted 9 lines
tools/libxl/libxl_types.idl +4 -0
index 5cf9708..c1cdc3c 100644
@@ -224,6 +224,27 @@ libxl_domain_create_info = Struct("domain_create_info",[
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),
+    ("cap", integer),
+    ])

You seem to have just moved many of these about ? That's just because the idl file doesn't support forward declarations, right ?

Thanks,
Ian.

#23 lore raw
Quoted 30 lines · Ian Jackson

Dieter Bloms writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 5 lines · Dario Faggioli
Quoted 2 lines

What might be missing is some documentation in docs/man/xl.cfg.pod.5, explaining about the new options... :-)

I've added a little documentation, so now I hope it is ok.

This is better, thanks. I have some comments.

Quoted 1 line

+=item B<cpu-weight="weight of cpu (default 256)">

I'm not qualified to review the documented semantics here.

Quoted 17 lines
tools/libxl/libxl_dom.c +12 -0
index 0bdd654..38acff4 100644
@@ -124,8 +124,27 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      libxl_sched_credit2_domain_set(ctx, domid, &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
Quoted 8 lines

tools/libxl/libxl_dom.c int libxl__build_post(libxl__gc *gc, uint32_t domid, · line 146

Quoted 5 lines
tools/libxl/libxl_dom.c +5 -0
+      /* not implemented */
+      break;
+    default:
+        abort();
+    }

This is a very repetitive piece of code. Can't it be autogenerated somehow by the idl compiler ? Ian C ?

Not without a bunch more plumbing in the infrastructure, which would probably heavily outweigh the code here...

A compromise might be to make this a libxl__sched_set_params(gc, domid, &info->us), so at least it wouldn't be repeated again somewhere.

Quoted 14 lines

Also, we use 4-character indents and you have used 2. (If this were the only thing that needed changing I would fix it when I committed.)

tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 227

Quoted 9 lines
tools/libxl/libxl_types.idl +4 -0
index 5cf9708..c1cdc3c 100644
@@ -224,6 +224,27 @@ libxl_domain_create_info = Struct("domain_create_info",[
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),
+    ("cap", integer),
+    ])

You seem to have just moved many of these about ?

I think he said as much in his commit message? Oh, it was actually in the comment of hte previous posting:

Quoted 10 lines

I've defined a new union in the libxl_domain_build_info structure. For this I had to move some structure definition like libxl_sched_credit_domain more to the top.

That's just because
the idl file doesn't support forward declarations, right ?

Thanks,
Ian.

#24 lore raw

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 6 lines · Ian Jackson
Quoted 2 lines

This is a very repetitive piece of code. Can't it be autogenerated somehow by the idl compiler ? Ian C ?

Not without a bunch more plumbing in the infrastructure, which would probably heavily outweigh the code here...

Fair enough.

Quoted 2 lines

A compromise might be to make this a libxl__sched_set_params(gc, domid, &info->us), so at least it wouldn't be repeated again somewhere.

That would be nice but I wouldn't insist on it until it was necessary to avoid a second copy.

Ian.

#12 lore raw
In reply to Ian Campbell

Hi,

Quoted 1 line · Ian Campbell

I think you mean cpu_weight rather than cpu-weight.

yes of course, fixed.

Quoted 3 lines

=item B<latency=N>

I think you missed the value here.

I don't know the value for it, so I added N as you suggested.

Quoted 7 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+    ("us", KeyedUnion(None, libxl_scheduler, "sched",
+                 [("credit", libxl_sched_credit_domain),
+                 ("credit2", libxl_sched_credit2_domain),
+                 ("sedf", libxl_sched_sedf_domain),
+                 ("arinc653", libxl_sched_arinc653_domain),
+                 ], keyvar_init_val = "-1")),
Quoted 6 lines

I don't think a KeyedUnion is right here, since the user of libxl doesn't really have a choice about which scheduler is in user (that's set at boot time or via cpupool interfaces).

You could use a Union, but below I'll make an argument that perhaps a Struct would be better.

Hm, but when I don't use a union with the structure for each scheduler I have to create a structure depend of scheduler at runtime, because the functions libxl_sched_XXXXXX_domain_set use there own structure for their scheduler.

I've create a new function libxl__sched_set_params, which set the params depend on the scheduler as you suggested.

I'am not a software developer, so please be forbear with me.

Here my next try.

Signature · 9 lines
Best regards

  Dieter

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
From field.

libxl: set domain scheduling parameters while creating the dom

the domain specific scheduling parameters like cpu_weight, cap, slice, ... will be set during creating the domain, so this parameters can be defined in the domain config file

docs/man/xl.cfg.pod.5 +38 -0
index e2cd251..b0c8064 100644
@@ -112,6 +112,44 @@ List of which cpus the guest is allowed to use. Default behavior is
 (all vcpus will run on cpus 0,2,3,5), or `cpus=["2", "3"]` (all vcpus
 will run on cpus 2 and 3).
 
+=item B<cpu_weight=WEIGHT>
+
+A domain with a weight of 512 will get twice as much CPU as a domain
+with a weight of 256 on a contended host.
+Legal weights range from 1 to 65535 and the default is 256.
+Can be set for credit, credit2 and sedf scheduler.
+
+=item B<cap=N>
+
+The cap optionally fixes the maximum amount of CPU a domain will be
+able to consume, even if the host system has idle CPU cycles.
+The cap is expressed in percentage of one physical CPU:
+100 is 1 physical CPU, 50 is half a CPU, 400 is 4 CPUs, etc.
+The default, 0, means there is no upper cap.
+Can be set for the credit and credit2 scheduler.
+
+=item B<period=NANOSECONDS>
+
+The normal EDF scheduling usage in nanoseconds. This means every period
+the domain gets cpu time defined in slice.
+Can be set for sedf scheduler.
+
+=item B<slice=NANOSECONDS>
+
+The normal EDF scheduling usage in nanoseconds. it defines the time 
+a domain get every period time.
+Can be set for sedf scheduler.
+
+=item B<latency=N>
+
+Scaled period if domain is doing heavy I/O.
+Can be set for sedf scheduler.
+
+=item B<extratime=BOOLEAN>
+
+Flag for allowing domain to run in extra time.
+Can be set for sedf scheduler.
+
 =item B<memory=MBYTES>
 
 Start the guest with MBYTES megabytes of RAM.
tools/libxl/libxl_dom.c +29 -0
index 0bdd654..654da78 100644
@@ -42,6 +42,33 @@ libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid)
         return LIBXL_DOMAIN_TYPE_PV;
 }
 
+int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info)
+{
+    libxl_ctx *ctx = libxl__gc_owner(gc);
+    libxl_scheduler sched;
+    int ret;
+
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      ret=libxl_sched_sedf_domain_set(ctx, domid, &(info->us.sedf));
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      ret=libxl_sched_credit_domain_set(ctx, domid, &(info->us.credit));
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      ret=libxl_sched_credit2_domain_set(ctx, domid, &(info->us.credit2));
+      break;
+    case LIBXL_SCHEDULER_ARINC653:
+      /* not implemented */
+      ret=0;
+      break;
+    default:
+      ret=-1;
+    }
+    return ret;
+}
+
 int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -126,6 +153,8 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
     char **ents, **hvm_ents;
     int i;
 
+    libxl__sched_set_params (gc, domid, info);
+
     libxl_cpuid_apply_policy(ctx, domid);
     if (info->cpuid != NULL)
         libxl_cpuid_set(ctx, domid, info->cpuid);
tools/libxl/libxl_internal.h +1 -0
index a4b933b..bfcdff4 100644
@@ -617,6 +617,7 @@ int libxl__atfork_init(libxl_ctx *ctx);
 /* from xl_dom */
 _hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
+_hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \
     libxl__domain_type((gc), (domid)) == LIBXL_DOMAIN_TYPE_##type
 typedef struct {
tools/libxl/libxl_types.idl +28 -16

68 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +18 -0
index 5703512..811f1ac 100644
@@ -587,6 +587,24 @@ static void parse_config_data(const char *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in the structures */
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0)) {
+        b_info->us.credit.weight = l;
+        b_info->us.credit2.weight = l;
+        b_info->us.sedf.weight = l;
+    }
+
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->us.credit.cap = l;
+
+    if (!xlu_cfg_get_long (config, "period", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "latency", &l, 0))
+        b_info->us.sedf.period = l;
+    if (!xlu_cfg_get_long (config, "extratime", &l, 0))
+        b_info->us.sedf.period = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;

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

#13 lore raw
Quoted 25 lines · Dieter Bloms

Hi,

Quoted 1 line · Ian Campbell

I think you mean cpu_weight rather than cpu-weight.

yes of course, fixed.

Quoted 3 lines

=item B<latency=N>

I think you missed the value here.

I don't know the value for it, so I added N as you suggested.

Quoted 11 lines

tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[ · line 285

Quoted 6 lines
tools/libxl/libxl_types.idl +6 -0
+    ("us", KeyedUnion(None, libxl_scheduler, "sched",
+                 [("credit", libxl_sched_credit_domain),
+                 ("credit2", libxl_sched_credit2_domain),
+                 ("sedf", libxl_sched_sedf_domain),
+                 ("arinc653", libxl_sched_arinc653_domain),
+                 ], keyvar_init_val = "-1")),

I don't think a KeyedUnion is right here, since the user of libxl doesn't really have a choice about which scheduler is in user (that's set at boot time or via cpupool interfaces).

Quoted 7 lines
Quoted 2 lines

You could use a Union, but below I'll make an argument that perhaps a Struct would be better.

Hm, but when I don't use a union with the structure for each scheduler I have to create a structure depend of scheduler at runtime, because the functions libxl_sched_XXXXXX_domain_set use there own structure for their scheduler.

I mean create a single struct with all of the options in it, from which libxl will select the appropriate set of parameters (much like the code you have now does. You don't need to decide the content of that struct at runtime.

The IDL patch is below, other than changing "us" to "sched_params" I think most of the rest of your patch remains the same.

Quoted 4 lines

I've create a new function libxl__sched_set_params, which set the params depend on the scheduler as you suggested.

I'am not a software developer, so please be forbear with me.

That's ok, thanks for doing this!

You add a struct for arinc635 but don't actually do anything with it, you may as well leave it out for now?

Ian.

#14 lore raw

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 7 lines

I mean create a single struct with all of the options in it, from which libxl will select the appropriate set of parameters (much like the code you have now does. You don't need to decide the content of that struct at runtime.

The IDL patch is below, other than changing "us" to "sched_params" I think most of the rest of your patch remains the same.

Missing attachment ?

Ian.

#15 lore raw
Quoted 10 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 7 lines

I mean create a single struct with all of the options in it, from which libxl will select the appropriate set of parameters (much like the code you have now does. You don't need to decide the content of that struct at runtime.

The IDL patch is below, other than changing "us" to "sched_params" I think most of the rest of your patch remains the same.

Missing attachment ?

Yes, sorry.

Here it is:

tools/libxl/libxl_types.idl +32 -22
diff -r aef90d90eb3b tools/libxl/libxl_types.idl
@@ -224,6 +224,32 @@ libxl_domain_create_info = Struct("domai
 
 MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
 
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),
+    ("cap", integer),
+    ])
+
+libxl_sched_credit_params = Struct("sched_credit_params", [
+    ("tslice_ms", integer),
+    ("ratelimit_us", integer),
+    ], dispose_fn=None)
+
+libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
+    ("weight", integer),
+    ])
+
+libxl_sched_sedf_domain = Struct("sched_sedf_domain", [
+    ("period", integer),
+    ("slice", integer),
+    ("latency", integer),
+    ("extratime", integer),
+    ("weight", integer),
+    ])
+
+libxl_sched_arinc653_domain = Struct("sched_arinc653_domain", [
+    ("weight", integer),
+    ])
+
 # Instances of libxl_file_reference contained in this struct which
 # have been mapped (with libxl_file_reference_map) will be unmapped
 # by libxl_domain_build/restore. If either of these are never called
@@ -256,6 +282,12 @@ libxl_domain_build_info = Struct("domain
     # extra parameters pass directly to qemu for HVM guest, NULL terminated
     ("extra_hvm",        libxl_string_list),
 
+    ("sched_params",     Struct(None, [("credit", libxl_sched_credit_domain),
+                                       ("credit2", libxl_sched_credit2_domain),
+                                       ("sedf", libxl_sched_sedf_domain),
+                                       ("arinc653", libxl_sched_arinc653_domain),
+                                       ]))
+    ,    
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware",         string),
                                        ("bios",             libxl_bios_type),
@@ -417,28 +449,6 @@ libxl_cputopology = Struct("cputopology"
     ("node", uint32),
     ], dir=DIR_OUT)
 
-libxl_sched_credit_domain = Struct("sched_credit_domain", [
-    ("weight", integer),
-    ("cap", integer),
-    ])
-
-libxl_sched_credit_params = Struct("sched_credit_params", [
-    ("tslice_ms", integer),
-    ("ratelimit_us", integer),
-    ], dispose_fn=None)
-
-libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
-    ("weight", integer),
-    ])
-
-libxl_sched_sedf_domain = Struct("sched_sedf_domain", [
-    ("period", integer),
-    ("slice", integer),
-    ("latency", integer),
-    ("extratime", integer),
-    ("weight", integer),
-    ])
-
 libxl_event_type = Enumeration("event_type", [
     (1, "DOMAIN_SHUTDOWN"),
     (2, "DOMAIN_DEATH"),
#16 lore raw

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 3 lines

diff -r aef90d90eb3b tools/libxl/libxl_types.idl

tools/libxl/libxl_types.idl +0 -0

...

Quoted 2 lines
tools/libxl/libxl_types.idl +2 -0
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),

...
...

Quoted 2 lines
tools/libxl/libxl_types.idl +2 -0
+libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
+    ("weight", integer),

...

Quoted 1 line

+libxl_sched_sedf_domain = Struct("sched_sedf_domain", [

...

Quoted 6 lines
tools/libxl/libxl_types.idl +6 -0
+    ("weight", integer),
+    ])
+
+libxl_sched_arinc653_domain = Struct("sched_arinc653_domain", [
+    ("weight", integer),
+    ])

...

tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain · line 289

Quoted 5 lines
tools/libxl/libxl_types.idl +5 -0
+    ("sched_params",     Struct(None, [("credit", libxl_sched_credit_domain),
+                                       ("credit2", libxl_sched_credit2_domain),
+                                       ("sedf", libxl_sched_sedf_domain),
+                                       ("arinc653", libxl_sched_arinc653_domain),
+                                       ]))

The resulting sched_params structure contains four subfields called "weight", all of which mean (roughly, obviously) the same thing and all of which are to be set from the same "weight" xl configuration parameter. Is this really the most sensible way to do things ?

Perhaps it would be better to have a single sched_params struct which contained all the parameters needed for any scheduler, and simply have them ignored by libxl for schedulers we're not using.

Ian.

#17 lore raw
Quoted 27 lines · Ian Jackson

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 3 lines

diff -r aef90d90eb3b tools/libxl/libxl_types.idl

tools/libxl/libxl_types.idl +0 -0

...

Quoted 2 lines
tools/libxl/libxl_types.idl +2 -0
+libxl_sched_credit_domain = Struct("sched_credit_domain", [
+    ("weight", integer),

...
...

Quoted 2 lines
tools/libxl/libxl_types.idl +2 -0
+libxl_sched_credit2_domain = Struct("sched_credit2_domain", [
+    ("weight", integer),

...

Quoted 1 line

+libxl_sched_sedf_domain = Struct("sched_sedf_domain", [

...

Quoted 6 lines
tools/libxl/libxl_types.idl +6 -0
+    ("weight", integer),
+    ])
+
+libxl_sched_arinc653_domain = Struct("sched_arinc653_domain", [
+    ("weight", integer),
+    ])

...

tools/libxl/libxl_types.idl libxl_domain_build_info = Struct("domain · line 289

Quoted 5 lines
tools/libxl/libxl_types.idl +5 -0
+    ("sched_params",     Struct(None, [("credit", libxl_sched_credit_domain),
+                                       ("credit2", libxl_sched_credit2_domain),
+                                       ("sedf", libxl_sched_sedf_domain),
+                                       ("arinc653", libxl_sched_arinc653_domain),
+                                       ]))
Quoted 4 lines

The resulting sched_params structure contains four subfields called "weight", all of which mean (roughly, obviously) the same thing and all of which are to be set from the same "weight" xl configuration parameter. Is this really the most sensible way to do things ?

Perhaps not, but it would imply major surgery to the other scheduler interfaces to do it some other way (since these same structs are used for libxl_sched_*_{set,get}.

I'm not 100% sure that "weight" has the same meaning for each scheduler either. It's at least plausible that I might want one weight for a doamin if the scheduler is credit and something else if it is sedf.

Quoted 3 lines

Perhaps it would be better to have a single sched_params struct which contained all the parameters needed for any scheduler, and simply have them ignored by libxl for schedulers we're not using.

You'd need to reconstitute each of the split structs in order to call libxl_sched_FOO_set internally, I don't think I want to ask Dieter to take on that much bigger job.

Modulo this IDL bit Dieter's patch looks quite nice.

Ian.

#18 lore raw
In reply to Ian Jackson

Hi,

Quoted 3 lines · Ian Jackson

Perhaps it would be better to have a single sched_params struct which contained all the parameters needed for any scheduler, and simply have them ignored by libxl for schedulers we're not using.

my first version has this type of design and then someone said that this was not a good design and I have to use union with libxl_sched_*_params.

Anyway I think it is a good design to have one struct with all parameters and I'am willing to implement it.

Signature · 8 lines
Gruß

  Dieter

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

#19 lore raw

Hi,

Quoted 7 lines · Dieter Bloms

Hi,

Quoted 3 lines · Ian Jackson

Perhaps it would be better to have a single sched_params struct which contained all the parameters needed for any scheduler, and simply have them ignored by libxl for schedulers we're not using.

...

Quoted 2 lines

Anyway I think it is a good design to have one struct with all parameters and I'am willing to implement it.

I've made a new patch.
Maybe it fit all your needs.

Signature · 8 lines
best regards

  Dieter Bloms

--
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

libxl: set domain scheduling parameters while creating the domU

the domain specific scheduling parameters like cpu_weight, cap, slice, ... will be set during creating the domain, so this parameters can be defined in the domain config file

docs/man/xl.cfg.pod.5 +38 -0
index e2cd251..b0c8064 100644
@@ -112,6 +112,44 @@ List of which cpus the guest is allowed to use. Default behavior is
 (all vcpus will run on cpus 0,2,3,5), or `cpus=["2", "3"]` (all vcpus
 will run on cpus 2 and 3).
 
+=item B<cpu_weight=WEIGHT>
+
+A domain with a weight of 512 will get twice as much CPU as a domain
+with a weight of 256 on a contended host.
+Legal weights range from 1 to 65535 and the default is 256.
+Can be set for credit, credit2 and sedf scheduler.
+
+=item B<cap=N>
+
+The cap optionally fixes the maximum amount of CPU a domain will be
+able to consume, even if the host system has idle CPU cycles.
+The cap is expressed in percentage of one physical CPU:
+100 is 1 physical CPU, 50 is half a CPU, 400 is 4 CPUs, etc.
+The default, 0, means there is no upper cap.
+Can be set for the credit and credit2 scheduler.
+
+=item B<period=NANOSECONDS>
+
+The normal EDF scheduling usage in nanoseconds. This means every period
+the domain gets cpu time defined in slice.
+Can be set for sedf scheduler.
+
+=item B<slice=NANOSECONDS>
+
+The normal EDF scheduling usage in nanoseconds. it defines the time 
+a domain get every period time.
+Can be set for sedf scheduler.
+
+=item B<latency=N>
+
+Scaled period if domain is doing heavy I/O.
+Can be set for sedf scheduler.
+
+=item B<extratime=BOOLEAN>
+
+Flag for allowing domain to run in extra time.
+Can be set for sedf scheduler.
+
 =item B<memory=MBYTES>
 
 Start the guest with MBYTES megabytes of RAM.
tools/libxl/libxl_dom.c +36 -0
index 0bdd654..55b033a 100644
@@ -42,6 +42,40 @@ libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid)
         return LIBXL_DOMAIN_TYPE_PV;
 }
 
+int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params *scparams)
+{
+    libxl_ctx *ctx = libxl__gc_owner(gc);
+    libxl_scheduler sched;
+    libxl_sched_sedf_domain sedf_info;
+    libxl_sched_credit_domain credit_info;
+    libxl_sched_credit2_domain credit2_info;
+    int ret;
+
+    sched = libxl_get_scheduler (ctx);
+    switch (sched) {
+    case LIBXL_SCHEDULER_SEDF:
+      sedf_info.period = scparams->period;
+      sedf_info.slice = scparams->slice;
+      sedf_info.latency = scparams->latency;
+      sedf_info.extratime = scparams->extratime;
+      sedf_info.weight = scparams->weight;
+      ret=libxl_sched_sedf_domain_set(ctx, domid, &sedf_info);
+      break;
+    case LIBXL_SCHEDULER_CREDIT:
+      credit_info.weight = scparams->weight;
+      credit_info.cap = scparams->cap;
+      ret=libxl_sched_credit_domain_set(ctx, domid, &credit_info);
+      break;
+    case LIBXL_SCHEDULER_CREDIT2:
+      credit2_info.weight = scparams->weight;
+      ret=libxl_sched_credit2_domain_set(ctx, domid, &credit2_info);
+      break;
+    default:
+      ret=-1;
+    }
+    return ret;
+}
+
 int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -126,6 +160,8 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
     char **ents, **hvm_ents;
     int i;
 
+    libxl__sched_set_params (gc, domid, &(info->sched_params));
+
     libxl_cpuid_apply_policy(ctx, domid);
     if (info->cpuid != NULL)
         libxl_cpuid_set(ctx, domid, info->cpuid);
tools/libxl/libxl_internal.h +1 -0
index a4b933b..2b76b0e 100644
@@ -617,6 +617,7 @@ int libxl__atfork_init(libxl_ctx *ctx);
 /* from xl_dom */
 _hidden libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__domain_shutdown_reason(libxl__gc *gc, uint32_t domid);
+_hidden int libxl__sched_set_params(libxl__gc *gc, uint32_t domid, libxl_sched_params *scparams);
 #define LIBXL__DOMAIN_IS_TYPE(gc, domid, type) \
     libxl__domain_type((gc), (domid)) == LIBXL_DOMAIN_TYPE_##type
 typedef struct {
tools/libxl/libxl_types.idl +13 -0
index 5cf9708..7789327 100644
@@ -224,6 +224,17 @@ libxl_domain_create_info = Struct("domain_create_info",[
 
 MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
 
+libxl_sched_params = Struct("sched_params",[
+    ("weight",       integer),
+    ("cap",          integer),
+    ("tslice_ms",    integer),
+    ("ratelimit_us", integer),
+    ("period",       integer),
+    ("slice",        integer),
+    ("latency",      integer),
+    ("extratime",    integer),
+    ], dir=DIR_IN)
+
 # Instances of libxl_file_reference contained in this struct which
 # have been mapped (with libxl_file_reference_map) will be unmapped
 # by libxl_domain_build/restore. If either of these are never called
@@ -255,6 +266,8 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("extra_pv",         libxl_string_list),
     # extra parameters pass directly to qemu for HVM guest, NULL terminated
     ("extra_hvm",        libxl_string_list),
+    #  parameters for all type of scheduler
+    ("sched_params",     libxl_sched_params),
 
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware",         string),
tools/libxl/xl_cmdimpl.c +17 -0
index 5703512..8e67307 100644
@@ -587,6 +587,23 @@ static void parse_config_data(const char *configfile_filename_report,
     libxl_domain_build_info_init_type(b_info, c_info->type);
 
     /* the following is the actual config parsing with overriding values in the structures */
+    if (!xlu_cfg_get_long (config, "cpu_weight", &l, 0))
+        b_info->sched_params.weight = l;
+    if (!xlu_cfg_get_long (config, "cap", &l, 0))
+        b_info->sched_params.cap = l;
+    if (!xlu_cfg_get_long (config, "tslice_ms", &l, 0))
+        b_info->sched_params.tslice_ms = l;
+    if (!xlu_cfg_get_long (config, "ratelimit_us", &l, 0))
+        b_info->sched_params.ratelimit_us = l;
+    if (!xlu_cfg_get_long (config, "period", &l, 0))
+        b_info->sched_params.period = l;
+    if (!xlu_cfg_get_long (config, "slice", &l, 0))
+        b_info->sched_params.period = l;
+    if (!xlu_cfg_get_long (config, "latency", &l, 0))
+        b_info->sched_params.period = l;
+    if (!xlu_cfg_get_long (config, "extratime", &l, 0))
+        b_info->sched_params.period = l;
+
     if (!xlu_cfg_get_long (config, "vcpus", &l, 0)) {
         b_info->max_vcpus = l;
         b_info->cur_vcpus = (1 << l) - 1;

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

#20 lore raw
Quoted 12 lines · Dieter Bloms

Hi,

Quoted 7 lines · Dieter Bloms

Hi,

Quoted 3 lines · Ian Jackson

Perhaps it would be better to have a single sched_params struct which contained all the parameters needed for any scheduler, and simply have them ignored by libxl for schedulers we're not using.

Quoted 7 lines

...

Quoted 2 lines

Anyway I think it is a good design to have one struct with all parameters and I'am willing to implement it.

I've made a new patch.
Maybe it fit all your needs.

Thanks, this patch look good to me, I'll leave it to IanJ to decide which approach he prefers.

Ian.

#21 lore raw

Ian Campbell writes ("Re: [Xen-devel] [Xen-users] xl doesn't honour the parameter cpu_weight from my config file while xm does honour it"):

Quoted 6 lines · Dieter Bloms
Quoted 2 lines

I've made a new patch.
Maybe it fit all your needs.

Thanks, this patch look good to me, I'll leave it to IanJ to decide which approach he prefers.

Thanks, I'll take that as an ack. I've applied Dieter's latest version, which I like.

I edited the docs message to change "can be set for" to "honoured by", because variables can be set which will then be ignored. Eg:

+=item B<cpu_weight=WEIGHT>
+
+A domain with a weight of 512 will get twice as much CPU as a domain +with a weight of 256 on a contended host.
+Legal weights range from 1 to 65535 and the default is 256.
-+Can be set for credit, credit2 and sedf scheduler. ++Honoured by the credit, credit2 and sedf schedulers.

Ian.