All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Meng Xu <mengxu@cis.upenn.edu>
Cc: ian.campbell@citrix.com, xisisu@gmail.com,
	stefano.stabellini@eu.citrix.com, george.dunlap@eu.citrix.com,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	xumengpanda@gmail.com, JBeulich@suse.com, chaowang@wustl.edu,
	lichong659@gmail.com, dgolomb@seas.upenn.edu
Subject: Re: [PATCH v1 3/4] libxl: add rt scheduler
Date: Fri, 5 Sep 2014 12:21:07 +0200	[thread overview]
Message-ID: <1409912467.2673.288.camel@Solace.lan> (raw)
In-Reply-To: <1408921125-21470-4-git-send-email-mengxu@cis.upenn.edu>


[-- Attachment #1.1: Type: text/plain, Size: 7474 bytes --]

On dom, 2014-08-24 at 18:58 -0400, Meng Xu wrote:
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -5154,6 +5154,139 @@ static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid,
>      return 0;
>  }
>  
> +static int sched_rt_domain_get(libxl__gc *gc, uint32_t domid,
> +                               libxl_domain_sched_params *scinfo)
> +{
> +    struct xen_domctl_sched_rt_params* sdom;
> +    uint16_t num_vcpus;
> +    int rc, i;
> +
> +    rc = xc_sched_rt_domain_get_num_vcpus(CTX->xch, domid, &num_vcpus);
> +    if (rc != 0) {
> +        LOGE(ERROR, "getting num_vcpus of domain sched rt");
> +        return ERROR_FAIL;
> +    }
>
As George pointed out already, you can get the num_vcpus via
xc_domain_getinfo().

I agree with George's review about the rest of this function
(appropriately updated to take what we decided about the interface into
account :-) ).

> +#define SCHED_RT_VCPU_PERIOD_MAX    31536000000000 /* one year in microsecond*/
> +#define SCHED_RT_VCPU_BUDGET_MAX    SCHED_RT_VCPU_PERIOD_MAX
> +
This may be me not remembering correctly the outcome of a preceding
discussion... did we say we were going with _RT_ or with something like
_RTDS_ ?

ISTR the latter...

Also, macros like INT_MAX, UINT_MAX, etc., or << and ~ "tricks" are,
IMO, preferrable to the open coding of the value.

Finally, I wonder whether these would better live in some headers,
closer to the declaration of period and budget (where their type is also
visible) and, as a nice side effect of that, available to libxl callers
as well.

