On Mon, 2015-05-25 at 19:05 -0500, Chong Li wrote: > diff --git a/xen/common/domctl.c b/xen/common/domctl.c > index 28aea55..8143c44 100644 > --- a/xen/common/domctl.c > +++ b/xen/common/domctl.c > @@ -841,6 +841,11 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) > u_domctl) > copyback = 1; > break; > > + case XEN_DOMCTL_scheduler_vcpu_op: > + ret = sched_adjust_vcpu(d, &op->u.scheduler_vcpu_op); > + copyback = 1; > + break; > + > So, thinking more about this, do we really want a full new DOMCTL, or do we want to instrument XEN_DOMCTL_scheduler_op? That would mean adding two operations there, and fiddling with struct xen_domctl_scheduler_op?
The problem I see is that, whatever I imagine putting this, there would be some redundancy. Quick-&-dirty, I put together the below... would it possibly make sense? 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_domctl_sched_rtds_t; typedef union xen_domctl_schedparam { xen_domctl_sched_credit_t credit; xen_domctl_sched_credit2_t credit2; xen_domctl_sched_rtds_t rtds; } xen_domctl_schedparam_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; } 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 { xen_domctl_schedparam_t d; 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; DEFINE_XEN_GUEST_HANDLE(xen_domctl_scheduler_op_t); I'm also attaching a (build-tested only) patch to that effect (I'm killing SEDF in there, so I don't have to care about it, as it's going away anyway). Thoughts? > /* > - * set/get each vcpu info of each domain > + * set/get per-domain params of a domain > */ > static int > rt_dom_cntl( > @@ -1115,6 +1115,74 @@ rt_dom_cntl( > return rc; > } > > +/* > + * set/get per-vcpu params of a domain > + */ > +static int > +rt_vcpu_cntl( > + const struct scheduler *ops, > + struct domain *d, > + struct xen_domctl_scheduler_vcpu_op *op) > +{ > I commented this function already, while replying to Jan. > +/* Adjust scheduling parameter for the vcpus of a given domain. */ > +long sched_adjust_vcpu( > + struct domain *d, > + struct xen_domctl_scheduler_vcpu_op *op) > +{ > Actually, I don't think you even need this function. Especially if we take the path of doing all this as subops of DOMCTL_scheduler_op, you can just use sched_adjust, do some more multiplexing in there, and the call the proper scheduler hook. Thanks and 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)
diff --git a/xen/common/Makefile b/xen/common/Makefile index 1cddebc..3fdf931 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -31,7 +31,6 @@ obj-y += rbtree.o obj-y += rcupdate.o obj-y += sched_credit.o obj-y += sched_credit2.o -obj-y += sched_sedf.o obj-y += sched_arinc653.o obj-y += sched_rt.o obj-y += schedule.o diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 953ecb0..43b086b 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1039,25 +1039,25 @@ csched_dom_cntl( if ( op->cmd == XEN_DOMCTL_SCHEDOP_getinfo ) { - op->u.credit.weight = sdom->weight; - op->u.credit.cap = sdom->cap; + op->u.d.credit.weight = sdom->weight; + op->u.d.credit.cap = sdom->cap; } else { ASSERT(op->cmd == XEN_DOMCTL_SCHEDOP_putinfo); - if ( op->u.credit.weight != 0 ) + if ( op->u.d.credit.weight != 0 ) { if ( !list_empty(&sdom->active_sdom_elem) ) { prv->weight -= sdom->weight * sdom->active_vcpu_count; - prv->weight += op->u.credit.weight * sdom->active_vcpu_count; + prv->weight += op->u.d.credit.weight * sdom->active_vcpu_count; } - sdom->weight = op->u.credit.weight; + sdom->weight = op->u.d.credit.weight; } - if ( op->u.credit.cap != (uint16_t)~0U ) - sdom->cap = op->u.credit.cap; + if ( op->u.d.credit.cap != (uint16_t)~0U ) + sdom->cap = op->u.d.credit.cap; } diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 75e0321..8992423 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1438,20 +1438,20 @@ csched2_dom_cntl( if ( op->cmd == XEN_DOMCTL_SCHEDOP_getinfo ) { - op->u.credit2.weight = sdom->weight; + op->u.d.credit2.weight = sdom->weight; } else { ASSERT(op->cmd == XEN_DOMCTL_SCHEDOP_putinfo); - if ( op->u.credit2.weight != 0 ) + if ( op->u.d.credit2.weight != 0 ) { struct list_head *iter; int old_weight; old_weight = sdom->weight; - sdom->weight = op->u.credit2.weight; + sdom->weight = op->u.d.credit2.weight; /* Update weights for vcpus, and max_weight for runqueues on which they reside */ list_for_each ( iter, &sdom->vcpu ) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 7c39a9e..c7efda3 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1091,12 +1091,12 @@ rt_dom_cntl( case XEN_DOMCTL_SCHEDOP_getinfo: 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.d.rtds.period = svc->period / MICROSECS(1); /* transfer to us */ + op->u.d.rtds.budget = svc->budget / MICROSECS(1); spin_unlock_irqrestore(&prv->lock, flags); break; case XEN_DOMCTL_SCHEDOP_putinfo: - if ( op->u.rtds.period == 0 || op->u.rtds.budget == 0 ) + if ( op->u.d.rtds.period == 0 || op->u.d.rtds.budget == 0 ) { rc = -EINVAL; break; @@ -1105,8 +1105,8 @@ rt_dom_cntl( list_for_each( iter, &sdom->vcpu ) { struct rt_vcpu * svc = list_entry(iter, struct rt_vcpu, sdom_elem); - svc->period = MICROSECS(op->u.rtds.period); /* transfer to nanosec */ - svc->budget = MICROSECS(op->u.rtds.budget); + svc->period = MICROSECS(op->u.d.rtds.period); /* transfer to nanosec */ + svc->budget = MICROSECS(op->u.d.rtds.budget); } spin_unlock_irqrestore(&prv->lock, flags); break; diff --git a/xen/common/schedule.c b/xen/common/schedule.c index f5a2e55..29f403c 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -65,7 +65,6 @@ DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); static const struct scheduler *schedulers[] = { - &sched_sedf_def, &sched_credit_def, &sched_credit2_def, &sched_arinc653_def, diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 88f8002..c1e25f4 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -330,31 +330,50 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_vcpus_t); #define XEN_SCHEDULER_ARINC653 7 #define XEN_SCHEDULER_RTDS 8 +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_domctl_sched_rtds_t; + +typedef union xen_domctl_schedparam { + xen_domctl_sched_credit_t credit; + xen_domctl_sched_credit2_t credit2; + xen_domctl_sched_rtds_t rtds; +} xen_domctl_schedparam_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; +} 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_schedparam_t d; + 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;
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel