Re: [Xen-devel] [PATCH v2 3/5] tools: libxl/xl: allow to get/set Credit1's vcpu_migration_delay

2018-02-28 Thread George Dunlap
On 02/23/2018 04:41 PM, Dario Faggioli wrote:
> Make it possible to get and set a (Credit1) scheduler's
> vCPU migration delay via the SCHEDOP sysctl, from both
> libxl and xl (no change needed in libxc).
> 
> Signed-off-by: Dario Faggioli 
> ---
> Cc: Ian Jackson 
> Cc: Wei Liu 
> Cc: George Dunlap 
> Cc: Andrew Cooper 
> ---
> Changes from v1:
> * add missing 'break', fix using wrong variable in xl_sched.c.
> 
> Changes are small, but still I'm dropping Wei's Ack.
> ---
>  docs/man/xl.pod.1.in|   11 +++
>  tools/libxl/libxl.h |7 +++
>  tools/libxl/libxl_sched.c   |   10 ++
>  tools/libxl/libxl_types.idl |1 +
>  tools/xl/xl_cmdtable.c  |1 +
>  tools/xl/xl_sched.c |   23 ---
>  6 files changed, 46 insertions(+), 7 deletions(-)
> 
> diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
> index 7fd35c9ae7..48da2052cc 100644
> --- a/docs/man/xl.pod.1.in
> +++ b/docs/man/xl.pod.1.in
> @@ -1046,6 +1046,17 @@ we will allow a higher-priority VM to pre-empt it.  
> The default value
>  is 1000 microseconds (1ms).  Valid range is 100 to 50 (500ms).
>  The ratelimit length must be lower than the timeslice length.
>  
> +=item B<-m DELAY>, B<--migration_delay_us=DELAY>
> +
> +Migration delay specifies for how long a vCPU, after it stopped running 
> should
> +be considered "cache-hot". Basically, if less than DELAY us passed since when
> +the vCPU was executing on a CPU, it is likely that most of the vCPU's working
> +set is still in the CPU's cache, and therefore the vCPU is not migrated.
> +
> +Default is 0. Maximum is 100 ms. This can be effective at preventing vCPUs
> +to bounce among CPUs too quickly, but, at the same time, the scheduler stops
> +being fully work-conserving.
> +
>  =back
>  
>  B
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index eca0ea2c50..edd244278a 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -299,6 +299,13 @@
>   */
>  #define LIBXL_HAVE_SCHED_CREDIT2_PARAMS 1
>  
> +/*
> + * LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY indicates that there is a field
> + * in libxl_sched_credit_params called vcpu_migr_delay_us which controls
> + * the resistance of the vCPUs of the cpupool to migrations among pCPUs.
> + */
> +#define LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY
> +
>  /*
>   * LIBXL_HAVE_VIRIDIAN_CRASH_CTL indicates that the 'crash_ctl' value
>   * is present in the viridian enlightenment enumeration.
> diff --git a/tools/libxl/libxl_sched.c b/tools/libxl/libxl_sched.c
> index 512788f736..07289079ce 100644
> --- a/tools/libxl/libxl_sched.c
> +++ b/tools/libxl/libxl_sched.c
> @@ -291,6 +291,7 @@ int libxl_sched_credit_params_get(libxl_ctx *ctx, 
> uint32_t poolid,
>  
>  scinfo->tslice_ms = sparam.tslice_ms;
>  scinfo->ratelimit_us = sparam.ratelimit_us;
> +scinfo->vcpu_migr_delay_us = sparam.vcpu_migr_delay_us;
>  
>  rc = 0;
>   out:
> @@ -321,9 +322,17 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, 
> uint32_t poolid,
>  rc = ERROR_INVAL;
>  goto out;
>  }
> +if (scinfo->vcpu_migr_delay_us
> +&& scinfo->vcpu_migr_delay_us > XEN_SYSCTL_CSCHED_MGR_DLY_MAX) {

Same idea -- no need to check if it's zero and then check to see if it's
greater than DLY_MAX.

Other than that, looks good.

 -George

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 3/5] tools: libxl/xl: allow to get/set Credit1's vcpu_migration_delay

2018-02-23 Thread Wei Liu
On Fri, Feb 23, 2018 at 05:41:48PM +0100, Dario Faggioli wrote:
> Make it possible to get and set a (Credit1) scheduler's
> vCPU migration delay via the SCHEDOP sysctl, from both
> libxl and xl (no change needed in libxc).
> 
> Signed-off-by: Dario Faggioli 

Acked-by: Wei Liu 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 3/5] tools: libxl/xl: allow to get/set Credit1's vcpu_migration_delay

2018-02-23 Thread Dario Faggioli
Make it possible to get and set a (Credit1) scheduler's
vCPU migration delay via the SCHEDOP sysctl, from both
libxl and xl (no change needed in libxc).

Signed-off-by: Dario Faggioli 
---
Cc: Ian Jackson 
Cc: Wei Liu 
Cc: George Dunlap 
Cc: Andrew Cooper 
---
Changes from v1:
* add missing 'break', fix using wrong variable in xl_sched.c.

Changes are small, but still I'm dropping Wei's Ack.
---
 docs/man/xl.pod.1.in|   11 +++
 tools/libxl/libxl.h |7 +++
 tools/libxl/libxl_sched.c   |   10 ++
 tools/libxl/libxl_types.idl |1 +
 tools/xl/xl_cmdtable.c  |1 +
 tools/xl/xl_sched.c |   23 ---
 6 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 7fd35c9ae7..48da2052cc 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1046,6 +1046,17 @@ we will allow a higher-priority VM to pre-empt it.  The 
default value
 is 1000 microseconds (1ms).  Valid range is 100 to 50 (500ms).
 The ratelimit length must be lower than the timeslice length.
 
+=item B<-m DELAY>, B<--migration_delay_us=DELAY>
+
+Migration delay specifies for how long a vCPU, after it stopped running should
+be considered "cache-hot". Basically, if less than DELAY us passed since when
+the vCPU was executing on a CPU, it is likely that most of the vCPU's working
+set is still in the CPU's cache, and therefore the vCPU is not migrated.
+
+Default is 0. Maximum is 100 ms. This can be effective at preventing vCPUs
+to bounce among CPUs too quickly, but, at the same time, the scheduler stops
+being fully work-conserving.
+
 =back
 
 B
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index eca0ea2c50..edd244278a 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -299,6 +299,13 @@
  */
 #define LIBXL_HAVE_SCHED_CREDIT2_PARAMS 1
 
