diff mbox

[v6,for,Xen,4.7,2/4] libxc: enable per-VCPU parameter settings for RTDS scheduler

Message ID 1457286958-5427-3-git-send-email-lichong659@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chong Li March 6, 2016, 5:55 p.m. UTC
Add xc_sched_rtds_vcpu_get/set functions to interact with
Xen to get/set a domain's per-VCPU parameters.

Signed-off-by: Chong Li <chong.li@wustl.edu>
Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
Signed-off-by: Sisu Xi <xisisu@gmail.com>

---
Changes on PATCH v5:
1) In xc_sched_rtds_vcpu_get/set, re-issueing the hypercall
if it is preempted.

Changes on PATCH v4:
1) Minor modifications on the function parameters.

Changes on PATCH v2:
1) Minor modifications due to the change of struct xen_domctl_scheduler_op.

CC: <dario.faggioli@citrix.com>
CC: <george.dunlap@eu.citrix.com>
CC: <dgolomb@seas.upenn.edu>
CC: <mengxu@cis.upenn.edu>
CC: <wei.liu2@citrix.com>
CC: <lichong659@gmail.com>
---
 tools/libxc/include/xenctrl.h | 16 +++++++---
 tools/libxc/xc_rt.c           | 68 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 4 deletions(-)

Comments

Wei Liu March 8, 2016, 7:09 p.m. UTC | #1
On Sun, Mar 06, 2016 at 11:55:56AM -0600, Chong Li wrote:
> Add xc_sched_rtds_vcpu_get/set functions to interact with
> Xen to get/set a domain's per-VCPU parameters.
> 
> Signed-off-by: Chong Li <chong.li@wustl.edu>
> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
> Signed-off-by: Sisu Xi <xisisu@gmail.com>
> 
> ---
> Changes on PATCH v5:
> 1) In xc_sched_rtds_vcpu_get/set, re-issueing the hypercall
> if it is preempted.
> 
> Changes on PATCH v4:
> 1) Minor modifications on the function parameters.
> 
> Changes on PATCH v2:
> 1) Minor modifications due to the change of struct xen_domctl_scheduler_op.
> 
> CC: <dario.faggioli@citrix.com>
> CC: <george.dunlap@eu.citrix.com>
> CC: <dgolomb@seas.upenn.edu>
> CC: <mengxu@cis.upenn.edu>
> CC: <wei.liu2@citrix.com>
> CC: <lichong659@gmail.com>
> ---
>  tools/libxc/include/xenctrl.h | 16 +++++++---
>  tools/libxc/xc_rt.c           | 68 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 80 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 01a6dda..9462271 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -888,11 +888,19 @@ int xc_sched_credit2_domain_get(xc_interface *xch,
>                                 struct xen_domctl_sched_credit2 *sdom);
>  
>  int xc_sched_rtds_domain_set(xc_interface *xch,
> -                            uint32_t domid,
> -                            struct xen_domctl_sched_rtds *sdom);
> +                               uint32_t domid,
> +                               struct xen_domctl_sched_rtds *sdom);
>  int xc_sched_rtds_domain_get(xc_interface *xch,
> -                            uint32_t domid,
> -                            struct xen_domctl_sched_rtds *sdom);
> +                               uint32_t domid,
> +                               struct xen_domctl_sched_rtds *sdom);

Please don't mix fixing indentation with new functionality. Besides, the
new indentation looks wrong.

> +int xc_sched_rtds_vcpu_set(xc_interface *xch,
> +                               uint32_t domid,
> +                               struct xen_domctl_schedparam_vcpu *vcpus,
> +                               uint32_t num_vcpus);
> +int xc_sched_rtds_vcpu_get(xc_interface *xch,
> +                               uint32_t domid,
> +                               struct xen_domctl_schedparam_vcpu *vcpus,
> +                               uint32_t num_vcpus);
>  

Indentation also looks wrong. Maybe you used tab? Please use spaces
instead.

>  int
>  xc_sched_arinc653_schedule_set(
> diff --git a/tools/libxc/xc_rt.c b/tools/libxc/xc_rt.c
> index d59e5ce..4be9624 100644
> --- a/tools/libxc/xc_rt.c
> +++ b/tools/libxc/xc_rt.c
> @@ -62,3 +62,71 @@ int xc_sched_rtds_domain_get(xc_interface *xch,
>  
>      return rc;
>  }
> +

I only skim the rest but it looks sensible.

Wei.
Chong Li March 8, 2016, 7:32 p.m. UTC | #2
On Tue, Mar 8, 2016 at 1:09 PM, Wei Liu <wei.liu2@citrix.com> wrote:
> On Sun, Mar 06, 2016 at 11:55:56AM -0600, Chong Li wrote:
>> Add xc_sched_rtds_vcpu_get/set functions to interact with
>> Xen to get/set a domain's per-VCPU parameters.
>>
>> Signed-off-by: Chong Li <chong.li@wustl.edu>
>> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
>> Signed-off-by: Sisu Xi <xisisu@gmail.com>
>>
>> ---
>> Changes on PATCH v5:
>> 1) In xc_sched_rtds_vcpu_get/set, re-issueing the hypercall
>> if it is preempted.
>>
>> Changes on PATCH v4:
>> 1) Minor modifications on the function parameters.
>>
>> Changes on PATCH v2:
>> 1) Minor modifications due to the change of struct xen_domctl_scheduler_op.
>>
>> CC: <dario.faggioli@citrix.com>
>> CC: <george.dunlap@eu.citrix.com>
>> CC: <dgolomb@seas.upenn.edu>
>> CC: <mengxu@cis.upenn.edu>
>> CC: <wei.liu2@citrix.com>
>> CC: <lichong659@gmail.com>
>> ---
>>  tools/libxc/include/xenctrl.h | 16 +++++++---
>>  tools/libxc/xc_rt.c           | 68 +++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 80 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
>> index 01a6dda..9462271 100644
>> --- a/tools/libxc/include/xenctrl.h
>> +++ b/tools/libxc/include/xenctrl.h
>> @@ -888,11 +888,19 @@ int xc_sched_credit2_domain_get(xc_interface *xch,
>>                                 struct xen_domctl_sched_credit2 *sdom);
>>
>>  int xc_sched_rtds_domain_set(xc_interface *xch,
>> -                            uint32_t domid,
>> -                            struct xen_domctl_sched_rtds *sdom);
>> +                               uint32_t domid,
>> +                               struct xen_domctl_sched_rtds *sdom);
>>  int xc_sched_rtds_domain_get(xc_interface *xch,
>> -                            uint32_t domid,
>> -                            struct xen_domctl_sched_rtds *sdom);
>> +                               uint32_t domid,
>> +                               struct xen_domctl_sched_rtds *sdom);
>
> Please don't mix fixing indentation with new functionality. Besides, the
> new indentation looks wrong.
>
>> +int xc_sched_rtds_vcpu_set(xc_interface *xch,
>> +                               uint32_t domid,
>> +                               struct xen_domctl_schedparam_vcpu *vcpus,
>> +                               uint32_t num_vcpus);
>> +int xc_sched_rtds_vcpu_get(xc_interface *xch,
>> +                               uint32_t domid,
>> +                               struct xen_domctl_schedparam_vcpu *vcpus,
>> +                               uint32_t num_vcpus);
>>
>
> Indentation also looks wrong. Maybe you used tab? Please use spaces
> instead.
>
I'm not using tab. This is just what I'm confused with. The
indentation for these
four *rtds* functions is the same as the two *credit2* functions
above. I can not
find the indentation rules for function calls with many / long parameters.