> +/*
> + * Sanity check of the scinfo parameters
> + * return 0 if all values are valid
> + * return 1 if one param is default value
> + * return 2 if the target vcpu's index, period or budget is out of range
> + */
> +static int sched_rt_domain_set_validate_params(libxl__gc *gc,
> +                                               const libxl_domain_sched_params *scinfo,
> +                                               const uint16_t num_vcpus)
> +{
> +    int vcpu_index = scinfo->rt.vcpu_index;
> +
As per the low level interface (Xen and libxc) there should be no need
for any vcpu_index anymore, right?

I'm just double checking, as the discussion was --as it should, on these
things-- long and involved :-D

> +    if (vcpu_index < 0 || vcpu_index > num_vcpus)
> +    {
> +        LOG(ERROR, "VCPU index is not set or out of range, "
> +                    "valid values are within range from 0 to %d", num_vcpus);
> +        return 2;
> +    }
> +
> +    if (scinfo->rt.period < 1 ||
> +        scinfo->rt.period > SCHED_RT_VCPU_PERIOD_MAX)
> +    {
> +        LOG(ERROR, "VCPU period is not set or out of range, "
> +                    "valid values are within range from 0 to %lu", SCHED_RT_VCPU_PERIOD_MAX);
> +        return 2;
> +    }
> +
> +    if (scinfo->rt.budget < 1 ||
> +        scinfo->rt.budget > SCHED_RT_VCPU_BUDGET_MAX)
> +    {
> +        LOG(ERROR, "VCPU budget is not set or out of range, "
> +                    "valid values are within range from 0 to %lu", SCHED_RT_VCPU_BUDGET_MAX);
> +        return 2;
> +    }
> +
I think some basics sanity checking are fine done here. E.g., you may
also add a (budget <= period) check. However, as George said already:
 - make sure you limit these to the kind of checks based on info the 
   toolstack should have, and defer the rest to the hypervisor
 - if something goes wrong, make sure to always return libxl error codes
   (typically, ERROR_INVAL), as sched_credit_domain_set() does.

Oh and, just double checking again, I think we decided to handle
(budget ==0 && period == 0) in a special way, so remember that! :-P

It's personal taste, I guess, but I think you don't really need an
helper function for this, and it can leave in sched_rt_domain_set.

> +static int sched_rt_domain_set(libxl__gc *gc, uint32_t domid,
> +                               const libxl_domain_sched_params *scinfo)
> +{
> +    struct xen_domctl_sched_rt_params sdom;
> +    uint16_t num_vcpus;
> +    int rc;
> + 
> +    rc = xc_sched_rt_domain_get_num_vcpus(CTX->xch, domid, &num_vcpus);
> +    if (rc != 0) {
> +        LOGE(ERROR, "getting domain sched rt");
> +        return ERROR_FAIL;
> +    }
> +    
> +    rc = sched_rt_domain_set_validate_params(gc, scinfo, num_vcpus);
> +    if (rc == 2)
> +        return ERROR_INVAL;
> +    if (rc == 1)
> +        return 0;
> +    if (rc == 0)
> +    {
> +        sdom.index = scinfo->rt.vcpu_index;
> +        sdom.period = scinfo->rt.period;
> +        sdom.budget = scinfo->rt.budget;
> +    }
> +
So, I see that you are actually returning libxl error codes, good. Well,
again, just put the code above directly here, instead of having to
define and then interpret an ad-hoc error handling logic. :-)

> @@ -5177,6 +5310,9 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
>      case LIBXL_SCHEDULER_ARINC653:
>          ret=sched_arinc653_domain_set(gc, domid, scinfo);
>          break;
> +    case LIBXL_SCHEDULER_RT:
> +        ret=sched_rt_domain_set(gc, domid, scinfo);
> +        break;
Again, I seriously think I remember we agreed upon _SCHEDULER_RTDS (or
_RT_DS) as thee name of this thing. Am I wrong?

> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -153,6 +153,7 @@ libxl_scheduler = Enumeration("scheduler", [
>      (5, "credit"),
>      (6, "credit2"),
>      (7, "arinc653"),
> +    (8, "rt"),
rtds? rt_ds?

> @@ -303,6 +304,19 @@ libxl_domain_restore_params = Struct("domain_restore_params", [
>      ("checkpointed_stream", integer),
>      ])
>  
> +libxl_rt_vcpu = Struct("vcpu",[
> +    ("period",       uint64, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT'}),
> +    ("budget",       uint64, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}),
> +    ("index",        integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_VCPU_INDEX_DEFAULT'}),
> +    ])
> +
> +libxl_domain_sched_rt_params = Struct("domain_sched_rt_params",[
> +    ("vcpus",        Array(libxl_rt_vcpu, "num_vcpus")),
> +    ("period",       uint64, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT'}),
> +    ("budget",       uint64, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}),
> +    ("vcpu_index",   integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_VCPU_INDEX_DEFAULT'}),
> +    ])
> +
>  libxl_domain_sched_params = Struct("domain_sched_params",[
>      ("sched",        libxl_scheduler),
>      ("weight",       integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT'}),
> @@ -311,6 +325,7 @@ libxl_domain_sched_params = Struct("domain_sched_params",[
>      ("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'}),
> +    ("rt",           libxl_domain_sched_rt_params),
>      ])
And about this part, we discussed and agreed already in the other
thread. :-)

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)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2014-09-05 10:21 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-24 22:58 Introduce rt real-time scheduler for Xen Meng Xu
2014-08-24 22:58 ` [PATCH v1 1/4] xen: add real time scheduler rt Meng Xu
2014-08-26 14:27   ` Jan Beulich
2014-08-27  2:07     ` Meng Xu
2014-08-27  6:26       ` Jan Beulich
2014-08-27 14:28         ` Meng Xu
2014-08-27 15:04           ` Jan Beulich
2014-08-28 16:06             ` Meng Xu
2014-08-29  9:05               ` Jan Beulich
2014-08-29 19:35                 ` Meng Xu
2014-09-03 14:08                 ` George Dunlap
2014-09-03 14:24                   ` Meng Xu
2014-09-03 14:35                     ` Dario Faggioli
2014-09-03 13:40   ` George Dunlap
2014-09-03 14:11     ` Meng Xu
2014-09-03 14:15       ` George Dunlap
2014-09-03 14:35         ` Meng Xu
2014-09-05  9:46     ` Dario Faggioli
2014-09-03 14:20   ` George Dunlap
2014-09-03 14:45     ` Jan Beulich
2014-09-03 14:59     ` Dario Faggioli
2014-09-03 15:27       ` Meng Xu
2014-09-03 15:46         ` Dario Faggioli
2014-09-03 17:13           ` George Dunlap
2014-09-03 15:13     ` Meng Xu
2014-09-03 16:06       ` George Dunlap
2014-09-03 16:57         ` Dario Faggioli
2014-09-03 17:18           ` George Dunlap
2014-09-04  2:15             ` Meng Xu
2014-09-04 14:27             ` Dario Faggioli
2014-09-04 15:30               ` Meng Xu
2014-09-05  9:36                 ` Dario Faggioli
2014-09-05 15:06                   ` Meng Xu
2014-09-05 15:09                     ` Dario Faggioli
2014-09-04  2:11         ` Meng Xu
2014-09-04 11:00           ` Dario Faggioli
2014-09-04 13:03           ` George Dunlap
2014-09-04 14:00             ` Meng Xu
2014-09-05 17:17   ` Dario Faggioli
2014-09-07  3:56     ` Meng Xu
2014-09-08 10:33       ` Dario Faggioli
2014-09-09 13:43         ` Meng Xu
2014-08-24 22:58 ` [PATCH v1 2/4] libxc: add rt scheduler Meng Xu
2014-09-05 10:34   ` Dario Faggioli
2014-09-05 17:17     ` Meng Xu
2014-09-05 17:50       ` Dario Faggioli
2014-08-24 22:58 ` [PATCH v1 3/4] libxl: " Meng Xu
2014-08-25 13:17   ` Wei Liu
2014-08-25 15:55     ` Meng Xu
2014-08-26  9:51       ` Wei Liu
2014-09-03 15:33   ` George Dunlap
2014-09-03 20:52     ` Meng Xu
2014-09-04 14:27     ` George Dunlap
2014-09-04 14:45       ` Dario Faggioli
2014-09-04 14:47       ` Meng Xu
2014-09-04 14:51         ` George Dunlap
2014-09-04 15:07           ` Meng Xu
2014-09-04 15:44             ` Dario Faggioli
2014-09-04 15:55               ` George Dunlap
2014-09-04 16:12                 ` Meng Xu
2014-09-05  9:19                   ` Dario Faggioli
2014-09-04 15:25         ` Dario Faggioli
2014-09-05 10:21   ` Dario Faggioli [this message]
2014-09-05 15:45     ` Meng Xu
2014-09-05 17:41       ` Dario Faggioli
2014-08-24 22:58 ` [PATCH v1 4/4] xl: introduce " Meng Xu
2014-08-25 13:31   ` Wei Liu
2014-08-25 16:12     ` Meng Xu
2014-09-03 15:52   ` George Dunlap
2014-09-03 22:28     ` Meng Xu
2014-09-05  9:40       ` Dario Faggioli
2014-09-05 14:43         ` Meng Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409912467.2673.288.camel@Solace.lan \
    --to=dario.faggioli@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=chaowang@wustl.edu \
    --cc=dgolomb@seas.upenn.edu \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=lichong659@gmail.com \
    --cc=mengxu@cis.upenn.edu \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xisisu@gmail.com \
    --cc=xumengpanda@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.