+/*
+ * LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY indicates that there is a field
+ * in libxl_sched_credit_params called vcpu_migr_delay_us which controls
+ * the resistance of the vCPUs of the cpupool to migrations among pCPUs.
+ */
+#define LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY
+
 /*
  * LIBXL_HAVE_VIRIDIAN_CRASH_CTL indicates that the 'crash_ctl' value
  * is present in the viridian enlightenment enumeration.
diff --git a/tools/libxl/libxl_sched.c b/tools/libxl/libxl_sched.c
index 512788f736..07289079ce 100644
--- a/tools/libxl/libxl_sched.c
+++ b/tools/libxl/libxl_sched.c
@@ -291,6 +291,7 @@ int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t 
poolid,
 
 scinfo->tslice_ms = sparam.tslice_ms;
 scinfo->ratelimit_us = sparam.ratelimit_us;
+scinfo->vcpu_migr_delay_us = sparam.vcpu_migr_delay_us;
 
 rc = 0;
  out:
@@ -321,9 +322,17 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t 
poolid,
 rc = ERROR_INVAL;
 goto out;
 }
+if (scinfo->vcpu_migr_delay_us
+&& scinfo->vcpu_migr_delay_us > XEN_SYSCTL_CSCHED_MGR_DLY_MAX) {
+LOG(ERROR, "vcpu migration delay should be > 0 and < %d",
+XEN_SYSCTL_CSCHED_MGR_DLY_MAX);
+rc = ERROR_INVAL;
+goto out;
+}
 
 sparam.tslice_ms = scinfo->tslice_ms;
 sparam.ratelimit_us = scinfo->ratelimit_us;
+sparam.vcpu_migr_delay_us = scinfo->vcpu_migr_delay_us;
 
 r = xc_sched_credit_params_set(ctx->xch, poolid, );
 if ( r < 0 ) {
@@ -334,6 +343,7 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t 
poolid,
 
 scinfo->tslice_ms = sparam.tslice_ms;
 scinfo->ratelimit_us = sparam.ratelimit_us;
+scinfo->vcpu_migr_delay_us = sparam.vcpu_migr_delay_us;
 
 rc = 0;
  out:
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 35038120ca..dbb287d6fe 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -973,6 +973,7 @@ libxl_pcitopology = Struct("pcitopology", [
 libxl_sched_credit_params = Struct("sched_credit_params", [
 ("tslice_ms", integer),
 ("ratelimit_us", integer),
+("vcpu_migr_delay_us", integer),
 ], dispose_fn=None)
 
 libxl_sched_credit2_params = Struct("sched_credit2_params", [
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 6d894394ca..bf2ced8140 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -257,6 +257,7 @@ struct cmd_spec cmd_table[] = {
   "-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"
+  "-m DLY, --migration_delay_us=DLY  Set the migration delay, in 
microseconds\n"
   "-p CPUPOOL, --cpupool=CPUPOOL Restrict output to CPUPOOL"
 },
 { "sched-credit2",
diff --git a/tools/xl/xl_sched.c b/tools/xl/xl_sched.c
index 7965ccbca0..73cd7040cd 100644
---