Allow user to configure credit scheduler parameters
PATCH 1/1 Allow user to configure credit scheduler parameters
This patch series introduces hypercalls to allow the timeslice and ratelimit parameters of the credit scheduler to be read and tweaked, and plumbed all the way through to the xl command-line.
PATCH 1/1 cleanup: Remove dependency files in efi directory during a make clean
xen/arch/x86/Makefile +1 -1
@@ -168,5 +168,5 @@ efi/mkreloc: efi/mkreloc.c clean:: rm -f asm-offsets.s xen.lds boot/*.o boot/*~ boot/core boot/mkelf32 rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d - rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.o efi/mkreloc + rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.o efi/mkreloc efi/.*.d rm -f boot/reloc.S boot/reloc.lnk boot/reloc.bin
PATCH 1/1 xen: Add a #define for the default ratelimit
In reply to George Dunlapxen/common/schedule.c +1 -1
@@ -50,7 +50,7 @@ boolean_param("sched_smt_power_savings",/* Default scheduling rate limit: 1ms * The behavior when sched_ratelimit_us is greater than sched_credit_tslice_ms is undefined * */ -int sched_ratelimit_us =1000 ; +int sched_ratelimit_us =SCHED_DEFAULT_RATELIMIT_US ;integer_param ("sched_ratelimit_us" , sched_ratelimit_us);/* Various timer handlers. */ static void s_timer_fn (void *unused);
xen/include/xen/sched-if.h +1 -0
@@ -18,6 +18,7 @@ extern cpumask_t cpupool_free_cpus;/* Scheduler generic parameters * */ +#define SCHED_DEFAULT_RATELIMIT_US 1000extern int sched_ratelimit_us;
PATCH 1/1 xen: Print ratelimit in scheduler debugkey
In reply to George Dunlapxen/common/sched_credit.c +2 -0
@@ -1504,6 +1504,7 @@ csched_dump(const struct scheduler *ops)"\trunq_sort = %u\n" "\tdefault-weight = %d\n" "\ttslice = %dms\n" +"\tratelimit = %dus\n" "\tcredits per msec = %d\n" "\tticks per tslice = %d\n" "\tmigration delay = %uus\n",
@@ -1515,6 +1516,7 @@ csched_dump(const struct scheduler *ops) prv->runq_sort,CSCHED_DEFAULT_WEIGHT , prv->tslice_ms, + prv->ratelimit_us,CSCHED_CREDITS_PER_MSEC , prv->ticks_per_tslice, vcpu_migration_delay);
PATCH 1/1 xen: Implement SCHEDOP sysctl for credit scheduler
In reply to George DunlapAllow tslice_ms and ratelimit_us to be modified.
xen/common/sched_credit.c +53 -0
@@ -833,6 +833,36 @@ csched_dom_cntl(return 0 ; } +static int +csched_sys_cntl (const struct scheduler *ops, +struct xen_sysctl_scheduler_op *sc) +{ +int rc = -EINVAL ; +xen_sysctl_credit_schedule_t *params = &sc->u.sched_credit; +struct csched_private *prv =CSCHED_PRIV (ops); + +switch ( sc->cmd ) + { +case XEN_SYSCTL_SCHEDOP_putinfo: +if (params->tslice_ms >XEN_SYSCTL_CSCHED_TSLICE_MAX + || params->tslice_ms <XEN_SYSCTL_CSCHED_TSLICE_MIN + || params->ratelimit_us >XEN_SYSCTL_SCHED_RATELIMIT_MAX + || params->ratelimit_us <XEN_SYSCTL_SCHED_RATELIMIT_MIN + ||MICROSECS (params->ratelimit_us) >MILLISECS (params->tslice_ms) ) + goto out; + prv->tslice_ms = params->tslice_ms; + prv->ratelimit_us = params->ratelimit_us; +/* FALLTHRU */ +case XEN_SYSCTL_SCHEDOP_getinfo: + params->tslice_ms = prv->tslice_ms; + params->ratelimit_us = prv->ratelimit_us; + rc =0 ; +break ; + } + out: +return rc; +} +static void *csched_alloc_domdata (const struct scheduler *ops,struct domain *dom) {
@@ -1566,6 +1596,28 @@ csched_init(struct scheduler *ops)INIT_LIST_HEAD (&prv->active_sdom); prv->master =UINT_MAX ; +if ( sched_credit_tslice_ms >XEN_SYSCTL_CSCHED_TSLICE_MAX + || sched_credit_tslice_ms <XEN_SYSCTL_CSCHED_TSLICE_MIN ) + { +printk ("WARNING: sched_credit_tslice_ms outside of valid range [%d,%d].\n" +" Resetting to default %u\n" , +XEN_SYSCTL_CSCHED_TSLICE_MIN , +XEN_SYSCTL_CSCHED_TSLICE_MAX , +CSCHED_DEFAULT_TSLICE_MS ); + sched_credit_tslice_ms =CSCHED_DEFAULT_TSLICE_MS ; + } + +if ( sched_ratelimit_us >XEN_SYSCTL_SCHED_RATELIMIT_MAX + || sched_ratelimit_us <XEN_SYSCTL_SCHED_RATELIMIT_MIN ) + { +printk ("WARNING: sched_ratelimit_us outside of valid range [%d,%d].\n" +" Resetting to default %u\n" , +XEN_SYSCTL_SCHED_RATELIMIT_MIN , +XEN_SYSCTL_SCHED_RATELIMIT_MAX , +SCHED_DEFAULT_RATELIMIT_US ); + sched_ratelimit_us =SCHED_DEFAULT_RATELIMIT_US ; + } + prv->tslice_ms = sched_credit_tslice_ms; prv->ticks_per_tslice =CSCHED_TICKS_PER_TSLICE ;if ( prv->tslice_ms < prv->ticks_per_tslice )
@@ -1641,6 +1693,7 @@ const struct scheduler sched_credit_def .yield = csched_vcpu_yield, .adjust = csched_dom_cntl, + .adjust_global = csched_sys_cntl, .pick_cpu = csched_cpu_pick, .do_schedule = csched_schedule,
xen/include/public/sysctl.h +14 -0
@@ -564,6 +564,19 @@ struct xen_sysctl_arinc653_schedule {typedef struct xen_sysctl_arinc653_schedule xen_sysctl_arinc653_schedule_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_arinc653_schedule_t); +struct xen_sysctl_credit_schedule { +/* Length of timeslice in milliseconds */ +#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000 +#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1 +unsigned tslice_ms; +/* Rate limit (minimum timeslice) in microseconds */ +#define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000 +#define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100 +unsigned ratelimit_us; +}; +typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_credit_schedule_t); +/* XEN_SYSCTL_scheduler_op */ /* Set or get info? */ #define XEN_SYSCTL_SCHEDOP_putinfo 0
@@ -576,6 +589,7 @@ struct xen_sysctl_scheduler_op {struct xen_sysctl_sched_arinc653 {XEN_GUEST_HANDLE_64 (xen_sysctl_arinc653_schedule_t) schedule; } sched_arinc653; +struct xen_sysctl_credit_schedule sched_credit; } u; };typedef struct xen_sysctl_scheduler_op xen_sysctl_scheduler_op_t ;
PATCH 1/1 libxc: Implement SCHEDOP sysctl for credit scheduler
In reply to George Dunlaptools/libxc/xc_csched.c +44 -0
@@ -61,3 +61,47 @@ xc_sched_credit_domain_get(return err; } + +int +xc_sched_credit_param_set ( +xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_credit_schedule *schedule) +{ +int rc; +DECLARE_SYSCTL ; + + sysctl.cmd = XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id = cpupool_id; + sysctl.u.scheduler_op.sched_id =XEN_SCHEDULER_CREDIT ; + sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_putinfo; + + sysctl.u.scheduler_op.u.sched_credit = *schedule; + + rc =do_sysctl (xch, &sysctl); + + *schedule = sysctl.u.scheduler_op.u.sched_credit; + +return rc; +} + +int +xc_sched_credit_param_get ( +xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_credit_schedule *schedule) +{ +int rc; +DECLARE_SYSCTL ; + + sysctl.cmd = XEN_SYSCTL_scheduler_op; + sysctl.u.scheduler_op.cpupool_id = cpupool_id; + sysctl.u.scheduler_op.sched_id =XEN_SCHEDULER_CREDIT ; + sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo; + + rc =do_sysctl (xch, &sysctl); + + *schedule = sysctl.u.scheduler_op.u.sched_credit; + +return rc; +}
tools/libxc/xenctrl.h +6 -1
@@ -668,7 +668,12 @@ int xc_sched_credit_domain_set(xc_interfint xc_sched_credit_domain_get (xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit *sdom); - +int xc_sched_credit_param_set (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_credit_schedule *schedule); +int xc_sched_credit_param_get (xc_interface *xch, +uint32_t cpupool_id, +struct xen_sysctl_credit_schedule *schedule);int xc_sched_credit2_domain_set (xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit2 *sdom);
Re: [PATCH 05 of 10] libxc: Implement SCHEDOP sysctl for credit scheduler
George Dunlap writes ("[Xen-devel] [PATCH 05 of 10] libxc: Implement SCHEDOP sysctl for credit scheduler"):
Quoted 1 line
Signed-off-by George Dunlap <[email protected]>
...
tools/libxc/xc_csched.c xc_sched_credit_domain_get( · line 69
Quoted 4 lines
tools/libxc/xc_csched.c +4
-0+xc_sched_credit_param_set ( + xc_interface *xch, + uint32_t cpupool_id, + struct xen_sysctl_credit_schedule *schedule)
Ian.
PATCH 1/1 libxl: cleanup: Remove pointless ERRNOVAL
In reply to George DunlapJust call LIBXL__LOG rather than passing a meaningless ERRNOVAL.
tools/libxl/libxl.c +2 -2
@@ -3008,13 +3008,13 @@ int libxl_sched_credit_domain_set(libxl_if (scinfo->weight <1 || scinfo->weight >65535 ) { -LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Cpu weight out of range, valid values are within range from 1 to 65535" );return ERROR_INVAL ; }if (scinfo->cap <0 || scinfo->cap > (domaininfo.max_vcpu_id +1 ) *100 ) { -LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Cpu cap out of range, valid range is from 0 to %d for specified number of vcpus" , ((domaininfo.max_vcpu_id +1 ) *100 ));return ERROR_INVAL ;
Re: [PATCH 06 of 10] libxl: cleanup: Remove pointless ERRNOVAL
George Dunlap writes ("[Xen-devel] [PATCH 06 of 10] libxl: cleanup: Remove pointless ERRNOVAL"):
Quoted 3 lines
Just call
LIBXL__LOGrather than passing a meaningless ERRNOVAL.Signed-off-by George Dunlap <[email protected]>
PATCH 1/1 libxl: Rename libxl_sched_* to include _domain
In reply to George DunlapIn preparation for introducing a schedule parameter-based structure, rename libxl_sched_{credit,credit2,sedf} to libxl_sched_{}_domain.
No functional changes.
tools/libxl/libxl.c +6 -6
@@ -2975,7 +2975,7 @@ int libxl_get_sched_id(libxl_ctx *ctx)return sched; } -int libxl_sched_credit_domain_get (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit *scinfo) +int libxl_sched_credit_domain_get (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit_domain *scinfo) {struct xen_domctl_sched_credit sdom;int rc;
@@ -2992,7 +2992,7 @@ int libxl_sched_credit_domain_get(libxl_return 0 ; } -int libxl_sched_credit_domain_set (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit *scinfo) +int libxl_sched_credit_domain_set (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit_domain *scinfo) {struct xen_domctl_sched_credit sdom;xc_domaininfo_t domaininfo;
@@ -3033,7 +3033,7 @@ int libxl_sched_credit_domain_set(libxl_ }int libxl_sched_credit2_domain_get (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit2 *scinfo) +libxl_sched_credit2_domain *scinfo) {struct xen_domctl_sched_credit2 sdom;int rc;
@@ -3051,7 +3051,7 @@ int libxl_sched_credit2_domain_get(libxl }int libxl_sched_credit2_domain_set (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit2 *scinfo) +libxl_sched_credit2_domain *scinfo) {struct xen_domctl_sched_credit2 sdom;xc_domaininfo_t domaininfo;
@@ -3086,7 +3086,7 @@ int libxl_sched_credit2_domain_set(libxl }int libxl_sched_sedf_domain_get (libxl_ctx *ctx,uint32_t domid, -libxl_sched_sedf *scinfo) +libxl_sched_sedf_domain *scinfo) {uint64_t period;uint64_t slice;
@@ -3112,7 +3112,7 @@ int libxl_sched_sedf_domain_get(libxl_ct }int libxl_sched_sedf_domain_set (libxl_ctx *ctx,uint32_t domid, -libxl_sched_sedf *scinfo) +libxl_sched_sedf_domain *scinfo) {xc_domaininfo_t domaininfo;int rc;
tools/libxl/libxl.h +6 -6
@@ -588,17 +588,17 @@ int libxl_get_sched_id(libxl_ctx *ctx);int libxl_sched_credit_domain_get (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit *scinfo); +libxl_sched_credit_domain *scinfo);int libxl_sched_credit_domain_set (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit *scinfo); +libxl_sched_credit_domain *scinfo);int libxl_sched_credit2_domain_get (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit2 *scinfo); +libxl_sched_credit2_domain *scinfo);int libxl_sched_credit2_domain_set (libxl_ctx *ctx,uint32_t domid, -libxl_sched_credit2 *scinfo); +libxl_sched_credit2_domain *scinfo);int libxl_sched_sedf_domain_get (libxl_ctx *ctx,uint32_t domid, -libxl_sched_sedf *scinfo); +libxl_sched_sedf_domain *scinfo);int libxl_sched_sedf_domain_set (libxl_ctx *ctx,uint32_t domid, -libxl_sched_sedf *scinfo); +libxl_sched_sedf_domain *scinfo);int libxl_send_trigger (libxl_ctx *ctx,uint32_t domid,libxl_trigger trigger,uint32_t vcpuid);int libxl_send_sysrq (libxl_ctx *ctx,uint32_t domid,char sysrq);
tools/libxl/libxl_types.idl +3 -3
@@ -390,16 +390,16 @@ libxl_cputopology = Struct("cputopology" ("node", uint32), ]) -libxl_sched_credit = Struct("sched_credit", [ +libxl_sched_credit_domain = Struct("sched_credit_domain", [ ("weight", integer), ("cap", integer), ], dispose_fn=None) -libxl_sched_credit2 = Struct("sched_credit2", [ +libxl_sched_credit2_domain = Struct("sched_credit2_domain", [ ("weight", integer), ], dispose_fn=None) -libxl_sched_sedf = Struct("sched_sedf", [ +libxl_sched_sedf_domain = Struct("sched_sedf_domain", [ ("period", integer), ("slice", integer), ("latency", integer),
tools/libxl/xl_cmdimpl.c +12 -12
@@ -3913,7 +3913,7 @@ int main_sharing(int argc, char **argv) }static int sched_credit_domain_get ( -int domid,libxl_sched_credit *scinfo) +int domid,libxl_sched_credit_domain *scinfo) {int rc;
@@ -3925,7 +3925,7 @@ static int sched_credit_domain_get( }static int sched_credit_domain_set ( -int domid,libxl_sched_credit *scinfo) +int domid,libxl_sched_credit_domain *scinfo) {int rc;
@@ -3940,7 +3940,7 @@ static int sched_credit_domain_output( int domid) {char *domname; -libxl_sched_credit scinfo; +libxl_sched_credit_domain scinfo;int rc;if (domid <0 ) {
@@ -3961,7 +3961,7 @@ static int sched_credit_domain_output( }static int sched_credit2_domain_get ( -int domid,libxl_sched_credit2 *scinfo) +int domid,libxl_sched_credit2_domain *scinfo) {int rc;
@@ -3973,7 +3973,7 @@ static int sched_credit2_domain_get( }static int sched_credit2_domain_set ( -int domid,libxl_sched_credit2 *scinfo) +int domid,libxl_sched_credit2_domain *scinfo) {int rc;
@@ -3988,7 +3988,7 @@ static int sched_credit2_domain_output( int domid) {char *domname; -libxl_sched_credit2 scinfo; +libxl_sched_credit2_domain scinfo;int rc;if (domid <0 ) {
@@ -4008,7 +4008,7 @@ static int sched_credit2_domain_output( }static int sched_sedf_domain_get ( -int domid,libxl_sched_sedf *scinfo) +int domid,libxl_sched_sedf_domain *scinfo) {int rc;
@@ -4020,7 +4020,7 @@ static int sched_sedf_domain_get( }static int sched_sedf_domain_set ( -int domid,libxl_sched_sedf *scinfo) +int domid,libxl_sched_sedf_domain *scinfo) {int rc;
@@ -4035,7 +4035,7 @@ static int sched_sedf_domain_output( int domid) {char *domname; -libxl_sched_sedf scinfo; +libxl_sched_sedf_domain scinfo;int rc;if (domid <0 ) {
@@ -4116,7 +4116,7 @@ static int sched_domain_output(int main_sched_credit (int argc,char **argv) { -libxl_sched_credit scinfo; +libxl_sched_credit_domain scinfo;const char *dom =NULL ;const char *cpupool =NULL ;int weight =256 , cap =0 , opt_w =0 , opt_c =0 ;
@@ -4198,7 +4198,7 @@ int main_sched_credit(int argc, char **aint main_sched_credit2 (int argc,char **argv) { -libxl_sched_credit2 scinfo; +libxl_sched_credit2_domain scinfo;const char *dom =NULL ;const char *cpupool =NULL ;int weight =256 , opt_w =0 ;
@@ -4272,7 +4272,7 @@ int main_sched_credit2(int argc, char **int main_sched_sedf (int argc,char **argv) { -libxl_sched_sedf scinfo; +libxl_sched_sedf_domain scinfo;const char *dom =NULL ;const char *cpupool =NULL ;int period =0 , opt_p =0 ;
tools/ocaml/libs/xl/xenlight_stubs.c +4 -4
@@ -473,7 +473,7 @@ value stub_xl_sched_credit_domain_get(va {CAMLparam1 (domid);CAMLlocal1 (scinfo); -libxl_sched_credit c_scinfo; +libxl_sched_credit_domain c_scinfo;int ret;INIT_STRUCT ();
@@ -483,18 +483,18 @@ value stub_xl_sched_credit_domain_get(vafailwith_xl ("sched_credit_domain_get" , &lg);FREE_CTX (); - scinfo =Val_sched_credit (&gc, &lg, &c_scinfo); + scinfo =Val_sched_credit_domain (&gc, &lg, &c_scinfo);CAMLreturn (scinfo); }value stub_xl_sched_credit_domain_set (value domid,value scinfo) {CAMLparam2 (domid, scinfo); -libxl_sched_credit c_scinfo; +libxl_sched_credit_domain c_scinfo;int ret;INIT_STRUCT (); -sched_credit_val (&gc, &lg, &c_scinfo, scinfo); +sched_credit_domain_val (&gc, &lg, &c_scinfo, scinfo);INIT_CTX (); ret =libxl_sched_credit_domain_set (ctx,Int_val (domid), &c_scinfo);
Re: [PATCH 07 of 10] libxl: Rename libxl_sched_* to include _domain
George Dunlap writes ("[Xen-devel] [PATCH 07 of 10] libxl: Rename libxl_sched_* to include _domain"):
Quoted 2 lines
In preparation for introducing a schedule parameter-based structure, rename libxl_sched_{credit,credit2,sedf} to libxl_sched_{}_domain.
If you're feeling nice you could rewrap the long lines.
Ian.
Re: [PATCH 07 of 10] libxl: Rename libxl_sched_* to include _domain
Quoted 7 lines · Ian Jackson
George Dunlap writes ("[Xen-devel] [PATCH 07 of 10] libxl: Rename libxl_sched_* to include
_domain"):Quoted 2 lines
In preparation for introducing a schedule parameter-based structure, rename libxl_sched_{credit,credit2,sedf} to libxl_sched_{}_domain.
Acked-by Ian Jackson <[email protected]>If you're feeling nice you could rewrap the long lines.
Might as well. :-)
-George
Quoted 2 lines
Ian.
PATCH 1/1 libxl: Implement libxl_sched_credit_param_[gs]et
In reply to George DunlapImplement functions to set credit scheduler global parameters.
tools/libxl/libxl.c +59 -0
@@ -3032,6 +3032,65 @@ int libxl_sched_credit_domain_set(libxl_return 0 ; } +int libxl_sched_credit_param_get (libxl_ctx *ctx,uint32_t poolid,libxl_sched_credit_param *scinfo) +{ +struct xen_sysctl_credit_schedule sparam; +int rc; + + rc =xc_sched_credit_param_get (ctx->xch, poolid, &sparam); +if (rc !=0 ) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"getting sched credit param" ); +return ERROR_FAIL ; + } + + scinfo->tslice_ms = sparam.tslice_ms; + scinfo->ratelimit_us = sparam.ratelimit_us; + +return 0 ; +} + +int libxl_sched_credit_param_set (libxl_ctx *ctx,uint32_t poolid,libxl_sched_credit_param *scinfo) +{ +struct xen_sysctl_credit_schedule sparam; +int rc=0 ; + +if (scinfo->tslice_ms <XEN_SYSCTL_CSCHED_TSLICE_MIN + || scinfo->tslice_ms >XEN_SYSCTL_CSCHED_TSLICE_MAX ) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"Time slice out of range, valid range is from %d to %d" , +XEN_SYSCTL_CSCHED_TSLICE_MIN , +XEN_SYSCTL_CSCHED_TSLICE_MAX ); +return ERROR_INVAL ; + } +if (scinfo->ratelimit_us <XEN_SYSCTL_SCHED_RATELIMIT_MIN + || scinfo->ratelimit_us >XEN_SYSCTL_SCHED_RATELIMIT_MAX ) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"Ratelimit out of range, valid range is from %d to %d" , +XEN_SYSCTL_SCHED_RATELIMIT_MIN , +XEN_SYSCTL_SCHED_RATELIMIT_MAX ); +return ERROR_INVAL ; + } +if (scinfo->ratelimit_us > scinfo->tslice_ms*1000 ) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"Ratelimit cannot be greater than timeslice\n" ); +return ERROR_INVAL ; + } + + sparam.tslice_ms = scinfo->tslice_ms; + sparam.ratelimit_us = scinfo->ratelimit_us; + + rc =xc_sched_credit_param_set (ctx->xch, poolid, &sparam); +if ( rc <0 ) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"setting sched credit param" ); +return ERROR_FAIL ; + } + + scinfo->tslice_ms = sparam.tslice_ms; + scinfo->ratelimit_us = sparam.ratelimit_us; + +return 0 ; +} +int libxl_sched_credit2_domain_get (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit2_domain *scinfo) {
tools/libxl/libxl.h +4 -0
@@ -591,6 +591,10 @@ int libxl_sched_credit_domain_get(libxl_ libxl_sched_credit_domain *scinfo);int libxl_sched_credit_domain_set (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit_domain *scinfo); +int libxl_sched_credit_param_get (libxl_ctx *ctx,uint32_t poolid, +libxl_sched_credit_param *scinfo); +int libxl_sched_credit_param_set (libxl_ctx *ctx,uint32_t poolid, +libxl_sched_credit_param *scinfo);int libxl_sched_credit2_domain_get (libxl_ctx *ctx,uint32_t domid,libxl_sched_credit2_domain *scinfo); int libxl_sched_credit2_domain_set(libxl_ctx *ctx, uint32_t domid,
tools/libxl/libxl_types.idl +5 -0
@@ -395,6 +395,11 @@ libxl_sched_credit_domain = Struct("sche ("cap", integer), ], dispose_fn=None) +libxl_sched_credit_param = Struct("sched_credit_param", [ + ("tslice_ms", integer), + ("ratelimit_us", integer), + ], dispose_fn=None) + libxl_sched_credit2_domain = Struct("sched_credit2_domain", [ ("weight", integer), ], dispose_fn=None)
Re: [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et
George Dunlap writes ("[Xen-devel] [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et"):
Quoted 1 line
Implement functions to set credit scheduler global parameters.
Again, just some niggles:
Quoted 1 line
+int
libxl_sched_credit_param_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_param *scinfo)
Long line here and in _set.
Shouldn't this be "params" rather than "param" since it sets several parameters ?
Ian.
Re: [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et
Quoted 11 lines · Ian Jackson
George Dunlap writes ("[Xen-devel] [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et"):
Quoted 1 line
Implement functions to set credit scheduler global parameters.
Again, just some niggles:
Quoted 1 line
+int
libxl_sched_credit_param_get(libxl_ctx *ctx, uint32_t poolid, libxl_sched_credit_param *scinfo)Long line here and in
_set.Shouldn't this be "params" rather than "param" since it sets several parameters ?
Hmm, I suppose so. I think I accidentally said "param" because I originally wrote the patch series, the structure actually only contained one parameter. Then I thought I might as well do both at the same time, but didn't have to re-write this patch. :-)
-George
Re: [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et
George Dunlap writes ("Re: [Xen-devel] [PATCH 08 of 10] libxl: Implement libxl_sched_credit_param_[gs]et"):
Quoted 8 lines · Ian Jackson
Quoted 2 lines
Shouldn't this be "params" rather than "param" since it sets several parameters ?
Hmm, I suppose so. I think I accidentally said "param" because I originally wrote the patch series, the structure actually only contained one parameter. Then I thought I might as well do both at the same time, but didn't have to re-write this patch. :-)
Well, a "params" struct containing only one param for this particular scheduler is less weird than a "param" one containing several...
Ian.
PATCH 1/1 xl: Refactor sched_domain_output to have a callback for pool information
In reply to George DunlapAllow a scheduler to provide a callback to display pool-wide information, providing a default. This is in preparation for displaying pool-wide scheduler parameters on this line.
tools/libxl/xl_cmdimpl.c +23 -8
@@ -4059,13 +4059,24 @@ static int sched_sedf_domain_output(return 0 ; } +static int sched_default_pool_output ( +uint32_t poolid) +{ +char *poolname; + + poolname =libxl_cpupoolid_to_name (ctx, poolid); +printf ("Cpupool %s:\n" , + poolname); +free (poolname); +return 0 ; +} +static int sched_domain_output ( -uint32_t sched,int (*output)(int ),const char *cpupool) +uint32_t sched,int (*output)(int ),int (*pooloutput)(uint32_t ),const char *cpupool) {libxl_dominfo *info;libxl_cpupoolinfo *poolinfo =NULL ;uint32_t poolid; -char *poolname;int nb_domain, n_pools =0 , i, p;int rc =0 ;
@@ -4093,9 +4104,7 @@ static int sched_domain_output( (cpupool && (poolid != poolinfo[p].poolid)))continue ; - poolname =libxl_cpupoolid_to_name (ctx, poolinfo[p].poolid); -printf ("Cpupool %s:\n" , poolname); -free (poolname); +pooloutput (poolinfo[p].poolid);output (-1 );for (i =0 ; i < nb_domain; i++) {
@@ -4171,7 +4180,9 @@ int main_sched_credit(int argc, char **aif (!dom) {/* list all domain's credit scheduler info */ return -sched_domain_output (XEN_SCHEDULER_CREDIT , - sched_credit_domain_output, cpupool); + sched_credit_domain_output, + sched_default_pool_output, + cpupool); }else {find_domain (dom);
@@ -4247,7 +4258,9 @@ int main_sched_credit2(int argc, char **if (!dom) {/* list all domain's credit scheduler info */ return -sched_domain_output (XEN_SCHEDULER_CREDIT2 , - sched_credit2_domain_output, cpupool); + sched_credit2_domain_output, + sched_default_pool_output, + cpupool); }else {find_domain (dom);
@@ -4349,7 +4362,9 @@ int main_sched_sedf(int argc, char **argif (!dom) {/* list all domain's credit scheduler info */ return -sched_domain_output (XEN_SCHEDULER_SEDF , - sched_sedf_domain_output, cpupool); + sched_sedf_domain_output, + sched_default_pool_output, + cpupool); }else {find_domain (dom);
Re: [PATCH 09 of 10] xl: Refactor sched_domain_output to have a callback for pool information
George Dunlap writes ("[Xen-devel] [PATCH 09 of 10] xl: Refactor sched_domain_output to have a callback for pool information"):
tools/libxl/xl_cmdimpl.c static int sched_sedf_domain_output( · line 4064
Quoted 7 lines
Allow a scheduler to provide a callback to display pool-wide information, providing a default. This is in preparation for displaying pool-wide scheduler parameters on this line.
tools/libxl/xl_cmdimpl.c +3
-0+static int sched_default_pool_output ( +uint32_t poolid) +{
Formatting glitch. I know sched_domain_output looks like that but that's because it needs it to avoid wrapping.
tools/libxl/xl_cmdimpl.c static int sched_sedf_domain_output( · line 4075
Quoted 3 lines
static int sched_domain_output(
tools/libxl/xl_cmdimpl.c +1
-1- uint32_t sched, int (*output)(int), const char *cpupool) + uint32_t sched, int (*output)(int), int (*pooloutput)(uint32_t), const char *cpupool)
And here you've failed to wrap it :-). I suggest
static int sched_domain_output(uint32_t sched, const char *cpupool,
int (*output)(int), int (*pooloutput)(uint32_t))
{
but anything plausible is fine by me.
Aside from those niggles,
Ian.
PATCH 1/1 xl: Implement sched-credit schedule parameter command-line interface
In reply to George DunlapAdd features to the sched-credit interface to allow querying and displaying scheduler parameters. New interface works as follows:
<nothing> : List all domain params and sched params from all pools -d [domid] : List domain params for domain -d [domid] [params] : Set domain params for domain -p [pool] : list all domains and sched params for pool -s : List sched params for poolid 0 -s [params] : Set sched params for poolid 0 -p [pool] -s : List sched params for pool
-p [pool] -s [params] : Set sched params for pool
-p [pool] -d... : Illegal
tools/libxl/xl_cmdimpl.c +111 -7
@@ -3936,6 +3936,30 @@ static int sched_credit_domain_set(return rc; } +static int sched_credit_param_set ( +int poolid,libxl_sched_credit_param *scinfo) +{ +int rc; + + rc =libxl_sched_credit_param_set (ctx, poolid, scinfo); +if (rc) +fprintf (stderr,"libxl_sched_credit_param_set failed.\n" ); + +return rc; +} + +static int sched_credit_param_get ( +int poolid,libxl_sched_credit_param *scinfo) +{ +int rc; + + rc =libxl_sched_credit_param_get (ctx, poolid, scinfo); +if (rc) +fprintf (stderr,"libxl_sched_credit_domain_get failed.\n" ); + +return rc; +} +static int sched_credit_domain_output (int domid) {
@@ -3960,6 +3984,25 @@ static int sched_credit_domain_output(return 0 ; } +static int sched_credit_pool_output ( +uint32_t poolid) +{ +libxl_sched_credit_param scparam; +char *poolname; +int rc; + + rc =sched_credit_param_get (poolid, &scparam); +if (rc) +return rc; + poolname =libxl_cpupoolid_to_name (ctx, poolid); +printf ("Cpupool %s: tslice=%dms ratelimit=%dus\n" , + poolname, + scparam.tslice_ms, + scparam.ratelimit_us); +free (poolname); +return 0 ; +} +static int sched_credit2_domain_get (int domid,libxl_sched_credit2_domain *scinfo) {
@@ -4123,25 +4166,41 @@ static int sched_domain_output(return 0 ; } +/* +* <nothing> : List all domain params and sched params from all pools +* -d [domid] : List domain params for domain +* -d [domid] [params] : Set domain params for domain +* -p [pool] : list all domains and sched params for pool +* -s : List sched params for poolid 0 +* -s [params] : Set sched params for poolid 0 +* -p [pool] -s : List sched params for pool +* -p [pool] -s [params] : Set sched params for pool +* -p [pool] -d... : Illegal +*/ int main_sched_credit (int argc,char **argv) {libxl_sched_credit_domain scinfo;const char *dom =NULL ;const char *cpupool =NULL ;int weight =256 , cap =0 , opt_w =0 , opt_c =0 ; +int opt_s =0 ; +int tslice =0 , opt_t =0 , ratelimit =0 , opt_r =0 ;int opt, rc;int option_index =0 ;static struct option long_options[] = { {"domain" ,1 ,0 ,'d' }, {"weight" ,1 ,0 ,'w' }, {"cap" ,1 ,0 ,'c' }, + {"schedparam" ,0 ,0 ,'s' }, + {"tslice_ms" ,1 ,0 ,'t' }, + {"ratelimit_us" ,1 ,0 ,'r' }, {"cpupool" ,1 ,0 ,'p' }, {"help" ,0 ,0 ,'h' }, {0 ,0 ,0 ,0 } };while (1 ) { - opt =getopt_long (argc, argv,"d:w:c:p:h" , long_options, + opt =getopt_long (argc, argv,"d:w:c:p:t:r:hs" , long_options, &option_index);if (opt ==-1 )break ;
@@ -4159,6 +4218,17 @@ int main_sched_credit(int argc, char **a cap =strtol (optarg,NULL ,10 ); opt_c =1 ;break ; +case 't' : + tslice =strtol (optarg,NULL ,10 ); + opt_t =1 ; +break ; +case 'r' : + ratelimit =strtol (optarg,NULL ,10 ); + opt_r =1 ; +break ; +case 's' : + opt_s =1 ; +break ;case 'p' : cpupool = optarg;break ;
@@ -4168,20 +4238,54 @@ int main_sched_credit(int argc, char **a } } -if (cpupool && (dom || opt_w || opt_c)) { -fprintf (stderr,"Specifying a cpupool is not allowed with other " -"options.\n" ); +if ((cpupool || opt_s) && (dom || opt_w || opt_c)) { +fprintf (stderr,"Specifying a cpupool or schedparam is not " +"allowed with domain options.\n" );return 1 ; }if (!dom && (opt_w || opt_c)) {fprintf (stderr,"Must specify a domain.\n" );return 1 ; } - -if (!dom) {/* list all domain's credit scheduler info */ +if (!opt_s && (opt_t || opt_r)) { +fprintf (stderr,"Must specify schedparam to set schedule " +"parameter values.\n" ); +return 1 ; + } + +if (opt_s) { +libxl_sched_credit_param scparam; +uint32_t poolid =0 ; + +if (cpupool) { +if (cpupool_qualifier_to_cpupoolid (cpupool, &poolid,NULL ) || + !libxl_cpupoolid_to_name (ctx, poolid)) { +fprintf (stderr,"unknown cpupool \'%s\'\n" , cpupool); +return -ERROR_FAIL ; + } + } + +if (!opt_t && !opt_r) {/* Output scheduling parameters */ +return -sched_credit_pool_output (poolid); + }else {/* Set scheduling parameters*/ + rc =sched_credit_param_get (poolid, &scparam); +if (rc) +return -rc; + +if (opt_t) + scparam.tslice_ms = tslice; + +if (opt_r) + scparam.ratelimit_us = ratelimit; + + rc =sched_credit_param_set (poolid, &scparam); +if (rc) +return -rc; + } + }else if (!dom) {/* list all domain's credit scheduler info */ return -sched_domain_output (XEN_SCHEDULER_CREDIT , sched_credit_domain_output, - sched_default_pool_output, + sched_credit_pool_output, cpupool); }else {find_domain (dom);
tools/libxl/xl_cmdtable.c +8 -5
@@ -204,11 +204,14 @@ struct cmd_spec cmd_table[] = { {"sched-credit" , &main_sched_credit,0 ,"Get/set credit scheduler parameters" , -"[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]] [-p CPUPOOL]" , -"-d DOMAIN, --domain=DOMAIN Domain to modify\n" -"-w WEIGHT, --weight=WEIGHT Weight (int)\n" -"-c CAP, --cap=CAP Cap (int)\n" -"-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL" +"[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]] [-s [-t TSLICE] [-r RATELIMIT]] [-p CPUPOOL]" , +"-d DOMAIN, --domain=DOMAIN Domain to modify\n" +"-w WEIGHT, --weight=WEIGHT Weight (int)\n" +"-c CAP, --cap=CAP Cap (int)\n" +"-s --schedparam Query / modify scheduler parameters\n" +"-t TSLICE, --tslice_ms=TSLICE Set the timeslice, in milliseconds\n" +"-r RLIMIT, --ratelimit_us=RLIMIT Set the scheduling rate limit, in microseconds\n" +"-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL" }, { "sched-credit2", &main_sched_credit2, 0,
Re: [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface
George Dunlap writes ("[Xen-devel] [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface"):
Quoted 10 lines
Add features to the sched-credit interface to allow querying and displaying scheduler parameters. New interface works as follows:
<nothing> : List all domain params and sched params from all pools -d [domid] : List domain params for domain -d [domid] [params] : Set domain params for domain -p [pool] : list all domains and sched params for pool -s : List sched params for poolid 0 -s [params] : Set sched params for poolid 0 -p [pool] -s : List sched params for pool
Quoted 2 lines
-p [pool] -s [params] : Set sched params for pool
-p [pool] -d... : Illegal
This information should be in the xl manpage, rather than in the commit message and a code comment.
tools/libxl/xl_cmdimpl.c static int sched_credit_domain_set( · line 3941
Quoted 3 lines
tools/libxl/xl_cmdimpl.c +3
-0+static int sched_credit_param_set ( +int poolid,libxl_sched_credit_param *scinfo) +{
Formatting. It should be
static int sched_credit_param_set(int poolid, libxl_sched_credit_param *scinfo)
(79 columns) or
static int sched_credit_param_set(int poolid,
libxl_sched_credit_param *scinfo)
(67 columns).
This should be changed throughout I'm afraid.
tools/libxl/xl_cmdimpl.c int main_sched_credit(int argc, char **a · line 4271
Quoted 2 lines
tools/libxl/xl_cmdimpl.c +2
-0+ }else {/* Set scheduling parameters*/ + rc =sched_credit_param_get (poolid, &scparam);
What happens if the pool isn't using the credit scheduler ?
Thanks,
Ian.
Re: [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface
Quoted 14 lines · Ian Jackson
George Dunlap writes ("[Xen-devel] [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface"):
Quoted 10 lines
Add features to the sched-credit interface to allow querying and displaying scheduler parameters. New interface works as follows:
<nothing> : List all domain params and sched params from all pools -d [domid] : List domain params for domain -d [domid] [params] : Set domain params for domain -p [pool] : list all domains and sched params for pool -s : List sched params for poolid 0 -s [params] : Set sched params for poolid 0 -p [pool] -s : List sched params for poolQuoted 2 lines
-p [pool] -s [params] : Set sched params for pool
-p [pool] -d... : Illegal
Quoted 2 lines
This information should be in the xl manpage, rather than in the commit message and a code comment.
Of course. And, is there some other documentation that this should be put into as well?
Quoted 9 lines
tools/libxl/xl_cmdimpl.c static int sched_credit_domain_set( · line 3941
Quoted 4 lines
tools/libxl/xl_cmdimpl.c +3
-0+static int sched_credit_param_set ( +int poolid,libxl_sched_credit_param *scinfo) +{Formatting. It should be
static int
sched_credit_param_set(int poolid, libxl_sched_credit_param *scinfo)
Quoted 8 lines
(79 columns) or
static int sched_credit_param_set(int poolid,
libxl_sched_credit_param*scinfo)(67 columns).
This should be changed throughout I'm afraid.
Ack.
Quoted 5 lines
tools/libxl/xl_cmdimpl.c int main_sched_credit(int argc, char **a · line 4271
Quoted 3 lines
tools/libxl/xl_cmdimpl.c +2
-0+ }else {/* Set scheduling parameters*/ + rc =sched_credit_param_get (poolid, &scparam);What happens if the pool isn't using the credit scheduler ?
Ah, good point. I suppose it should just print the pool name.
What happens to output of domains when you use xl sched-credit and there is a pool that's not using the credit scheduler? It looks like it will stop at that point and quit processing. It seems like having it print the domain ID and "[not sched-credit]" or something like that would be better.
What would be *even* better is to unify these all somehow, so that xl would automatically detect the appropriate scheduler for the pool and behave accordingly. But that's a patch series for another time, I think.
-George
Re: [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface
George Dunlap writes ("Re: [Xen-devel] [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface"):
Quoted 7 lines · Ian Jackson
Quoted 3 lines
George Dunlap writes ("[Xen-devel] [PATCH 10 of 10] xl: Implement sched-credit schedule parameter command-line interface"):
This information should be in the xl manpage, rather than in the
commit message and a code comment.Of course. And, is there some other documentation that this should be put into as well?
I think what you have in the usage message, plus the manpage, is sufficient.
Quoted 4 lines
What would be *even* better is to unify these all somehow, so that xl would automatically detect the appropriate scheduler for the pool and behave accordingly. But that's a patch series for another time, I think.
Sure. I just wasn't sure from the code that you'd considered this case. I'd be happy with an error message of some kind, and a zero exit status.
Ian.