Enable per-VCPU parameter settings for RTDS scheduler
v4 cover Enable per-VCPU parameter settings for RTDS scheduler
[Goal]
The current xl sched-rtds tool can only set the VCPUs of a domain to the same parameter although the scheduler supports VCPUs with different parameters. This patchset is to enable xl sched-rtds tool to configure the VCPUs of a domain with different parameters.
This per-VCPU settings can be used in many scenarios. For example, based on Dario's statement in our pervious discussion
(http://lists.xen.org/archives/html/xen-devel/2014-09/msg00423.html),
if there are two real-time applications, which have different timing requirements, running in a multi-VCPU guest domain, it is beneficial to pin these two applications to two seperate VCPUs with different scheduling parameters.
What this patchset includes is a wanted and planned feature for RTDS scheudler(http://wiki.xenproject.org/wiki/RTDS-Based-Scheduler) in Xen 4.6. The interface design of the xl sched-rtds tool is based on Meng's previous discussion with Dario, George and Wei
(http://lists.xen.org/archives/html/xen-devel/2015-02/msg02606.html).
Basically, there are two main changes:
1) in xl, we create an array that records all VCPUs whose parameters are about to modify or output.
2) in libxl, we receive the array and call different xc functions to handle it.
3) in xen and libxc, we use XEN_DOMCTL_SCHEDOP_getvcpuinfo/putvcpuinfo(introduced by this patchset) as the hypercall for per-VCPU operations(get/set method).
[Usage]
With this patchset in use, xl sched-rtds tool can:
1) show the budget and period of each VCPU of each domain, by using "xl sched-rtds -v all" command. An example would be like:
# xl sched-rtds -v all Cpupool Pool-0: sched=RTDS Name ID VCPU Period Budget Domain-0 0 0 10000 4000 vm1 1 0 300 150 vm1 1 1 400 200 vm1 1 2 10000 4000 vm1 1 3 1000 500 vm2 2 0 10000 4000 vm2 2 1 10000 4000
Using "xl sched-rtds" will output the default scheduling parameters for each domain. An example would be like:
# xl sched-rtds Cpupool Pool-0: sched=RTDS Name ID Period Budget Domain-0 0 10000 4000 vm1 1 10000 4000 vm2 2 10000 4000
2) show the budget and period of each VCPU of a specific domain, by using, e.g., "xl sched-rtds -d vm1 -v all" command. The output would be like:
# xl sched-rtds -d vm1 -v all Name ID VCPU Period Budget vm1 1 0 300 150 vm1 1 1 400 200 vm1 1 2 10000 4000 vm1 1 3 1000 500
To show a subset of the parameters of the VCPUs of a specific domain, please use, e.g.,"xl sched-rtds -d vm1 -v 0 -v 3" command. The output would be:
# xl sched-rtds -d vm1 -v 0 -v 3 Name ID VCPU Period Budget vm1 1 0 300 150 vm1 1 3 1000 500
Using command, e.g., "xl sched-rtds -d vm1" will output the default scheduling parameters of vm1. An example would be like:
# xl sched-rtds -d vm1 Name ID Period Budget vm1 1 10000 4000
3) Users can set the budget and period of multiple VCPUs of a specific domain with only one command,
e.g., "xl sched-rtds -d vm1 -v 0 -p 100 -b 50 -v 3 -p 300 -b 150".
Users can set all VCPUs with the same parameters, by one command. e.g., "xl sched-rtds -d vm1 -v all -p 500 -b 250".
---
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
CC: <[email protected]>
Chong Li (4):
xen: enable per-VCPU parameter settings for RTDS scheduler
libxc: enable per-VCPU parameter settings for RTDS scheduler
libxl: enable per-VCPU parameter settings for RTDS scheduler
xl: enable per-VCPU parameter settings for RTDS scheduler
docs/man/xl.pod.1 | 4 + tools/libxc/include/xenctrl.h | 9 ++ tools/libxc/xc_rt.c | 58 ++++++++- tools/libxl/libxl.c | 265 ++++++++++++++++++++++++++++++++++---- tools/libxl/libxl.h | 17 +++ tools/libxl/libxl_types.idl | 16 +++ tools/libxl/xl_cmdimpl.c | 292 ++++++++++++++++++++++++++++++++++++++---- tools/libxl/xl_cmdtable.c | 10 +- xen/common/domctl.c | 3 + xen/common/sched_rt.c | 100 ++++++++++++++- xen/common/schedule.c | 18 ++- xen/include/public/domctl.h | 61 ++++++--- 12 files changed, 770 insertions(+), 83 deletions(-)
Signature · 1 line
1.9.1
PATCH v4 1/4 xen: enable per-VCPU parameter settings for RTDS scheduler
Add XEN_DOMCTL_SCHEDOP_getvcpuinfo and _putvcpuinfo hypercalls to independently get and set the scheduling parameters of each vCPU of a domain
---
Changes on PATCH v3:
1) Remove struct xen_domctl_schedparam_t.
2) Change struct xen_domctl_scheduler_op.
3) Check if period/budget is within a validated range
--- xen/common/domctl.c | 3 ++ xen/common/sched_rt.c | 100 +++++++++++++++++++++++++++++++++++++++++--- xen/common/schedule.c | 18 ++++++-- xen/include/public/domctl.h | 61 +++++++++++++++++++-------- 4 files changed, 155 insertions(+), 27 deletions(-)
xen/common/domctl.c +3 -0
@@ -839,6 +839,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)case XEN_DOMCTL_scheduler_op: ret =sched_adjust (d, &op->u.scheduler_op); +if ( ret == -ERESTART ) + ret =hypercall_create_continuation ( + __HYPERVISOR_domctl,"h" , u_domctl); copyback =1 ;break ;
xen/common/sched_rt.c +94 -6
129 lines not on this page · raw message
xen/common/schedule.c +15 -3
@@ -1052,10 +1052,22 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)if ( ret )return ret; -if ( (op->sched_id !=DOM2OP (d)->sched_id) || - ((op->cmd != XEN_DOMCTL_SCHEDOP_putinfo) && - (op->cmd != XEN_DOMCTL_SCHEDOP_getinfo)) ) +if ( op->sched_id !=DOM2OP (d)->sched_id )return -EINVAL ; +else +switch ( op->cmd ) + { +case XEN_DOMCTL_SCHEDOP_putinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getinfo: +break ; +case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +break ; +default : +return -EINVAL ; + }/* NB: the pluggable scheduler code needs to take care * of locking by itself. */
xen/include/public/domctl.h +43 -18
74 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v4 for Xen 4.6 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 11.07.15 at 06:52, <[email protected]> wrote:
xen/common/sched_rt.c +22
-0@@ -1162,8 +1176,82 @@ rt_dom_cntl( }spin_unlock_irqrestore (&prv->lock, flags);break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } +if ( local_sched.vcpuid >= d->max_vcpus || + d->vcpu[local_sched.vcpuid] ==NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + + local_sched.s.rtds.budget = svc->budget /MICROSECS (1 ); + local_sched.s.rtds.period = svc->period /MICROSECS (1 ); + + if ( __copy_to_guest_offset(op->u.v.vcpus, index,
xen/common/sched_rt.c rt_dom_cntl( · line 1210
Quoted 10 lines
xen/common/sched_rt.c +10
-0+ &local_sched, 1) ) + { + rc = -EFAULT ; +break ; + } +if (hypercall_preempt_check () ) + { + rc = -ERESTART ; +break ; + }
I still don't see how this is supposed to work.
Quoted 14 lines
xen/common/sched_rt.c +14
-0+ } +spin_unlock_irqrestore (&prv->lock, flags); +break ; +case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } + if ( local_sched.vcpuid >= d->max_vcpus ||
xen/common/sched_rt.c rt_dom_cntl( · line 1234
Quoted 10 lines
xen/common/sched_rt.c +10
-0+ d->vcpu[local_sched.vcpuid] == NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + period =MICROSECS (local_sched.s.rtds.period); + budget =MICROSECS (local_sched.s.rtds.budget); +if ( period <MICROSECS (10 ) || period >RTDS_MAX_PERIOD || + budget <MICROSECS (10 ) || budget > period )
Apart from numerous coding style issues I think the first of the checks in this if() is redundant (covered by the combination of the last two ones) and hence would better be dropped.
Quoted 12 lines
xen/common/schedule.c +2
-3@@ -1052,10 +1052,22 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)if ( ret )return ret; -if ( (op->sched_id !=DOM2OP (d)->sched_id) || - ((op->cmd != XEN_DOMCTL_SCHEDOP_putinfo) && - (op->cmd != XEN_DOMCTL_SCHEDOP_getinfo)) ) +if ( op->sched_id !=DOM2OP (d)->sched_id )return -EINVAL ; +else
xen/common/schedule.c long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op) · line 1067
Quoted 10 lines
xen/common/schedule.c +10
-0+switch ( op->cmd ) + { +case XEN_DOMCTL_SCHEDOP_putinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getinfo: +break ; +case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +break ;
Only this break should stay, the three earlier ones should be dropped as redundant.
Quoted 26 lines
xen/include/public/domctl.h +20
-0@@ -330,31 +330,56 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);#define XEN_SCHEDULER_ARINC653 7#define XEN_SCHEDULER_RTDS 8 +typedef struct xen_domctl_sched_sedf { +uint64_aligned_t period; +uint64_aligned_t slice; +uint64_aligned_t latency; +uint32_t extratime; +uint32_t weight; +}xen_domctl_sched_sedf_t ; + +typedef struct xen_domctl_sched_credit { +uint16_t weight; +uint16_t cap; +}xen_domctl_sched_credit_t ; + +typedef struct xen_domctl_sched_credit2 { +uint16_t weight; +}xen_domctl_sched_credit2_t ; + +typedef struct xen_domctl_sched_rtds { + uint32_t period; + uint32_t budget;
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 362
Quoted 10 lines
xen/include/public/domctl.h +10
-0+} xen_domctl_sched_rtds_t; + +typedef struct xen_domctl_schedparam_vcpu { + union { + xen_domctl_sched_credit_t credit; + xen_domctl_sched_credit2_t credit2; + xen_domctl_sched_rtds_t rtds; + } s; + uint16_t vcpuid; + uint16_t padding;
This pads to a 32-bit boundary, leaving another 32-bit hole.
Quoted 28 lines
xen/include/public/domctl.h +5
-16+} xen_domctl_schedparam_vcpu_t; +DEFINE_XEN_GUEST_HANDLE (xen_domctl_schedparam_vcpu_t); +/* Set or get info? */ #define XEN_DOMCTL_SCHEDOP_putinfo 0#define XEN_DOMCTL_SCHEDOP_getinfo 1 +#define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 +#define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3struct xen_domctl_scheduler_op {uint32_t sched_id;/* XEN_SCHEDULER_* */ uint32_t cmd;/* XEN_DOMCTL_SCHEDOP_* */ union { - struct xen_domctl_sched_sedf { - uint64_aligned_t period; - uint64_aligned_t slice; - uint64_aligned_t latency; - uint32_t extratime; - uint32_t weight; - } sedf; - struct xen_domctl_sched_credit { - uint16_t weight; - uint16_t cap; - } credit; - struct xen_domctl_sched_credit2 { - uint16_t weight; - } credit2; - struct xen_domctl_sched_rtds { - uint32_t period;
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 382
Quoted 10 lines
xen/include/public/domctl.h +8
-2-uint32_t budget; - } rtds; +xen_domctl_sched_sedf_t sedf; +xen_domctl_sched_credit_t credit; +xen_domctl_sched_credit2_t credit2; +xen_domctl_sched_rtds_t rtds; +struct { +XEN_GUEST_HANDLE_64 (xen_domctl_schedparam_vcpu_t) vcpus; +uint16_t nr_vcpus; + } v;
And there's still no explicit padding here at all (nor am I convinced that uint16_t is really a good choice for nr_vcpus - uint32_t would seem more natural without causing any problems or structure growth).
Jan
Re: [PATCH v4 for Xen 4.6 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 11.07.15 at 06:52, <[email protected]> wrote:
xen/common/sched_rt.c +26
-0@@ -1162,8 +1176,82 @@ rt_dom_cntl( }spin_unlock_irqrestore (&prv->lock, flags);break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } +if ( local_sched.vcpuid >= d->max_vcpus || + d->vcpu[local_sched.vcpuid] ==NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + + local_sched.s.rtds.budget = svc->budget /MICROSECS (1 ); + local_sched.s.rtds.period = svc->period /MICROSECS (1 ); + +if (__copy_to_guest_offset (op->u.v.vcpus, index, + &local_sched,1 ) ) + { + rc = -EFAULT ; +break ;
Quoted 8 lines
xen/common/sched_rt.c rt_dom_cntl( · line 1210
Quoted 6 lines
xen/common/sched_rt.c +6
-0+ } +if (hypercall_preempt_check () ) + { + rc = -ERESTART ; +break ; + }I still don't see how this is supposed to work.
I return -ERESTART here, and the upper layer function (do_domctl) will handle this error code by calling hypercall_create_continuation.
Quoted 35 lines
Quoted 35 lines
xen/include/public/domctl.h +10
-18+} xen_domctl_schedparam_vcpu_t; +DEFINE_XEN_GUEST_HANDLE (xen_domctl_schedparam_vcpu_t); +/* Set or get info? */ #define XEN_DOMCTL_SCHEDOP_putinfo 0#define XEN_DOMCTL_SCHEDOP_getinfo 1 +#define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 +#define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3 struct xen_domctl_scheduler_op { uint32_t sched_id; /* XEN_SCHEDULER_* */ uint32_t cmd; /* XEN_DOMCTL_SCHEDOP_* */ union { -struct xen_domctl_sched_sedf { -uint64_aligned_t period; -uint64_aligned_t slice; -uint64_aligned_t latency; -uint32_t extratime; -uint32_t weight; - } sedf; -struct xen_domctl_sched_credit { -uint16_t weight; -uint16_t cap; - } credit; -struct xen_domctl_sched_credit2 { -uint16_t weight; - } credit2; -struct xen_domctl_sched_rtds { -uint32_t period; -uint32_t budget; - } rtds; + xen_domctl_sched_sedf_t sedf; + xen_domctl_sched_credit_t credit; + xen_domctl_sched_credit2_t credit2; + xen_domctl_sched_rtds_t rtds; + struct {
Quoted 8 lines
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 382
Quoted 3 lines
xen/include/public/domctl.h +3
-0+XEN_GUEST_HANDLE_64 (xen_domctl_schedparam_vcpu_t) vcpus; +uint16_t nr_vcpus; + } v;And there's still no explicit padding here at all (nor am I convinced that
uint16_tis really a good choice fornr_vcpus-uint32_twould seem more natural without causing any problems or structure growth).
I think the size of union u is equal to the size of xen_domctl_sched_sedf_t, which is 64*4 bits (if "vcpus" in struct v is just a pointer).
The "nr_vcpus" is indeed better to be uint32_t. I'll change it in the next version.
Chong
Quoted 2 lines
Jan
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis
Re: [PATCH v4 for Xen 4.6 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
Quoted 42 lines
Quoted 1 line
Quoted 1 line · On 09.08.15 at 17:45, <[email protected]> wrote:
Quoted 31 lines · Jan Beulich
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 11.07.15 at 06:52, <[email protected]> wrote:
xen/common/sched_rt.c +26
-0@@ -1162,8 +1176,82 @@ rt_dom_cntl( }spin_unlock_irqrestore (&prv->lock, flags);break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } +if ( local_sched.vcpuid >= d->max_vcpus || + d->vcpu[local_sched.vcpuid] ==NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + + local_sched.s.rtds.budget = svc->budget /MICROSECS (1 ); + local_sched.s.rtds.period = svc->period /MICROSECS (1 ); + +if (__copy_to_guest_offset (op->u.v.vcpus, index, + &local_sched,1 ) ) + { + rc = -EFAULT ; +break ;Quoted 8 lines
xen/common/sched_rt.c rt_dom_cntl( · line 1210
Quoted 6 lines
xen/common/sched_rt.c +6
-0+ } +if (hypercall_preempt_check () ) + { + rc = -ERESTART ; +break ; + }I still don't see how this is supposed to work.
Quoted 2 lines
I return
-ERESTARThere, and the upper layer function (do_domctl) will handle this error code by callinghypercall_create_continuation.
I have no idea where you found the upper layer (i.e. the XEN_DOMCTL_scheduler_op case of do_domctl() to take care of this).
Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
xen/include/public/domctl.h +10
-18+} xen_domctl_schedparam_vcpu_t; +DEFINE_XEN_GUEST_HANDLE (xen_domctl_schedparam_vcpu_t); +/* Set or get info? */ #define XEN_DOMCTL_SCHEDOP_putinfo 0#define XEN_DOMCTL_SCHEDOP_getinfo 1 +#define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 +#define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3 struct xen_domctl_scheduler_op { uint32_t sched_id; /* XEN_SCHEDULER_* */ uint32_t cmd; /* XEN_DOMCTL_SCHEDOP_* */ union { -struct xen_domctl_sched_sedf { -uint64_aligned_t period; -uint64_aligned_t slice; -uint64_aligned_t latency; -uint32_t extratime; -uint32_t weight; - } sedf; -struct xen_domctl_sched_credit { -uint16_t weight; -uint16_t cap; - } credit; -struct xen_domctl_sched_credit2 { -uint16_t weight; - } credit2; -struct xen_domctl_sched_rtds { -uint32_t period; -uint32_t budget; - } rtds; + xen_domctl_sched_sedf_t sedf; + xen_domctl_sched_credit_t credit; + xen_domctl_sched_credit2_t credit2; + xen_domctl_sched_rtds_t rtds; + struct {Quoted 8 lines
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 382
Quoted 3 lines
xen/include/public/domctl.h +3
-0+XEN_GUEST_HANDLE_64 (xen_domctl_schedparam_vcpu_t) vcpus; +uint16_t nr_vcpus; + } v;And there's still no explicit padding here at all (nor am I convinced that
uint16_tis really a good choice fornr_vcpus-uint32_twould seem more natural without causing any problems or structure growth).
Quoted 3 lines
I think the size of union u is equal to the size of
xen_domctl_sched_sedf_t, which is 64*4 bits (if "vcpus" in struct v is just a pointer).
Which doesn't in any way address to complaint about missing explicit padding - I'm not asking you to pad to the size of the union, but to the size of the unnamed structure you add.
Jan
Quoted 4 lines
The "
nr_vcpus" is indeed better to beuint32_t. I'll change it in the next version.Chong
Re: [PATCH v4 for Xen 4.6 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
In reply to Chong LiQuoted 4 lines · Chong Li
Add
XEN_DOMCTL_SCHEDOP_getvcpuinfoand_putvcpuinfohypercalls to independently get and set the scheduling parameters of each vCPU of a domain
I'd add a note about the fact that, for now, this is only supported and being implemented for RTDs.
Quoted 4 lines
Signed-off-by Chong Li <[email protected]>Signed-off-by Meng Xu <[email protected]>Signed-off-by Sisu Xi <[email protected]>
Quoted 9 lines
---
Changes on PATCH v3:1) Remove struct
xen_domctl_schedparam_t.2) Change struct
xen_domctl_scheduler_op.3) Check if period/budget is within a validated range
Don't drop the 'Changes on PATCH v2' part, please. That helps having an idea of the full history, reminding about previous comments being done, etc.
Quoted 20 lines
xen/common/domctl.c +3
-0@@ -839,6 +839,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)case XEN_DOMCTL_scheduler_op: ret =sched_adjust (d, &op->u.scheduler_op); +if ( ret == -ERESTART ) + ret =hypercall_create_continuation ( + __HYPERVISOR_domctl,"h" , u_domctl); copyback =1 ;break ;xen/common/sched_rt.c +0
-0
xen/common/sched_rt.c line 83
Quoted 7 lines
xen/common/sched_rt.c +0
-1@@ -78,7 +78,6 @@* vcpu_insert, vcpu_remove, context_saved, __runq_insert */ -/* * Default parameters: * Period and budget in default is 10 and 4 ms, respectively
This hunk is spurious, just don't do these things. If you think the white line should indeed be dropped, send a separate patch, i.e., let's avoid mixing cosmetic and coding style fixes, with functional changes.
Of course, it's not really worthwhile to send a patch for a blank line. If you, however, identify a bunch of coding style issues in the file, you can well bundle them together and send a patch to fix them.
xen/common/sched_rt.c line 94
Quoted 11 lines
xen/common/sched_rt.c +7
-0@@ -86,6 +85,18 @@#define RTDS_DEFAULT_PERIOD (MICROSECS(10000))#define RTDS_DEFAULT_BUDGET (MICROSECS(4000)) +/* +* Max period: max delta of time type +* Min period: 100 us, considering the scheduling overhead +*/ +#define RTDS_MAX_PERIOD (STIME_DELTA_MAX) +#define RTDS_MIN_PERIOD (MICROSECS(100)) +
So, minimum acceptable value is 100, or so one understands, when seeing this.
Then, below, you do this:
if ( period < MICROSECS(10) || period > RTDS_MAX_PERIOD ||
budget < MICROSECS(10) || budget > period )
{
rc = -EINVAL;
break;
}
if ( period < RTDS_MIN_PERIOD || budget < RTDS_MIN_BUDGET )
warn = 1;I.e., we warn if the value is below the minimum acceptable, but we accept it, while we error if the value is below some magic number (10, in this case).
I'd do the opposite: make 10 the minimum, and #define it so. For gating the warning, either use another #define, or open code 100, but put down a comment about it.
Quoted 13 lines
xen/common/sched_rt.c +4
-1@@ -1137,14 +1148,17 @@ rt_dom_cntl(struct list_head *iter;unsigned long flags;int rc =0 ; +int warn =0 ; +xen_domctl_schedparam_vcpu_t local_sched; +s_time_t period, budget; +unsigned int index;switch ( op->cmd ) { -case XEN_DOMCTL_SCHEDOP_getinfo:
xen/common/sched_rt.c rt_dom_cntl( · line 1164
Quoted 10 lines
xen/common/sched_rt.c +3
-3+case XEN_DOMCTL_SCHEDOP_getinfo:/* return the default parameters */ spin_lock_irqsave (&prv->lock, flags); - svc = list_entry(sdom->vcpu.next, struct rt_vcpu, sdom_elem); - op->u.rtds.period = svc->period /MICROSECS (1 );/* transfer to us */ - op->u.rtds.budget = svc->budget /MICROSECS (1 ); + op->u.rtds.period =RTDS_DEFAULT_PERIOD /MICROSECS (1 );/* transfer to us */ + op->u.rtds.budget =RTDS_DEFAULT_BUDGET /MICROSECS (1 );spin_unlock_irqrestore (&prv->lock, flags);break ;case XEN_DOMCTL_SCHEDOP_putinfo:
So, the interface is asymmetric:
- getinfo: returns defaults
- putinfo: sets params for all vcpus
This is fine, as there is no much else meaningful we can do with getinfo, and I don't see putinfo changing the defaults that much useful.
However, I'd put down a brief comment about this here, and a less brief one in the public header.
Quoted 37 lines
xen/common/sched_rt.c +35
-0@@ -1162,8 +1176,82 @@ rt_dom_cntl( +case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } +if ( local_sched.vcpuid >= d->max_vcpus || + d->vcpu[local_sched.vcpuid] ==NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + period =MICROSECS (local_sched.s.rtds.period); + budget =MICROSECS (local_sched.s.rtds.budget); +if ( period <MICROSECS (10 ) || period >RTDS_MAX_PERIOD || + budget <MICROSECS (10 ) || budget > period ) + { + rc = -EINVAL ; +break ; + } +if ( period <RTDS_MIN_PERIOD || budget <RTDS_MIN_BUDGET ) + warn =1 ; + + svc->period = period; + svc->budget = budget; +if (hypercall_preempt_check () ) + { + rc = -ERESTART ; +break ; + }
xen/common/sched_rt.c rt_dom_cntl( · line 1220
Quoted 10 lines
xen/common/sched_rt.c +5
-1+ } +spin_unlock_irqrestore (&prv->lock, flags); +break ; } - +if ( rc ==0 && warn ==1 )/* print warning in libxl */ + rc =1 ;return rc; }
Mmm.. And where is the documentation about the fact that return value of 1 means that the call succeeded, but some upper layer should print a warning?
Remember that, when working in Xen, libxl is not the only toolstack one should bear in mind.
In any case, even if documented, I don't like it that much... Why can't we print a warning here, and just return success?
Quoted 21 lines
xen/common/schedule.c +8
-3@@ -1052,10 +1052,22 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)if ( ret )return ret; -if ( (op->sched_id !=DOM2OP (d)->sched_id) || - ((op->cmd != XEN_DOMCTL_SCHEDOP_putinfo) && - (op->cmd != XEN_DOMCTL_SCHEDOP_getinfo)) ) +if ( op->sched_id !=DOM2OP (d)->sched_id )return -EINVAL ; +else +switch ( op->cmd ) + { +case XEN_DOMCTL_SCHEDOP_putinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getinfo: +break ;
xen/common/schedule.c long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op) · line 1073
Quoted 10 lines
xen/common/schedule.c +7
-0+case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +break ; +default : +return -EINVAL ; + }/* NB: the pluggable scheduler code needs to take care * of locking by itself. */
So, what happens if someone calls XEN_DOMCTL_SCHEDOP_putvcpuinfo or XEN_DOMCTL_SCHEDOP_getvcpuinfo on Credit or Credit2? The call reports being successful, but no date is returned (by quickly inspecting csched_dom_cntl() and csched2_dom_cntl())?
I think you should go there and add something like:
if ( op->cmd == XEN_DOMCTL_SCHEDOP_putvcpuinfo ||
op->cmd == XEN_DOMCTL_SCHEDOP_getvcpuinfo )
return -ENOTSUP;or something like that.
Again, I know this can't happen in libxl, but that does not really matter much down here. :-)
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 332
Quoted 8 lines
xen/include/public/domctl.h +0
-0@@ -330,31 +330,56 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t);/* Set or get info? */
As I said, I'll expand the comment here a bit, mentioning what happens in the various cases (schedulers supporting or not per-vcpu information), as well as how, for supporting ones, _getvcpuinfo and _putvcpuinfo behave.
Quoted 27 lines
xen/include/public/domctl.h +3
-18#define XEN_DOMCTL_SCHEDOP_putinfo 0#define XEN_DOMCTL_SCHEDOP_getinfo 1 +#define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 +#define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3struct xen_domctl_scheduler_op {uint32_t sched_id;/* XEN_SCHEDULER_* */ uint32_t cmd;/* XEN_DOMCTL_SCHEDOP_* */ union { -struct xen_domctl_sched_sedf { -uint64_aligned_t period; -uint64_aligned_t slice; -uint64_aligned_t latency; -uint32_t extratime; -uint32_t weight; - } sedf; -struct xen_domctl_sched_credit { -uint16_t weight; -uint16_t cap; - } credit; -struct xen_domctl_sched_credit2 { -uint16_t weight; - } credit2; -struct xen_domctl_sched_rtds { -uint32_t period; -uint32_t budget; - } rtds; +xen_domctl_sched_sedf_t sedf;
xen/include/public/domctl.h DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); · line 385
Quoted 10 lines
xen/include/public/domctl.h +7
-0+xen_domctl_sched_credit_t credit; +xen_domctl_sched_credit2_t credit2; +xen_domctl_sched_rtds_t rtds; +struct { +XEN_GUEST_HANDLE_64 (xen_domctl_schedparam_vcpu_t) vcpus; +uint16_t nr_vcpus; + } v; } u; };typedef struct xen_domctl_scheduler_op xen_domctl_scheduler_op_t ;
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]
http://lists.xen.org/xen-devel
Re: [PATCH v4 for Xen 4.6 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
Quoted 82 lines · Dario Faggioli
Quoted 4 lines · Chong Li
Add
XEN_DOMCTL_SCHEDOP_getvcpuinfoand_putvcpuinfohypercalls to independently get and set the scheduling parameters of each vCPU of a domainI'd add a note about the fact that, for now, this is only supported and being implemented for RTDs.
Quoted 4 lines
Signed-off-by Chong Li <[email protected]>Signed-off-by Meng Xu <[email protected]>Signed-off-by Sisu Xi <[email protected]>Quoted 9 lines
---
Changes on PATCH v3:1) Remove struct
xen_domctl_schedparam_t.2) Change struct
xen_domctl_scheduler_op.3) Check if period/budget is within a validated range
Don't drop the 'Changes on PATCH v2' part, please. That helps having an idea of the full history, reminding about previous comments being done, etc.
Quoted 43 lines
xen/common/domctl.c +35
-0@@ -1162,8 +1176,82 @@ rt_dom_cntl( +case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +spin_lock_irqsave (&prv->lock, flags); +for ( index =0 ; index < op->u.v.nr_vcpus; index++ ) + { +if (copy_from_guest_offset (&local_sched, + op->u.v.vcpus, index,1 ) ) + { + rc = -EFAULT ; +break ; + } +if ( local_sched.vcpuid >= d->max_vcpus || + d->vcpu[local_sched.vcpuid] ==NULL ) + { + rc = -EINVAL ; +break ; + } + svc =rt_vcpu (d->vcpu[local_sched.vcpuid]); + period =MICROSECS (local_sched.s.rtds.period); + budget =MICROSECS (local_sched.s.rtds.budget); +if ( period <MICROSECS (10 ) || period >RTDS_MAX_PERIOD || + budget <MICROSECS (10 ) || budget > period ) + { + rc = -EINVAL ; +break ; + } +if ( period <RTDS_MIN_PERIOD || budget <RTDS_MIN_BUDGET ) + warn =1 ; + + svc->period = period; + svc->budget = budget; +if (hypercall_preempt_check () ) + { + rc = -ERESTART ; +break ; + }xen/common/domctl.c rt_dom_cntl( · line 1220
Quoted 10 lines
xen/common/domctl.c +5
-1+ } +spin_unlock_irqrestore (&prv->lock, flags); +break ; } - +if ( rc ==0 && warn ==1 )/* print warning in libxl */ + rc =1 ;return rc; }Mmm.. And where is the documentation about the fact that return value of 1 means that the call succeeded, but some upper layer should print a warning?
Quoted 5 lines
Remember that, when working in Xen, libxl is not the only toolstack one should bear in mind.
In any case, even if documented, I don't like it that much... Why can't we print a warning here, and just return success?
Do I just use printk here? Is there any other more appropriate print function in xen?
Quoted 37 lines
Quoted 22 lines
xen/common/schedule.c +8
-3@@ -1052,10 +1052,22 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)if ( ret )return ret; -if ( (op->sched_id !=DOM2OP (d)->sched_id) || - ((op->cmd != XEN_DOMCTL_SCHEDOP_putinfo) && - (op->cmd != XEN_DOMCTL_SCHEDOP_getinfo)) ) +if ( op->sched_id !=DOM2OP (d)->sched_id )return -EINVAL ; +else +switch ( op->cmd ) + { +case XEN_DOMCTL_SCHEDOP_putinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getinfo: +break ;xen/common/schedule.c long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op) · line 1073
Quoted 10 lines
xen/common/schedule.c +7
-0+case XEN_DOMCTL_SCHEDOP_putvcpuinfo: +break ; +case XEN_DOMCTL_SCHEDOP_getvcpuinfo: +break ; +default : +return -EINVAL ; + }/* NB: the pluggable scheduler code needs to take care * of locking by itself. */ So, what happens if someone calls
XEN_DOMCTL_SCHEDOP_putvcpuinfoorXEN_DOMCTL_SCHEDOP_getvcpuinfoon Credit or Credit2? The call reports being successful, but no date is returned (by quickly inspectingcsched_dom_cntl()andcsched2_dom_cntl())?
Quoted 7 lines
I think you should go there and add something like:
if ( op->cmd == XEN_DOMCTL_SCHEDOP_putvcpuinfo || op->cmd == XEN_DOMCTL_SCHEDOP_getvcpuinfo ) return -ENOTSUP;or something like that.
I see. Will do.
Chong
Quoted 8 lines
Regards,
Dario--
<<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)
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis
PATCH v4 2/4 libxc: enable per-VCPU parameter settings for RTDS scheduler
In reply to Chong LiAdd xc_sched_rtds_vcpu_get/set functions to interact with Xen to get/set a domain's per-VCPU parameters.
---
--- tools/libxc/include/xenctrl.h | 9 +++++++ tools/libxc/xc_rt.c | 58 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-)
tools/libxc/include/xenctrl.h +9 -0
@@ -915,6 +915,15 @@ int xc_sched_rtds_domain_get(xc_interface *xch,uint32_t domid, struct xen_domctl_sched_rtds *sdom); +int xc_sched_rtds_vcpu_set (xc_interface *xch, +uint32_t domid, +xen_domctl_schedparam_vcpu_t *vcpus, +uint16_t num_vcpus); +int xc_sched_rtds_vcpu_get (xc_interface *xch, +uint32_t domid, +xen_domctl_schedparam_vcpu_t *vcpus, +uint16_t num_vcpus); + int xc_sched_arinc653_schedule_set( xc_interface *xch,
tools/libxc/xc_rt.c +56 -2
73 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v4 for Xen 4.6 2/4] libxc: enable per-VCPU parameter settings for RTDS scheduler
tools/libxc/include/xenctrl.h int xc_sched_rtds_domain_get(xc_interface *xch, · line 917
Quoted 8 lines · Chong Li
tools/libxc/include/xenctrl.h +0
-0@@ -915,6 +915,15 @@ int xc_sched_rtds_domain_get(xc_interface *xch,uint32_t domid, struct xen_domctl_sched_rtds *sdom);
So, here in the header, you're not changing the prototype of xc_sched_rtds_domain_{get,set} to use the typedef.
However...
tools/libxc/include/xenctrl.h int xc_sched_rtds_domain_get(xc_interface *xch,
Quoted 5 lines
tools/libxc/include/xenctrl.h +4
-0+int xc_sched_rtds_vcpu_set (xc_interface *xch, +uint32_t domid, +xen_domctl_schedparam_vcpu_t *vcpus, +uint16_t num_vcpus);
... you hare using the typedef for the newly introduced functions xc_sched_rtds_vcpu_{get,set}(), and...
tools/libxc/xc_rt.c line 31
Quoted 9 lines
tools/libxc/xc_rt.c +1
-1@@ -27,7 +27,7 @@int xc_sched_rtds_domain_set (xc_interface *xch,uint32_t domid, -struct xen_domctl_sched_rtds *sdom) +xen_domctl_sched_rtds_t *sdom)
...you are actually changing the _implementation_ of xc_sched_rtds_domain_{get,set}().
That's all rather inconsistent.
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]
http://lists.xen.org/xen-devel
Re: [PATCH v4 for Xen 4.6 2/4] libxc: enable per-VCPU parameter settings for RTDS scheduler
Quoted 35 lines · Dario Faggioli
tools/libxc/include/xenctrl.h int xc_sched_rtds_domain_get(xc_interface *xch, · line 917
Quoted 8 lines · Chong Li
tools/libxc/include/xenctrl.h +0
-0@@ -915,6 +915,15 @@ int xc_sched_rtds_domain_get(xc_interface *xch,uint32_t domid, struct xen_domctl_sched_rtds *sdom);So, here in the header, you're not changing the prototype of xc_sched_rtds_domain_{get,set} to use the typedef.
However...
tools/libxc/include/xenctrl.h int xc_sched_rtds_domain_get(xc_interface *xch,
Quoted 5 lines
tools/libxc/include/xenctrl.h +4
-0+int xc_sched_rtds_vcpu_set (xc_interface *xch, +uint32_t domid, +xen_domctl_schedparam_vcpu_t *vcpus, +uint16_t num_vcpus);... you hare using the typedef for the newly introduced functions xc_sched_rtds_vcpu_{get,set}(), and...
tools/libxc/xc_rt.c line 31
Quoted 9 lines
tools/libxc/xc_rt.c +1
-1@@ -27,7 +27,7 @@int xc_sched_rtds_domain_set (xc_interface *xch,uint32_t domid, -struct xen_domctl_sched_rtds *sdom) +xen_domctl_sched_rtds_t *sdom)...you are actually changing the _implementation_ of xc_sched_rtds_domain_{get,set}().
Quoted 1 line
That's all rather inconsistent.
You're right. I'll change it.
Quoted 8 lines
Regards,
Dario
--
<<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)
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis
PATCH v4 3/4 libxl: enable per-VCPU parameter settings for RTDS scheduler
In reply to Chong LiAdd libxl_vcpu_sched_params_get/set and sched_rtds_vcpu_get/set functions to support per-VCPU settings.
---
Changes on PATCH v3:
1) Add sanity check on vcpuid
2) Add comments on per-domain and per-vcpu functions for libxl users
--- tools/libxl/libxl.c | 265 ++++++++++++++++++++++++++++++++++++++++---- tools/libxl/libxl.h | 17 +++ tools/libxl/libxl_types.idl | 16 +++ 3 files changed, 276 insertions(+), 22 deletions(-)
tools/libxl/libxl.c +243 -22
@@ -5854,6 +5854,156 @@ static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid,return 0 ; } +static int sched_rtds_validate_params (libxl__gc *gc,int period, +int budget,uint32_t *sdom_period, +uint32_t *sdom_budget) +{ +if (period !=LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT ) { +if (period <1 ) { +LOG (ERROR ,"VCPU period is not set or out of range, " +"valid values are larger than or equal to 1" ); +return 1 ; + } + *sdom_period = period; + } + +if (budget !=LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT ) { +if (budget <1 ) { +LOG (ERROR ,"VCPU budget is not set or out of range, " +"valid values are larger than or equal to 1" ); +return 1 ; + } + *sdom_budget = budget; + } + +if (budget > period) { +LOG (ERROR ,"VCPU budget is larger than VCPU period" ); +return 1 ; + } + +return 0 ; +} + +static int sched_rtds_vcpu_get (libxl__gc *gc,uint32_t domid, +libxl_vcpu_sched_params *scinfo) +{ +uint16_t num_vcpus; +int rc, i; +xc_dominfo_t info; +xen_domctl_schedparam_vcpu_t *vcpus; + + rc =xc_domain_getinfo (CTX ->xch, domid,1 , &info); +if (rc <0 ) { +LOGE (ERROR ,"getting domain info" ); +return ERROR_FAIL ; + } + +if (scinfo->num_vcpus ==0 ) + num_vcpus = info.max_vcpu_id +1 ; +else + num_vcpus = scinfo->num_vcpus; + +GCNEW_ARRAY (vcpus, num_vcpus); + +if (scinfo->num_vcpus >0 ) +for (i=0 ; i < num_vcpus; i++) { +if (scinfo->vcpus[i].vcpuid <0 || + scinfo->vcpus[i].vcpuid > info.max_vcpu_id) { +LOG (ERROR ,"VCPU index is out of range, " +"valid values are within range from 0 to %d" , + info.max_vcpu_id); +return ERROR_INVAL ; + } + vcpus[i].vcpuid = scinfo->vcpus[i].vcpuid; + }else +for (i=0 ; i < num_vcpus; i++) + vcpus[i].vcpuid = i; + + rc =xc_sched_rtds_vcpu_get (CTX ->xch, domid, vcpus, num_vcpus); +if (rc !=0 ) { +LOGE (ERROR ,"getting vcpu sched rtds" ); +return ERROR_FAIL ; + } + + scinfo->sched =LIBXL_SCHEDULER_RTDS ; +if (scinfo->num_vcpus ==0 ) { + scinfo->num_vcpus = num_vcpus; + scinfo->vcpus =libxl__calloc (NOGC , num_vcpus,sizeof (libxl_sched_params)); + } +for (i =0 ; i < num_vcpus; i++) { + scinfo->vcpus[i].period = vcpus[i].s.rtds.period; + scinfo->vcpus[i].budget = vcpus[i].s.rtds.budget; + scinfo->vcpus[i].vcpuid = vcpus[i].vcpuid; + } + +return 0 ; +} + +static int sched_rtds_vcpu_set (libxl__gc *gc,uint32_t domid, +const libxl_vcpu_sched_params *scinfo) +{ +int rc; +int i; +uint16_t max_vcpuid; +xc_dominfo_t info; +xen_domctl_schedparam_vcpu_t *vcpus; +int num_vcpus; + + rc =xc_domain_getinfo (CTX ->xch, domid,1 , &info); +if (rc <0 ) { +LOGE (ERROR ,"getting domain info" ); +return ERROR_FAIL ; + } + max_vcpuid = info.max_vcpu_id; + +if (scinfo->num_vcpus >0 ) { + num_vcpus = scinfo->num_vcpus; +GCNEW_ARRAY (vcpus, num_vcpus); +for (i =0 ; i < num_vcpus; i++) { +if (scinfo->vcpus[i].vcpuid <0 || + scinfo->vcpus[i].vcpuid > max_vcpuid) { +LOG (ERROR ,"VCPU index is out of range, " +"valid values are within range from 0 to %d" , + max_vcpuid); +return ERROR_INVAL ; + } + vcpus[i].vcpuid = scinfo->vcpus[i].vcpuid; + + rc =sched_rtds_validate_params (gc, + scinfo->vcpus[i].period, scinfo->vcpus[i].budget, + &vcpus[i].s.rtds.period, &vcpus[i].s.rtds.budget); +if (rc) +return ERROR_INVAL ; + } + }else { + num_vcpus = max_vcpuid +1 ; +GCNEW_ARRAY (vcpus, num_vcpus); + rc =sched_rtds_validate_params (gc, + scinfo->vcpus[0 ].period, scinfo->vcpus[0 ].budget, + &vcpus[0 ].s.rtds.period, &vcpus[0 ].s.rtds.budget); +if (rc) +return ERROR_INVAL ; +for (i =0 ; i < num_vcpus; i++) { + vcpus[i].vcpuid = i; + vcpus[i].s.rtds.period = scinfo->vcpus[0 ].period; + vcpus[i].s.rtds.budget = scinfo->vcpus[0 ].budget; + } + } + + rc =xc_sched_rtds_vcpu_set (CTX ->xch, domid, + vcpus, num_vcpus); +if (rc ==1 ) { +printf ("WARN: too small period or budget may " +"result in large scheduling overhead\n" ); + rc =0 ; + }else if (rc !=0 ) { +LOGE (ERROR ,"setting vcpu sched rtds" ); +return ERROR_FAIL ; + } + +return rc; +} +static int sched_rtds_domain_get (libxl__gc *gc,uint32_t domid,libxl_domain_sched_params *scinfo) {
@@ -5887,29 +6037,10 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,return ERROR_FAIL ; } -if (scinfo->period !=LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT ) { -if (scinfo->period <1 ) { -LOG (ERROR ,"VCPU period is not set or out of range, " -"valid values are larger than 1" ); -return ERROR_INVAL ; - } - sdom.period = scinfo->period; - } - -if (scinfo->budget !=LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT ) { -if (scinfo->budget <1 ) { -LOG (ERROR ,"VCPU budget is not set or out of range, " -"valid values are larger than 1" ); -return ERROR_INVAL ; - } - sdom.budget = scinfo->budget; - } - -if (sdom.budget > sdom.period) { -LOG (ERROR ,"VCPU budget is larger than VCPU period, " -"VCPU budget should be no larger than VCPU period" ); + rc =sched_rtds_validate_params (gc, scinfo->period, scinfo->budget, + &sdom.period, &sdom.budget); +if (rc)return ERROR_INVAL ; - } rc =xc_sched_rtds_domain_set (CTX ->xch, domid, &sdom);if (rc <0 ) {
@@ -5920,6 +6051,11 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,return 0 ; } +/* Set the per-domain scheduling parameters. +* For schedulers that support per-vcpu settings (e.g., RTDS), +* calling *_domain_set functions will set all vcpus with the same +* scheduling parameters. +*/ int libxl_domain_sched_params_set (libxl_ctx *ctx,uint32_t domid,const libxl_domain_sched_params *scinfo) {
@@ -5956,6 +6092,52 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,return ret; } +/* Set the per-vcpu scheduling parameters */ +int libxl_vcpu_sched_params_set (libxl_ctx *ctx,uint32_t domid, +const libxl_vcpu_sched_params *scinfo) +{ +GC_INIT (ctx); +libxl_scheduler sched = scinfo->sched; +int ret; + +if (sched ==LIBXL_SCHEDULER_UNKNOWN ) + sched =libxl__domain_scheduler (gc, domid); + +switch (sched) { +case LIBXL_SCHEDULER_SEDF : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT2 : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_ARINC653 : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_RTDS : + ret =sched_rtds_vcpu_set (gc, domid, scinfo); +break ; +default : +LOG (ERROR ,"Unknown scheduler" ); + ret =ERROR_INVAL ; +break ; + } + +GC_FREE ; +return ret; +} + +/* Get the per-domain scheduling parameters. +* For schedulers that support per-vcpu settings (e.g., RTDS), +* calling *_domain_get functions will get default scheduling +* parameters. +*/ int libxl_domain_sched_params_get (libxl_ctx *ctx,uint32_t domid,libxl_domain_sched_params *scinfo) {
@@ -5989,6 +6171,45 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,return ret; } +/* Get the per-vcpu scheduling parameters */ +int libxl_vcpu_sched_params_get (libxl_ctx *ctx,uint32_t domid, +libxl_vcpu_sched_params *scinfo) +{ +GC_INIT (ctx); +int ret; + + scinfo->sched =libxl__domain_scheduler (gc, domid); + +switch (scinfo->sched) { +case LIBXL_SCHEDULER_SEDF : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT2 : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_ARINC653 : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_RTDS : + ret =sched_rtds_vcpu_get (gc, domid, scinfo); +break ; +default : +LOG (ERROR ,"Unknown scheduler" ); + ret =ERROR_INVAL ; +break ; + } + +GC_FREE ; +return ret; +} +static int libxl__domain_s3_resume (libxl__gc *gc,int domid) {int rc =0 ;
tools/libxl/libxl.h +17 -0
@@ -200,6 +200,16 @@#define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1/* +* libxl_vcpu_sched_params is used to store per-vcpu params +*/ +#define LIBXL_HAVE_VCPU_SCHED_PARAMS 1 + +/* +* libxl_sched_params is used to store the array of per-vcpu params +*/ +#define LIBXL_HAVE_SCHED_PARAMS 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility
@@ -1554,10 +1564,17 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid,#define LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT -1#define LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT -1 +/* Per-VCPU parameters*/ +#define LIBXL_SCHED_PARAM_VCPU_INDEX_DEFAULT -1 +int libxl_domain_sched_params_get (libxl_ctx *ctx,uint32_t domid,libxl_domain_sched_params *params);int libxl_domain_sched_params_set (libxl_ctx *ctx,uint32_t domid,const libxl_domain_sched_params *params); +int libxl_vcpu_sched_params_get (libxl_ctx *ctx,uint32_t domid, +libxl_vcpu_sched_params *params); +int libxl_vcpu_sched_params_set (libxl_ctx *ctx,uint32_t domid, +const libxl_vcpu_sched_params *params);int libxl_send_trigger (libxl_ctx *ctx,uint32_t domid,libxl_trigger trigger,uint32_t vcpuid);
tools/libxl/libxl_types.idl +16 -0
@@ -351,6 +351,22 @@ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), ]) +libxl_sched_params = Struct("sched_params",[ + ("vcpuid", integer, {'init_val': 'LIBXL_SCHED_PARAM_VCPU_INDEX_DEFAULT'}), + ("weight", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT'}), + ("cap", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT'}), + ("period", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT'}), + ("slice", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT'}), + ("latency", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT'}), + ("extratime", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT'}), + ("budget", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}), + ]) + +libxl_vcpu_sched_params = Struct("vcpu_sched_params",[ + ("sched", libxl_scheduler), + ("vcpus", Array(libxl_sched_params, "num_vcpus")), + ]) + libxl_domain_sched_params = Struct("domain_sched_params",[ ("sched", libxl_scheduler), ("weight", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT'}),
Signature · 1 line
1.9.1
Re: [PATCH v4 for Xen 4.6 3/4] libxl: enable per-VCPU parameter settings for RTDS scheduler
Quoted 3 lines · Chong Li
Add libxl_vcpu_sched_params_get/set and sched_rtds_vcpu_get/set functions to support per-VCPU settings.
This patch looks mostly fine. A few comments.
So, as for the other patches, I'd mention here in the changelog, that only RTDS supports this for now.
Quoted 5 lines
tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5864
Quoted 9 lines
tools/libxl/libxl.c +8
-0+static int sched_rtds_validate_params (libxl__gc *gc,int period, +int budget,uint32_t *sdom_period, +uint32_t *sdom_budget) +{ +if (period !=LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT ) { +if (period <1 ) { +LOG (ERROR ,"VCPU period is not set or out of range, " +"valid values are larger than or equal to 1" );
That's probably a nit, but, if period is not set, as the error message says, it means it stays LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT? In which case you do not enter this branch, and you do not print this message, do you?
What I mean is that, it looks to me that it's not accurate for the message to say "period not set", or am I overlooking something?
Quoted 2 lines
+ return 1;
So, 1 is error, 0 is ok. That's fine, as this is an internal function, but please, add a quick doc comment above it.
Quoted 6 lines
tools/libxl/libxl.c +5
-0+ } + *sdom_period = period; + } + +if (budget !=LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT ) {
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5880
Quoted 10 lines
tools/libxl/libxl.c +10
-0+if (budget <1 ) { +LOG (ERROR ,"VCPU budget is not set or out of range, " +"valid values are larger than or equal to 1" ); +return 1 ; + } + *sdom_budget = budget; + } + +if (budget > period) { +LOG (ERROR ,"VCPU budget is larger than VCPU period" );
I'd be more explicit: "VCPU budget must be smaller than VCPU period".
Quoted 15 lines
tools/libxl/libxl.c +15
-0+return 1 ; + } + +return 0 ; +} + +static int sched_rtds_vcpu_get (libxl__gc *gc,uint32_t domid, +libxl_vcpu_sched_params *scinfo) +{ +uint16_t num_vcpus; +int rc, i; +xc_dominfo_t info; +xen_domctl_schedparam_vcpu_t *vcpus; + + rc =xc_domain_getinfo (CTX ->xch, domid,1 , &info);
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5905
Quoted 10 lines
tools/libxl/libxl.c +10
-0+if (rc <0 ) { +LOGE (ERROR ,"getting domain info" ); +return ERROR_FAIL ; + } + +if (scinfo->num_vcpus ==0 ) + num_vcpus = info.max_vcpu_id +1 ; +else + num_vcpus = scinfo->num_vcpus; +
num_vcpus = scinfo->num_vcpus ? scinfo->num_vcpus :
info->max_vcpu_id + 1;
(And I think there is a 'contracted' form of this, but I keep forgetting it, and I'm not sure whether it's a GCC extension...)
Quoted 17 lines
tools/libxl/libxl.c +16
-0+GCNEW_ARRAY (vcpus, num_vcpus); + +if (scinfo->num_vcpus >0 ) +for (i=0 ; i < num_vcpus; i++) { +if (scinfo->vcpus[i].vcpuid <0 || + scinfo->vcpus[i].vcpuid > info.max_vcpu_id) { +LOG (ERROR ,"VCPU index is out of range, " +"valid values are within range from 0 to %d" , + info.max_vcpu_id); +return ERROR_INVAL ; + } + vcpus[i].vcpuid = scinfo->vcpus[i].vcpuid; + }else +for (i=0 ; i < num_vcpus; i++) + vcpus[i].vcpuid = i; +
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5931
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ rc =xc_sched_rtds_vcpu_get (CTX ->xch, domid, vcpus, num_vcpus); +if (rc !=0 ) { +LOGE (ERROR ,"getting vcpu sched rtds" ); +return ERROR_FAIL ; + } + + scinfo->sched =LIBXL_SCHEDULER_RTDS ; +if (scinfo->num_vcpus ==0 ) { + scinfo->num_vcpus = num_vcpus; + scinfo->vcpus =libxl__calloc (NOGC , num_vcpus,sizeof (libxl_sched_params));
This line looks a long...
Quoted 36 lines
tools/libxl/libxl.c +35
-0+ } +for (i =0 ; i < num_vcpus; i++) { + scinfo->vcpus[i].period = vcpus[i].s.rtds.period; + scinfo->vcpus[i].budget = vcpus[i].s.rtds.budget; + scinfo->vcpus[i].vcpuid = vcpus[i].vcpuid; + } + +return 0 ; +} + +static int sched_rtds_vcpu_set (libxl__gc *gc,uint32_t domid, +const libxl_vcpu_sched_params *scinfo) +{ +int rc; +int i; +uint16_t max_vcpuid; +xc_dominfo_t info; +xen_domctl_schedparam_vcpu_t *vcpus; +int num_vcpus; + + rc =xc_domain_getinfo (CTX ->xch, domid,1 , &info); +if (rc <0 ) { +LOGE (ERROR ,"getting domain info" ); +return ERROR_FAIL ; + } + max_vcpuid = info.max_vcpu_id; + +if (scinfo->num_vcpus >0 ) { + num_vcpus = scinfo->num_vcpus; +GCNEW_ARRAY (vcpus, num_vcpus); +for (i =0 ; i < num_vcpus; i++) { +if (scinfo->vcpus[i].vcpuid <0 || + scinfo->vcpus[i].vcpuid > max_vcpuid) { + LOG(ERROR, "VCPU index is out of range, " + "valid values are within range from 0 to %d",
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5976
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ max_vcpuid); +return ERROR_INVAL ; + } + vcpus[i].vcpuid = scinfo->vcpus[i].vcpuid; + + rc =sched_rtds_validate_params (gc, + scinfo->vcpus[i].period, scinfo->vcpus[i].budget, + &vcpus[i].s.rtds.period, &vcpus[i].s.rtds.budget); +if (rc) +return ERROR_INVAL ;
if (sched_rtds_validate_params(gc, scinfo->vcpus[i].period,
scinfo->vcpus[i].budget,
&vcpus[i].s.rtds.period,
&vcpus[i].s.rtds.budget))
return ERROR_INVAL;I.e., I don't think you need to save rc.
Quoted 13 lines
tools/libxl/libxl.c +12
-0+ } + }else { + num_vcpus = max_vcpuid +1 ; +GCNEW_ARRAY (vcpus, num_vcpus); + rc =sched_rtds_validate_params (gc, + scinfo->vcpus[0 ].period, scinfo->vcpus[0 ].budget, + &vcpus[0 ].s.rtds.period, &vcpus[0 ].s.rtds.budget); +if (rc) +return ERROR_INVAL ; +for (i =0 ; i < num_vcpus; i++) { + vcpus[i].vcpuid = i; + vcpus[i].s.rtds.period = scinfo->vcpus[0 ].period;
tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5998
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ vcpus[i].s.rtds.budget = scinfo->vcpus[0 ].budget; + } + } + + rc =xc_sched_rtds_vcpu_set (CTX ->xch, domid, + vcpus, num_vcpus); +if (rc ==1 ) { +printf ("WARN: too small period or budget may " +"result in large scheduling overhead\n" ); + rc =0 ;
As said, do the logging in Xen directly, and ditch this.
Quoted 28 lines
tools/libxl/libxl.c +7
-16+ }else if (rc !=0 ) { +LOGE (ERROR ,"setting vcpu sched rtds" ); +return ERROR_FAIL ; + } + +return rc; +}@@ -5887,29 +6037,10 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,return ERROR_FAIL ; } -if (scinfo->period !=LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT ) { -if (scinfo->period <1 ) { -LOG (ERROR ,"VCPU period is not set or out of range, " -"valid values are larger than 1" ); -return ERROR_INVAL ; - } - sdom.period = scinfo->period; - } - -if (scinfo->budget !=LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT ) { -if (scinfo->budget <1 ) { -LOG (ERROR ,"VCPU budget is not set or out of range, " -"valid values are larger than 1" ); -return ERROR_INVAL ; - } - sdom.budget = scinfo->budget;
tools/libxl/libxl.c static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid, · line 6044
Quoted 10 lines
tools/libxl/libxl.c +3
-5- } - -if (sdom.budget > sdom.period) { -LOG (ERROR ,"VCPU budget is larger than VCPU period, " -"VCPU budget should be no larger than VCPU period" ); + rc =sched_rtds_validate_params (gc, scinfo->period, scinfo->budget, + &sdom.period, &sdom.budget); +if (rc)return ERROR_INVAL ;
Ditto.
Quoted 24 lines
tools/libxl/libxl.c +10
-1- }@@ -5920,6 +6051,11 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,return 0 ; } +/* Set the per-domain scheduling parameters. +* For schedulers that support per-vcpu settings (e.g., RTDS), +* calling *_domain_set functions will set all vcpus with the same +* scheduling parameters. +*/ int libxl_domain_sched_params_set (libxl_ctx *ctx,uint32_t domid,const libxl_domain_sched_params *scinfo) {@@ -5956,6 +6092,52 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,return ret; } +/* Set the per-vcpu scheduling parameters */ +int libxl_vcpu_sched_params_set (libxl_ctx *ctx,uint32_t domid, +const libxl_vcpu_sched_params *scinfo) +{ +GC_INIT (ctx);
tools/libxl/libxl.c int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid, · line 6109
Quoted 10 lines
tools/libxl/libxl.c +9
-0+libxl_scheduler sched = scinfo->sched; +int ret; + +if (sched ==LIBXL_SCHEDULER_UNKNOWN ) + sched =libxl__domain_scheduler (gc, domid); + +switch (sched) { +case LIBXL_SCHEDULER_SEDF : +LOG (ERROR ,"No per-vcpu set function provided" );
I'd say: "per-VCPU parameter setting not supported for this scheduler".
Quoted 4 lines
tools/libxl/libxl.c +4
-0+ ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT : +LOG (ERROR ,"No per-vcpu set function provided" );
tools/libxl/libxl.c int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid, · line 6122
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT2 : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_ARINC653 : +LOG (ERROR ,"No per-vcpu set function provided" ); + ret =ERROR_INVAL ; +break ;
BTW, Can't you unify all the !supported cases?
Quoted 20 lines
tools/libxl/libxl.c +15
-0+case LIBXL_SCHEDULER_RTDS : + ret =sched_rtds_vcpu_set (gc, domid, scinfo); +break ; +default : +LOG (ERROR ,"Unknown scheduler" ); + ret =ERROR_INVAL ; +break ; + } + +GC_FREE ; +return ret; +}@@ -5989,6 +6171,45 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,return ret; } +/* Get the per-vcpu scheduling parameters */ +int libxl_vcpu_sched_params_get (libxl_ctx *ctx,uint32_t domid, +libxl_vcpu_sched_params *scinfo)
tools/libxl/libxl.c int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid, · line 6186
Quoted 10 lines
tools/libxl/libxl.c +9
-0+{ +GC_INIT (ctx); +int ret; + + scinfo->sched =libxl__domain_scheduler (gc, domid); + +switch (scinfo->sched) { +case LIBXL_SCHEDULER_SEDF : +LOG (ERROR ,"No per-vcpu get function provided" );
Same here.
Quoted 7 lines
tools/libxl/libxl.c +7
-0+ ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_CREDIT2 :
tools/libxl/libxl.c int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid, · line 6202
Quoted 10 lines
tools/libxl/libxl.c +10
-0+LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_ARINC653 : +LOG (ERROR ,"No per-vcpu get function provided" ); + ret =ERROR_INVAL ; +break ; +case LIBXL_SCHEDULER_RTDS : + ret =sched_rtds_vcpu_get (gc, domid, scinfo); +break ;
And here.
Quoted 18 lines
tools/libxl/libxl.c +9
-0+default : +LOG (ERROR ,"Unknown scheduler" ); + ret =ERROR_INVAL ; +break ; + } + +GC_FREE ; +return ret; +}tools/libxl/libxl.h +0
-0@@ -200,6 +200,16 @@#define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1/*
tools/libxl/libxl.h line 212
Quoted 10 lines
tools/libxl/libxl.h +9
-0+* libxl_vcpu_sched_params is used to store per-vcpu params +*/ +#define LIBXL_HAVE_VCPU_SCHED_PARAMS 1 + +/* +* libxl_sched_params is used to store the array of per-vcpu params +*/ +#define LIBXL_HAVE_SCHED_PARAMS 1 +
I may be misremembering, but did not we say that one of these LIBXL_HAVE_* was enough?
If we want to have two, I'd much rather have a generic one (LIBXL_HAVE_VCPU_SCHED_PARAMS) and one announcing that the feature is supported by RTDS (e.g., LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS).
This way, if/when we'll add support for per-VCPU parameters in Credit, we'd add LIBXL_HAVE_SCHED_CREDIT_VCPU_PARAMS.
But that's just an idea, it's best to see what tools maintainers think of this.
BTW, be a little more verbose in commenting these macros. Just have a look and take inspiration from the already existing ones.
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]
http://lists.xen.org/xen-devel
Re: [PATCH v4 for Xen 4.6 3/4] libxl: enable per-VCPU parameter settings for RTDS scheduler
Quoted 22 lines · Dario Faggioli
Quoted 5 lines · Chong Li
tools/libxl/libxl.c +0
-0tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5864
Quoted 9 lines
tools/libxl/libxl.c +8
-0+static int sched_rtds_validate_params (libxl__gc *gc,int period, +int budget,uint32_t *sdom_period, +uint32_t *sdom_budget) +{ +if (period !=LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT ) { +if (period <1 ) { +LOG (ERROR ,"VCPU period is not set or out of range, " +"valid values are larger than or equal to 1" );That's probably a nit, but, if period is not set, as the error message says, it means it stays
LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT? In which case you do not enter this branch, and you do not print this message, do you?
Quoted 2 lines
What I mean is that, it looks to me that it's not accurate for the message to say "period not set", or am I overlooking something?
If the period is empty (which means its value == 0), we consider it as "period not set". Actually, I think maybe we can just delete this "not set" warning, because in xl, we've already done a sanity check to make sure period is not empty.
Quoted 5 lines
Quoted 3 lines
+ return 1;
So, 1 is error, 0 is ok. That's fine, as this is an internal function, but please, add a quick doc comment above it.
Sure.
Quoted 29 lines
Quoted 19 lines
tools/libxl/libxl.c +14
-0+return 1 ; + } + } + }else { + num_vcpus = max_vcpuid +1 ; +GCNEW_ARRAY (vcpus, num_vcpus); + rc =sched_rtds_validate_params (gc, + scinfo->vcpus[0 ].period, scinfo->vcpus[0 ].budget, + &vcpus[0 ].s.rtds.period, &vcpus[0 ].s.rtds.budget); +if (rc) +return ERROR_INVAL ; +for (i =0 ; i < num_vcpus; i++) { + vcpus[i].vcpuid = i; + vcpus[i].s.rtds.period = scinfo->vcpus[0 ].period;tools/libxl/libxl.c static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid, · line 5998
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ vcpus[i].s.rtds.budget = scinfo->vcpus[0 ].budget; + } + } + + rc =xc_sched_rtds_vcpu_set (CTX ->xch, domid, + vcpus, num_vcpus); +if (rc ==1 ) { +printf ("WARN: too small period or budget may " +"result in large scheduling overhead\n" ); + rc =0 ;
Quoted 1 line
As said, do the logging in Xen directly, and ditch this.
Do I use "printk" function in Xen to output warning message?
Quoted 34 lines
Quoted 17 lines
tools/libxl/libxl.c +7
-0+ }else if (rc !=0 ) { +LOGE (ERROR ,"setting vcpu sched rtds" ); +return ERROR_FAIL ; + } + +return rc; +}tools/libxl/libxl.h +0
-0@@ -200,6 +200,16 @@#define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1/* tools/libxl/libxl.h line 212
Quoted 10 lines
tools/libxl/libxl.h +9
-0+* libxl_vcpu_sched_params is used to store per-vcpu params +*/ +#define LIBXL_HAVE_VCPU_SCHED_PARAMS 1 + +/* +* libxl_sched_params is used to store the array of per-vcpu params +*/ +#define LIBXL_HAVE_SCHED_PARAMS 1 +I may be misremembering, but did not we say that one of these LIBXL_HAVE_* was enough?
If we want to have two, I'd much rather have a generic one (
LIBXL_HAVE_VCPU_SCHED_PARAMS) and one announcing that the feature is supported by RTDS (e.g.,LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS).
Quoted 8 lines
This way, if/when we'll add support for per-VCPU parameters in Credit, we'd add
LIBXL_HAVE_SCHED_CREDIT_VCPU_PARAMS.But that's just an idea, it's best to see what tools maintainers think of this.
BTW, be a little more verbose in commenting these macros. Just have a look and take inspiration from the already existing ones.
Ok. I'll rewrite it.
Thanks,
Chong
Quoted 8 lines
Regards,
Dario
--
<<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)
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis
PATCH v4 4/4 xl: enable per-VCPU parameter settings for RTDS scheduler
In reply to Chong LiChange main_sched_rtds and related output functions to support per-VCPU settings.
---
Changes on PATCH v3:
1) Support commands, e.g., "xl sched-rtds -d vm1" to output the default scheduling parameters
--- docs/man/xl.pod.1 | 4 + tools/libxl/xl_cmdimpl.c | 292 +++++++++++++++++++++++++++++++++++++++++----- tools/libxl/xl_cmdtable.c | 10 +- 3 files changed, 274 insertions(+), 32 deletions(-)
docs/man/xl.pod.1 +4 -0
@@ -1093,6 +1093,10 @@ B<OPTIONS> Specify domain for which scheduler parameters are to be modified or retrieved. Mandatory for modifying scheduler parameters. +=item B<-v VCPUID/all>, B<--vcpuid=VCPUID/all> + +Specify vcpu for which scheduler parameters are to be modified or retrieved. + =item B<-p PERIOD>, B<--period=PERIOD> Period of time, in microseconds, over which to replenish the budget.
tools/libxl/xl_cmdimpl.c +264 -28
358 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +6 -4
@@ -284,10 +284,12 @@ struct cmd_spec cmd_table[] = { {"sched-rtds" , &main_sched_rtds,0 ,1 ,"Get/set rtds scheduler parameters" , -"[-d <Domain> [-p[=PERIOD]] [-b[=BUDGET]]]" , -"-d DOMAIN, --domain=DOMAIN Domain to modify\n" -"-p PERIOD, --period=PERIOD Period (us)\n" -"-b BUDGET, --budget=BUDGET Budget (us)\n" +"[-d <Domain> [-v[=VCPUID]] [-p[=PERIOD]] [-b[=BUDGET]]]" , +"-d DOMAIN, --domain=DOMAIN Domain to modify\n" +"-v VCPUID/all, --vcpuid=VCPUID/all VCPU to modify or output;\n" +" Using '-v all' to modify/output all vcpus\n" +"-p PERIOD, --period=PERIOD Period (us)\n" +"-b BUDGET, --budget=BUDGET Budget (us)\n" }, { "domid", &main_domid, 0, 0,
Signature · 1 line
1.9.1
Re: [PATCH v4 for Xen 4.6 4/4] xl: enable per-VCPU parameter settings for RTDS scheduler
Quoted 3 lines · Chong Li
Change
main_sched_rtdsand related output functions to support per-VCPU settings.
This patch also looks nice. A few comments provided inline.
Quoted 14 lines
tools/libxl/xl_cmdimpl.c +6
-0@@ -5630,6 +5630,37 @@ static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo)return rc; } +static int sched_vcpu_get (libxl_scheduler sched,int domid, +libxl_vcpu_sched_params *scinfo) +{ +int rc; + + rc =libxl_vcpu_sched_params_get (ctx, domid, scinfo);
tools/libxl/xl_cmdimpl.c static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo) · line 5648
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +9
-0+if (rc) { +fprintf (stderr,"libxl_vcpu_sched_params_get failed.\n" ); +return rc; + } +if (scinfo->sched != sched) { +fprintf (stderr,"libxl_vcpu_sched_params_get returned %s not %s.\n" , +libxl_scheduler_to_string (scinfo->sched), +libxl_scheduler_to_string (sched)); +return ERROR_INVAL ;
We are in xl, so there's no need to use libxl error code. It's probably not strictly forbidden either, and xl itself is really inconsistent about this, I know.
Personally, I never use them, and I think that using them may be confusing, and create even more inconsistency.
tools/libxl/xl_cmdimpl.c static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo)
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +9
-0+static int sched_vcpu_set (int domid,const libxl_vcpu_sched_params *scinfo) +{ +int rc; + + rc =libxl_vcpu_sched_params_set (ctx, domid, scinfo); +if (rc) +fprintf (stderr,"libxl_vcpu_sched_params_set failed.\n" ); + +return rc;
In xl, when failing, most of the time we exit(-1), or something like that. So, it's important that you log what's happening, but then there's no need to save the return codes and propagate them.
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +0
-0static int sched_credit_params_set (int poolid,libxl_sched_credit_params *scinfo) {int rc;@@ -5786,6 +5817,38 @@ out:return rc; }
tools/libxl/xl_cmdimpl.c out: · line 5828
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +8
-0+static int sched_rtds_vcpu_output ( +int domid,libxl_vcpu_sched_params *scinfo) +{ +char *domname; +int rc =0 ; +int i; + +if (domid <0 ) {
Style (indentation). This is not the only instance of something like this in this patch.
tools/libxl/xl_cmdimpl.c out:
Quoted 12 lines
tools/libxl/xl_cmdimpl.c +11
-0+printf ("%-33s %4s %4s %9s %9s\n" ,"Name" ,"ID" , +"VCPU" ,"Period" ,"Budget" ); +return 0 ; + } + + rc =sched_vcpu_get (LIBXL_SCHEDULER_RTDS , domid, scinfo); +if (rc) + goto out; + + domname =libxl_domid_to_name (ctx, domid); +for ( i =0 ; i < scinfo->num_vcpus; i++ ) {
Style:
for (i = 0; i < scinfo->num_vcpus; i++) {and indentation, I think.
tools/libxl/xl_cmdimpl.c out: · line 5851
Quoted 13 lines
tools/libxl/xl_cmdimpl.c +13
-0+printf ("%-33s %4d %4d %9" PRIu32" %9" PRIu32"\n" , + domname, + domid, + scinfo->vcpus[i].vcpuid, + scinfo->vcpus[i].period, + scinfo->vcpus[i].budget); + } +free (domname); + +out: +return rc; +} +
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]
http://lists.xen.org/xen-devel
Re: [PATCH v4 for Xen 4.6 4/4] xl: enable per-VCPU parameter settings for RTDS scheduler
Quoted 35 lines · Dario Faggioli
Quoted 3 lines · Chong Li
Change
main_sched_rtdsand related output functions to support per-VCPU settings.This patch also looks nice. A few comments provided inline.
Quoted 14 lines
tools/libxl/xl_cmdimpl.c +6
-0@@ -5630,6 +5630,37 @@ static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo)return rc; } +static int sched_vcpu_get (libxl_scheduler sched,int domid, +libxl_vcpu_sched_params *scinfo) +{ +int rc; + + rc =libxl_vcpu_sched_params_get (ctx, domid, scinfo);tools/libxl/xl_cmdimpl.c static int sched_domain_set(int domid, const libxl_domain_sched_params *scinfo) · line 5648
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +9
-0+if (rc) { +fprintf (stderr,"libxl_vcpu_sched_params_get failed.\n" ); +return rc; + } +if (scinfo->sched != sched) { +fprintf (stderr,"libxl_vcpu_sched_params_get returned %s not %s.\n" , +libxl_scheduler_to_string (scinfo->sched), +libxl_scheduler_to_string (sched)); +return ERROR_INVAL ;We are in xl, so there's no need to use libxl error code. It's probably not strictly forbidden either, and xl itself is really inconsistent about this, I know.
Quoted 3 lines
Personally, I never use them, and I think that using them may be confusing, and create even more inconsistency.
What error code should I use here? Do I also need to change the "ERROR_INVAL" in function sched_domain_get?
Quoted 5 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)
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis
Hi Chong
This series is marked as "for 4.6", but we just hit feature freeze yesterday.
Given the status of this series (missing many acks), I am sorry to say this series will have to wait until next release.
We will review this series in timely manner provided there are no other urgent matters for the release. Please keep up with your good work.
Wei.
Quoted 5 lines · Wei Liu
Hi Chong
This series is marked as "for 4.6", but we just hit feature freeze yesterday.
Yeah, I wanted to reply myself about this, but Wei beat me... Good job as release manager, I would say. :-)
Quoted 3 lines
Given the status of this series (missing many acks), I am sorry to say this series will have to wait until next release.
Indeed. The series is starting to look good, and, Chong, you're doing a great work, especially by replying promptly to reviews, and reposting new versions very quickly.
However, this series arrived a bit late in the dev cycle, and suffered from some delay in reviewing (from me as well, sorry for that), but (both) this things happen in (Open Source) software development, and we can't do much about it.
Also, the original goal was to pull RTDS out of experimental, but, even with this series in, we wouldn't get to there as:
- not enough testing: it entered OSSTest not so long ago, which, e.g., showed up it's failing on ARM!
- not enough benchmarks/performance figures: I'd like to have the latency numbers, e.g., from cyclictest, we've spoke many times with Meng, give our official blessing at using it
- the work Dagaen's doing is a rather fundamental restructuring, and it makes sense to do all the above (testing and performance evaluation) on top of the result of that for a bit, before declaring things stable and supported (or we risk disrupting that because of it, and since it's already ongoing, I'll really let him finish)
So, for the following reasons (coming from the above reasoning):
- the series is good, but certainly still not ready;
- having the series in, would not change much wrt RTDS in 4.6
I, as the maintainer of this feature, agree with Wei that we should work toward merging this series really soon... at the beginning of 4.7 development cycle! :-D
Quoted 3 lines
We will review this series in timely manner provided there are no other urgent matters for the release. Please keep up with your good work.
Indeed. Thanks a log again to you, Meng, Dagaen, and everyone.
I'll review the series ASAP.
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]
http://lists.xen.org/xen-devel
Hi Dario,
- not enough benchmarks/performance figures: I'd like to have the
Quoted 2 lines
latency numbers, e.g., from cyclictest, we've spoke many times with Meng, give our official blessing at using it
Considering t
he improved version Dagaen is working on should be able to improve the efficiency of the scheduler "a lot"
,
I will evaluate the performance of the RTDS scheduler with cyclictest once Dagaen have the improved version done.
Thanks,
Meng
-----------
Meng Xu
PhD Student in Computer and Information Science
University of Pennsylvania
http://www.cis.upenn.edu/~mengxu/
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 2 lines · Meng Xu
Hi Dario,
Hi,
Quoted 7 lines
- not enough benchmarks/performance figures: I'd like to have
the
latency numbers, e.g., from cyclictest, we've spoke many
times with
Meng, give our official blessing at using it
Quoted 7 lines
Considering t
he improved version Dagaen is working on should be able to improve the efficiency of the scheduler "a lot"
,
I will evaluate the performance of the RTDS scheduler with cyclictest once Dagaen have the improved version done.
Sure thing! It actually was part of my own reasoning about why we want to wait. :-)
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]
http://lists.xen.org/xen-devel
Quoted 10 lines · Chong Li
Using "xl sched-rtds" will output the default scheduling parameters for each domain. An example would be like:
# xl sched-rtds Cpupool Pool-0: sched=RTDS Name ID Period Budget Domain-0 0 10000 4000 vm1 1 10000 4000 vm2 2 10000 4000
Quoted 7 lines
Using command, e.g., "xl sched-rtds -d vm1" will output the default scheduling parameters of vm1. An example would be like:
# xl sched-rtds -d vm1 Name ID Period Budget vm1 1 10000 4000
Thanks for making these two works.
I think it would be great if we could, in this case, output somehow and somewhere that we are actually showing some defaults, instead than anything that is really in use.
I don't know whether with something like this:
# xl sched-rtds Cpupool Pool-0: sched=RTDS Name ID Period Budget Domain-0 (defaults) 0 10000 4000 vm1 (defaults) 1 10000 4000 vm2 (defaults) 2 10000 4000
# xl sched-rtds -d vm1 Name ID Period Budget vm1 (defaults) 1 10000 4000
Or by "just" adding a note before the actual output:
# xl sched-rtds -d vm1 Showing per-vm(s) default scheduling parameters, use `-v' for seeing the actual parameters of each vcpu Name ID Period Budget vm1 1 10000 4000
The latter is more verbose, but I think is what I see as more useful (and, probably, the easier to implement).
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]
http://lists.xen.org/xen-devel
Quoted 5 lines · Dario Faggioli
On Fri, 2015-07-10 at 23:52 -0500, Chong Li wrote:
Or by "just" adding a note before the actual output:
Quoted 8 lines
# xl sched-rtds -d vm1 Showing per-vm(s) default scheduling parameters, use `-v' for seeing the actual parameters of each vcpu Name ID Period Budget vm1 1 10000 4000The latter is more verbose, but I think is what I see as more useful (and, probably, the easier to implement).
I agree. I'll add it in the next version.
Quoted 8 lines
Regards,
Dario
--
<<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)
Signature · 3 lines
Chong Li Department of Computer Science and Engineering Washington University in St.louis