All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chong Li <lichong659@gmail.com>
To: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Chong Li <chong.li@wustl.edu>, Wei Liu <wei.liu2@citrix.com>,
	Sisu Xi <xisisu@gmail.com>,
	"dario.faggioli" <dario.faggioli@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel <xen-devel@lists.xen.org>,
	Ian Campbell <ian.campbell@eu.citrix.com>,
	Meng Xu <mengxu@cis.upenn.edu>,
	Dagaen Golomb <dgolomb@seas.upenn.edu>
Subject: Re: [PATCH v2 for Xen 4.6 3/4] libxl: enabling XL to set per-VCPU parameters of a domain for RTDS scheduler
Date: Tue, 2 Jun 2015 09:10:20 -0500	[thread overview]
Message-ID: <CAGHO-ioGO7-bepdTT1jwLxpA7ZOTxVNjR5BBu=Z=LvVsfDNySA@mail.gmail.com> (raw)
In-Reply-To: <556DA756.3040208@eu.citrix.com>

On Tue, Jun 2, 2015 at 7:53 AM, George Dunlap
<george.dunlap@eu.citrix.com> wrote:
> On 05/26/2015 01:09 AM, Chong Li wrote:
>> Add libxl_vcpu_sched_params_get/set and sched_rtds_vcpu_get/set functions to support
>> per-VCPU settings for RTDS scheduler.
>>
>> Add a new data structure (libxl_vcpu_sched_params) to help per-VCPU settings.
>>
>> 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>
>
> This doesn't apply cleanly for me anymore -- can you refresh and resend?
>
> Thanks,
>  -George
>

Yes, sure. I'm working on the comments that have already been posted
in this series and will send out a new version soon.