Chong
Wei Liu March 8, 2016, 7:36 p.m. UTC | #3
On Tue, Mar 08, 2016 at 01:32:58PM -0600, Chong Li wrote:
> On Tue, Mar 8, 2016 at 1:09 PM, Wei Liu <wei.liu2@citrix.com> wrote:
> > On Sun, Mar 06, 2016 at 11:55:56AM -0600, Chong Li wrote:
> >> Add xc_sched_rtds_vcpu_get/set functions to interact with
> >> Xen to get/set a domain's per-VCPU parameters.
> >>
> >> Signed-off-by: Chong Li <chong.li@wustl.edu>
> >> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
> >> Signed-off-by: Sisu Xi <xisisu@gmail.com>
> >>
> >> ---
> >> Changes on PATCH v5:
> >> 1) In xc_sched_rtds_vcpu_get/set, re-issueing the hypercall
> >> if it is preempted.
> >>
> >> Changes on PATCH v4:
> >> 1) Minor modifications on the function parameters.
> >>
> >> Changes on PATCH v2:
> >> 1) Minor modifications due to the change of struct xen_domctl_scheduler_op.
> >>
> >> CC: <dario.faggioli@citrix.com>
> >> CC: <george.dunlap@eu.citrix.com>
> >> CC: <dgolomb@seas.upenn.edu>
> >> CC: <mengxu@cis.upenn.edu>
> >> CC: <wei.liu2@citrix.com>
> >> CC: <lichong659@gmail.com>
> >> ---
> >>  tools/libxc/include/xenctrl.h | 16 +++++++---
> >>  tools/libxc/xc_rt.c           | 68 +++++++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 80 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> >> index 01a6dda..9462271 100644
> >> --- a/tools/libxc/include/xenctrl.h
> >> +++ b/tools/libxc/include/xenctrl.h
> >> @@ -888,11 +888,19 @@ int xc_sched_credit2_domain_get(xc_interface *xch,
> >>                                 struct xen_domctl_sched_credit2 *sdom);
> >>
> >>  int xc_sched_rtds_domain_set(xc_interface *xch,
> >> -                            uint32_t domid,
> >> -                            struct xen_domctl_sched_rtds *sdom);
> >> +                               uint32_t domid,
> >> +                               struct xen_domctl_sched_rtds *sdom);
> >>  int xc_sched_rtds_domain_get(xc_interface *xch,
> >> -                            uint32_t domid,
> >> -                            struct xen_domctl_sched_rtds *sdom);
> >> +                               uint32_t domid,
> >> +                               struct xen_domctl_sched_rtds *sdom);
> >
> > Please don't mix fixing indentation with new functionality. Besides, the
> > new indentation looks wrong.
> >
> >> +int xc_sched_rtds_vcpu_set(xc_interface *xch,
> >> +                               uint32_t domid,
> >> +                               struct xen_domctl_schedparam_vcpu *vcpus,
> >> +                               uint32_t num_vcpus);
> >> +int xc_sched_rtds_vcpu_get(xc_interface *xch,
> >> +                               uint32_t domid,
> >> +                               struct xen_domctl_schedparam_vcpu *vcpus,
> >> +                               uint32_t num_vcpus);
> >>
> >
> > Indentation also looks wrong. Maybe you used tab? Please use spaces
> > instead.
> >
> I'm not using tab. This is just what I'm confused with. The
> indentation for these
> four *rtds* functions is the same as the two *credit2* functions
> above. I can not
> find the indentation rules for function calls with many / long parameters.
> 


Use white space and stay aligned with previous line wherever you can.
So:

int xc_sched_rtds_vcpu_get(xc_interface *xch,
                           uint32_t domid,
                           struct xen_domctl_schedparam_vcpu *vcpus,
                           uint32_t num_vcpus);

I know there is inconsistency in the code base. I'm sorry it makes you
feel confused.

Wei.

> Chong
> 
> -- 
> Chong Li
> Department of Computer Science and Engineering
> Washington University in St.louis
diff mbox

