* [PATCH for 4.5 v4 3/4] libxl: add rtds scheduler
@ 2014-09-20 22:14 Meng Xu
2014-09-22 11:24 ` Ian Campbell
0 siblings, 1 reply; 2+ messages in thread
From: Meng Xu @ 2014-09-20 22:14 UTC (permalink / raw)
To: xen-devel
Cc: ian.campbell, xisisu, stefano.stabellini, george.dunlap, lu,
dario.faggioli, ian.jackson, ptxlinh, xumengpanda, Meng Xu,
chaowang, lichong659, dgolomb
Add libxl functions to set/get domain's parameters for rtds scheduler
Note: VCPU's information (period, budget) is in microsecond (us).
Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
Signed-off-by: Sisu Xi <xisisu@gmail.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
---
tools/libxl/libxl.c | 72 +++++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h | 7 +++++
tools/libxl/libxl_types.idl | 2 ++
3 files changed, 81 insertions(+)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index f796da8..233496e 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5443,6 +5443,72 @@ static int sched_sedf_domain_set(libxl__gc *gc, uint32_t domid,
return 0;
}
+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);
+ if (rc != 0) {
+ LOGE(ERROR, "getting domain sched rtds");
+ return ERROR_FAIL;
+ }
+
+ libxl_domain_sched_params_init(scinfo);
+
+ scinfo->sched = LIBXL_SCHEDULER_RTDS;
+ scinfo->period = sdom.period;
+ scinfo->budget = sdom.budget;
+
+ return 0;
+}
+
+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;
+
+ rc = xc_sched_rtds_domain_get(CTX->xch, domid, &sdom);
+ if (rc != 0) {
+ LOGE(ERROR, "getting domain sched rtds");
+ 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 = xc_sched_rtds_domain_set(CTX->xch, domid, &sdom);
+ if (rc < 0) {
+ LOGE(ERROR, "setting domain sched rtds");
+ return ERROR_FAIL;
+ }
+
+ return 0;
+}
+
int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
const libxl_domain_sched_params *scinfo)
{
@@ -5466,6 +5532,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_RTDS:
+ ret=sched_rtds_domain_set(gc, domid, scinfo);
+ break;
default:
LOG(ERROR, "Unknown scheduler");
ret=ERROR_INVAL;
@@ -5496,6 +5565,9 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
case LIBXL_SCHEDULER_CREDIT2:
ret=sched_credit2_domain_get(gc, domid, scinfo);
break;
+ case LIBXL_SCHEDULER_RTDS:
+ ret=sched_rtds_domain_get(gc, domid, scinfo);
+ break;
default:
LOG(ERROR, "Unknown scheduler");
ret=ERROR_INVAL;
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index bc68cac..b7f4f39 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -145,6 +145,12 @@
#define LIBXL_HAVE_BUILDINFO_IOMEM_START_GFN 1
/*
+ * LIBXL_HAVE_SCHED_RTDS indicates that the RTDS real time scheduler
+ * is available. A 'budget' field added in libxl_domain_sched_params.
+ */
+#define LIBXL_HAVE_SCHED_RTDS 1
+
+/*
* libxl ABI compatibility
*
* The only guarantee which libxl makes regarding ABI compatibility
@@ -1319,6 +1325,7 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid,
#define LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT -1
#define LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT -1
#define LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT -1
+#define LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT -1
int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
libxl_domain_sched_params *params);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index f1fcbc3..15234d6 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -156,6 +156,7 @@ libxl_scheduler = Enumeration("scheduler", [
(5, "credit"),
(6, "credit2"),
(7, "arinc653"),
+ (8, "rtds"),
])
# Consistent with SHUTDOWN_* in sched.h (apart from UNKNOWN)
@@ -318,6 +319,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'}),
+ ("budget", integer, {'init_val': 'LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT'}),
])
libxl_domain_build_info = Struct("domain_build_info",[
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH for 4.5 v4 3/4] libxl: add rtds scheduler
2014-09-20 22:14 [PATCH for 4.5 v4 3/4] libxl: add rtds scheduler Meng Xu
@ 2014-09-22 11:24 ` Ian Campbell
0 siblings, 0 replies; 2+ messages in thread
From: Ian Campbell @ 2014-09-22 11:24 UTC (permalink / raw)
To: Meng Xu
Cc: xisisu, stefano.stabellini, george.dunlap, lu, dario.faggioli,
ian.jackson, xen-devel, ptxlinh, xumengpanda, chaowang,
lichong659, dgolomb
On Sat, 2014-09-20 at 18:14 -0400, Meng Xu wrote:
> Add libxl functions to set/get domain's parameters for rtds scheduler
> Note: VCPU's information (period, budget) is in microsecond (us).
>
> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
> Signed-off-by: Sisu Xi <xisisu@gmail.com>
> Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
> Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-22 11:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-20 22:14 [PATCH for 4.5 v4 3/4] libxl: add rtds scheduler Meng Xu
2014-09-22 11:24 ` Ian Campbell
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).