Chong
>> ---
>>  tools/libxl/libxl.c         | 189 ++++++++++++++++++++++++++++++++++++++------
>>  tools/libxl/libxl.h         |  19 +++++
>>  tools/libxl/libxl_types.idl |  11 +++
>>  3 files changed, 196 insertions(+), 23 deletions(-)
>>
>> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
>> index feb3aa9..169901a 100644
>> --- a/tools/libxl/libxl.c
>> +++ b/tools/libxl/libxl.c
>> @@ -5797,6 +5797,120 @@ static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid,
>>      return 0;
>>  }
>>
>> +static int sched_rtds_validate_params(libxl__gc *gc, uint32_t period,
>> +                                 uint32_t 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 1");
>> +            return ERROR_INVAL;
>> +        }
>> +        *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 1");
>> +            return ERROR_INVAL;
>> +        }
>> +        *sdom_budget = budget;
>> +    }
>> +
>> +    if (budget > period) {
>> +        LOG(ERROR, "VCPU budget is larger than VCPU period, "
>> +                   "VCPU budget should be no larger than VCPU period");
>> +        return ERROR_INVAL;
>> +    }
>> +
>> +    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;
>> +
>> +    rc = xc_domain_getinfo(CTX->xch, domid, 1, &info);
>> +    if (rc < 0) {
>> +        LOGE(ERROR, "getting domain info");
>> +        return ERROR_FAIL;
>> +    }
>> +    num_vcpus = info.max_vcpu_id + 1;
>> +
>> +    struct xen_domctl_sched_rtds_params  *sdom = libxl__malloc(NOGC,
>> +                sizeof(struct xen_domctl_sched_rtds_params) * num_vcpus);
>> +    rc = xc_sched_rtds_vcpu_get(CTX->xch, domid, sdom, num_vcpus);
>> +    if (rc != 0) {
>> +        LOGE(ERROR, "getting vcpu sched rtds");
>> +        return ERROR_FAIL;
>> +    }
>> +
>> +    libxl_vcpu_sched_params_init(scinfo);
>> +
>> +    scinfo->sched = LIBXL_SCHEDULER_RTDS;
>> +    scinfo->num_vcpus = num_vcpus;
>> +    scinfo->vcpus = (libxl_rtds_vcpu *)
>> +            libxl__malloc(NOGC, sizeof(libxl_rtds_vcpu) * num_vcpus);
>> +    for(i = 0; i < num_vcpus; i++) {
>> +        scinfo->vcpus[i].period = sdom[i].period;
>> +        scinfo->vcpus[i].budget = sdom[i].budget;
>> +    }
>> +
>> +    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 num_vcpus;
>> +    int vcpuid;
>> +    uint32_t budget, period;
>> +    xc_dominfo_t info;
>> +
>> +    rc = xc_domain_getinfo(CTX->xch, domid, 1, &info);
>> +    if (rc < 0) {
>> +        LOGE(ERROR, "getting domain info");
>> +        return ERROR_FAIL;
>> +    }
>> +    num_vcpus = info.max_vcpu_id + 1;
>> +
>> +    struct xen_domctl_sched_rtds_params  *sdom =
>> +            libxl__malloc(NOGC, scinfo->num_vcpus);
>> +    for (i = 0; i < scinfo->num_vcpus; i++) {
>> +        vcpuid = scinfo->vcpus[i].vcpuid;
>> +        budget = scinfo->vcpus[i].budget;
>> +        period = scinfo->vcpus[i].period;
>> +        if (vcpuid < 0 || vcpuid >= num_vcpus) {
>> +            LOG(ERROR, "VCPU index is out of range, "
>> +                       "valid values are within range from 0 to %d",
>> +                       num_vcpus);
>> +            return ERROR_INVAL;
>> +        }
>> +        sdom[i].vcpuid = vcpuid;
>> +
>> +        rc = sched_rtds_validate_params(gc, period, budget,
>> +                &sdom[i].period, &sdom[i].budget);
>> +        if (rc == ERROR_INVAL)
>> +            return rc;
>> +    }
>> +
>> +    rc = xc_sched_rtds_vcpu_set(CTX->xch, domid,
>> +            sdom, scinfo->num_vcpus);
>> +    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)
>>  {
>> @@ -5830,29 +5944,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");
>> -        return ERROR_INVAL;
>> -    }
>> +    rc = sched_rtds_validate_params(gc, scinfo->period, scinfo->budget,
>> +            &sdom.period, &sdom.budget);
>> +    if (rc == ERROR_INVAL)
>> +        return rc;
>>
>>      rc = xc_sched_rtds_domain_set(CTX->xch, domid, &sdom);
>>      if (rc < 0) {
>> @@ -5899,6 +5994,30 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
>>      return ret;
>>  }
>>
>> +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_RTDS:
>> +        ret=sched_rtds_vcpu_set(gc, domid, scinfo);
>> +        break;
>> +    default:
>> +        LOG(ERROR, "Unknown scheduler");
>> +        ret=ERROR_INVAL;
>> +        break;
>> +    }
>> +
>> +    GC_FREE;
>> +    return ret;
>> +}
>> +
>>  int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
>>                                    libxl_domain_sched_params *scinfo)
>>  {
>> @@ -5932,6 +6051,30 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
>>      return ret;
>>  }
>>
>> +int libxl_vcpu_sched_params_get(libxl_ctx *ctx, uint32_t domid,
>> +                                  libxl_vcpu_sched_params *scinfo)
>> +{
>> +    GC_INIT(ctx);
>> +    int ret;
>> +
>> +    libxl_vcpu_sched_params_init(scinfo);
>> +
>> +    scinfo->sched = libxl__domain_scheduler(gc, domid);
>> +
>> +    switch (scinfo->sched) {
>> +    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;
>> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
>> index 44bd8e2..e565814 100644
>> --- a/tools/libxl/libxl.h
>> +++ b/tools/libxl/libxl.h
>> @@ -192,6 +192,18 @@
>>   * is not present, instead of ERROR_INVAL.
>>   */
>>  #define LIBXL_HAVE_ERROR_DOMAIN_NOTFOUND 1
>> +
>> +/*
>> + * libxl_vcpu_sched_params is used to get/set per-vcpu params
>> +*/
>> +#define LIBXL_HAVE_VCPU_SCHED_PARAMS 1
>> +
>> +/*
>> + * libxl_rtds_vcpu is used to represent the rtds scheduling params
>> + * of a vcpu
>> +*/
>> +#define LIBXL_HAVE_RTDS_VCPU 1
>> +
>>  /*
>>   * libxl ABI compatibility
>>   *
>> @@ -1460,10 +1472,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
>>
>> +/*RTDS Per-VCPU parameters*/
>> +#define LIBXL_DOMAIN_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);
>> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
>> index 117b61d..d28d274 100644
>> --- a/tools/libxl/libxl_types.idl
>> +++ b/tools/libxl/libxl_types.idl
>> @@ -347,6 +347,17 @@ libxl_domain_restore_params = Struct("domain_restore_params", [
>>      ("checkpointed_stream", integer),
>>      ])
>>
>> +libxl_rtds_vcpu = Struct("rtds_vcpu",[
>> +    ("period",       uint32, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT'}),
>> +    ("budget",       uint32, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}),
>> +    ("vcpuid",        integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_VCPU_INDEX_DEFAULT'}),
>> +    ])
>> +
>> +libxl_vcpu_sched_params = Struct("vcpu_sched_params",[
>> +    ("sched",        libxl_scheduler),
>> +    ("vcpus",        Array(libxl_rtds_vcpu, "num_vcpus")),
>> +    ])
>> +
>>  libxl_domain_sched_params = Struct("domain_sched_params",[
>>      ("sched",        libxl_scheduler),
>>      ("weight",       integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT'}),
>>
>



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

  reply	other threads:[~2015-06-02 14:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26  0:09 [PATCH v2 for Xen 4.6 3/4] libxl: enabling XL to set per-VCPU parameters of a domain for RTDS scheduler Chong Li
2015-06-02 12:53 ` George Dunlap
2015-06-02 14:10   ` Chong Li [this message]
2015-06-04 23:48 ` Dario Faggioli
2015-06-05 11:37 ` Ian Campbell
2015-06-08 15:56   ` Dario Faggioli
2015-06-08 20:55     ` Chong Li
2015-06-09 16:18       ` Dario Faggioli
2015-06-12 20:48         ` Chong Li
2015-06-15 10:12           ` Dario Faggioli
2015-06-17 12:14             ` Ian Campbell
2015-06-17 12:26               ` Dario Faggioli
2015-06-17 12:08         ` Ian Campbell
2015-06-17 12:32           ` Dario Faggioli
2015-06-17 15:47             ` Chong Li

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='CAGHO-ioGO7-bepdTT1jwLxpA7ZOTxVNjR5BBu=Z=LvVsfDNySA@mail.gmail.com' \
    --to=lichong659@gmail.com \
    --cc=chong.li@wustl.edu \
    --cc=dario.faggioli@citrix.com \
    --cc=dgolomb@seas.upenn.edu \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=mengxu@cis.upenn.edu \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xisisu@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.