Patch

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 01a6dda..9462271 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -888,11 +888,19 @@  int xc_sched_credit2_domain_get(xc_interface *xch,
                                struct xen_domctl_sched_credit2 *sdom);
 
 int xc_sched_rtds_domain_set(xc_interface *xch,
-                            uint32_t domid,
-                            struct xen_domctl_sched_rtds *sdom);
+                               uint32_t domid,
+                               struct xen_domctl_sched_rtds *sdom);
 int xc_sched_rtds_domain_get(xc_interface *xch,
-                            uint32_t domid,
-                            struct xen_domctl_sched_rtds *sdom);
+                               uint32_t domid,
+                               struct xen_domctl_sched_rtds *sdom);
+int xc_sched_rtds_vcpu_set(xc_interface *xch,
+                               uint32_t domid,
+                               struct xen_domctl_schedparam_vcpu *vcpus,
+                               uint32_t num_vcpus);
+int xc_sched_rtds_vcpu_get(xc_interface *xch,
+                               uint32_t domid,
+                               struct xen_domctl_schedparam_vcpu *vcpus,
+                               uint32_t num_vcpus);
 
 int
 xc_sched_arinc653_schedule_set(
diff --git a/tools/libxc/xc_rt.c b/tools/libxc/xc_rt.c
index d59e5ce..4be9624 100644
--- a/tools/libxc/xc_rt.c
+++ b/tools/libxc/xc_rt.c
@@ -62,3 +62,71 @@  int xc_sched_rtds_domain_get(xc_interface *xch,
 
     return rc;
 }
+
+int xc_sched_rtds_vcpu_set(xc_interface *xch,
+                           uint32_t domid,
+                           struct xen_domctl_schedparam_vcpu *vcpus,
+                           uint32_t num_vcpus)
+{
+    int rc = 0;
+    unsigned processed = 0;
+    DECLARE_DOMCTL;
+    DECLARE_HYPERCALL_BOUNCE(vcpus, sizeof(*vcpus) * num_vcpus,
+            XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( xc_hypercall_bounce_pre(xch, vcpus) )
+        return -1;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain = (domid_t) domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_RTDS;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putvcpuinfo;
+
+    while ( processed < num_vcpus )
+    {
+        domctl.u.scheduler_op.u.v.nr_vcpus = num_vcpus - processed;
+        set_xen_guest_handle_offset(domctl.u.scheduler_op.u.v.vcpus, vcpus,
+                                    processed);
+        if ( (rc = do_domctl(xch, &domctl)) != 0 )
+            break;
+        processed += domctl.u.scheduler_op.u.v.nr_vcpus;
+    }
+
+    xc_hypercall_bounce_post(xch, vcpus);
+
+    return rc;
+}
+
+int xc_sched_rtds_vcpu_get(xc_interface *xch,
+                           uint32_t domid,
+                           struct xen_domctl_schedparam_vcpu *vcpus,
+                           uint32_t num_vcpus)
+{
+    int rc;
+    unsigned processed = 0;
+    DECLARE_DOMCTL;
+    DECLARE_HYPERCALL_BOUNCE(vcpus, sizeof(*vcpus) * num_vcpus,
+            XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+
+    if ( xc_hypercall_bounce_pre(xch, vcpus) )
+        return -1;
+
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain = (domid_t) domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_RTDS;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getvcpuinfo;
+
+    while ( processed < num_vcpus )
+    {
+        domctl.u.scheduler_op.u.v.nr_vcpus = num_vcpus - processed;
+        set_xen_guest_handle_offset(domctl.u.scheduler_op.u.v.vcpus, vcpus,
+                                    processed);
+        if ( (rc = do_domctl(xch, &domctl)) != 0 )
+            break;
+        processed += domctl.u.scheduler_op.u.v.nr_vcpus;
+    }
+
+    xc_hypercall_bounce_post(xch, vcpus);
+
+    return rc;
+}