From: Dario Faggioli <dario.faggioli@citrix.com>
To: Chong Li <lichong659@gmail.com>
Cc: Chong Li <chong.li@wustl.edu>,
wei.liu2@citrix.com, Sisu Xi <xisisu@gmail.com>,
george.dunlap@eu.citrix.com, xen-devel@lists.xen.org,
mengxu@cis.upenn.edu, jbeulich@suse.com, dgolomb@seas.upenn.edu
Subject: Re: [PATCH v1 3/4] libxl: enabling XL to set per-VCPU parameters of a domain for RTDS scheduler
Date: Mon, 11 May 2015 16:06:33 +0200 [thread overview]
Message-ID: <1431353193.8979.85.camel@citrix.com> (raw)
In-Reply-To: <1431018326-3239-4-git-send-email-chong.li@wustl.edu>
On Thu, 2015-05-07 at 12:05 -0500, Chong Li wrote:
> Change sched_rtds_domain_get/set functions to support per-VCPU settings for RTDS scheduler.
>
> 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>
> ---
> tools/libxl/libxl.c | 143 +++++++++++++++++++++++++++++++++-----------
> tools/libxl/libxl.h | 6 ++
> tools/libxl/libxl_types.idl | 11 ++++
> 3 files changed, 126 insertions(+), 34 deletions(-)
>
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index feb3aa9..5f66753 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -5800,10 +5800,17 @@ static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid,
> static int sched_rtds_domain_get(libxl__gc *gc, uint32_t domid,
> libxl_domain_sched_params *scinfo)
> {
> - struct xen_domctl_sched_rtds sdom;
> - int rc;
> -
> - rc = xc_sched_rtds_domain_get(CTX->xch, domid, &sdom);
> + uint16_t num_vcpus;
> + int rc, i;
> + xc_dominfo_t info;
>
Coding style: we want a blank line between variable definitions and
actual code.
> + rc = xc_domain_getinfo(CTX->xch, domid, 1, &info);
> + if (rc < 0) {
> + LOGE(ERROR, "getting domain info");
> + return ERROR_FAIL;
> + }
> + num_vcpus = info.nr_online_vcpus;
>
It looks like the most of other places in libxl where this is necessary
use libxl_list_vcpu(), which, if you want to open code it, uses
info.max_vcpu_id. I'd do the same.
> + struct xen_domctl_sched_rtds_params sdom[num_vcpus];
>
And, please, all the variable definitions go together, at the top of the
function. Avoid having them scattered around the body.
I see why this is here, but no, that's not a good reason... For
allocating arrays in libxl, have a look at GCNEW_ARRAY, or
libxl__calloc, libxl__malloc, libxl__realloc, etc.
> + rc = xc_sched_rtds_vcpu_get(CTX->xch, domid, sdom, num_vcpus);
> if (rc != 0) {
> LOGE(ERROR, "getting domain sched rtds");
> return ERROR_FAIL;
> @@ -5821,43 +5835,104 @@ static int sched_rtds_domain_get(libxl__gc *gc, uint32_t domid,
> static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,
> const libxl_domain_sched_params *scinfo)
> {
> - struct xen_domctl_sched_rtds sdom;
> int rc;
> + int i;
>
> - rc = xc_sched_rtds_domain_get(CTX->xch, domid, &sdom);
> - if (rc != 0) {
> - LOGE(ERROR, "getting domain sched rtds");
> - return ERROR_FAIL;
> - }
> + if(scinfo->rtds.num_vcpus <= 0) {/*set per-dom rtds parameters*/
>
The comment is better before or after, rather than inline.
But, really, can you define another helper function and call it, instead
than re-indenting everything and making this one much more long and
complex?
Oh, and the error checking and error reporting code should be factored
and shared, not duplicated.
I mean this:
> + 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;
> + }
And this:
> + if (period < 1) {
> + LOG(ERROR, "VCPU period is out of range, "
> + "valid values are larger than 1");
> + return ERROR_INVAL;
> + }
>
And the same for every other one.
Regards,
Dario
next prev parent reply other threads:[~2015-05-11 14:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 17:05 [PATCH v1 0/4] Enabling XL to set per-VCPU parameters of a domain for RTDS scheduler Chong Li
2015-05-07 17:05 ` [PATCH v1 1/4] xen: enabling " Chong Li
2015-05-08 7:49 ` Jan Beulich
2015-05-10 22:04 ` Chong Li
2015-05-11 6:57 ` Jan Beulich
2015-05-14 22:27 ` Chong Li
2015-05-15 14:42 ` Dario Faggioli
2015-05-11 13:11 ` Dario Faggioli
2015-05-14 22:15 ` Chong Li
2015-05-07 17:05 ` [PATCH v1 2/4] libxc: " Chong Li
2015-05-11 13:27 ` Dario Faggioli
2015-05-07 17:05 ` [PATCH v1 3/4] libxl: " Chong Li
2015-05-11 14:06 ` Dario Faggioli [this message]
2015-05-15 15:24 ` Chong Li
2015-05-15 23:09 ` Dario Faggioli
2015-05-12 10:01 ` Dario Faggioli
2015-05-15 16:35 ` Chong Li
2015-05-15 23:02 ` Dario Faggioli
2015-05-22 17:57 ` Chong Li
2015-05-07 17:05 ` [PATCH v1 4/4] xl: " Chong Li
2015-05-14 14:24 ` Meng Xu
2015-05-14 14:39 ` Dario Faggioli
2015-05-14 14:43 ` Meng Xu
2015-05-11 9:56 ` [PATCH v1 0/4] Enabling " Dario Faggioli
2015-05-14 17:08 ` 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=1431353193.8979.85.camel@citrix.com \
--to=dario.faggioli@citrix.com \
--cc=chong.li@wustl.edu \
--cc=dgolomb@seas.upenn.edu \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=lichong659@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).