|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/6] xen/sched: Remove {init, destroy}_domain() interfaces
These hooks have one single caller (sched_{init,destroy}_domain()
respectively) and are all identical (when implemented).
Previous changes have ensured that only real domains reach these functions, so
ASSERT() that system domains are not seen. Call sched_{alloc,free}_domdata()
directly, and handle d->sched_priv directly.
The net diffstat is:
add/remove: 0/8 grow/shrink: 1/7 up/down: 7/-335 (-328)
function old new delta
sched_destroy_domain 130 137 +7
sched_init_domain 138 137 -1
rt_dom_destroy 6 - -6
null_dom_destroy 6 - -6
csched_dom_destroy 9 - -9
csched2_dom_destroy 9 - -9
sched_rtds_def 264 248 -16
sched_null_def 264 248 -16
sched_credit_def 264 248 -16
sched_credit2_def 264 248 -16
sched_arinc653_def 264 248 -16
ops 264 248 -16
rt_dom_init 52 - -52
null_dom_init 52 - -52
csched_dom_init 52 - -52
csched2_dom_init 52 - -52
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
CC: Dario Faggioli <dfaggioli@xxxxxxxx>
CC: Meng Xu <mengxu@xxxxxxxxxxxxx>
CC: Josh Whitehead <josh.whitehead@xxxxxxxxxxxxxxx>
CC: Robert VanVossen <robert.vanvossen@xxxxxxxxxxxxxxx>
---
xen/common/sched_arinc653.c | 3 ---
xen/common/sched_credit.c | 26 --------------------------
xen/common/sched_credit2.c | 28 ----------------------------
xen/common/sched_null.c | 23 -----------------------
xen/common/sched_rt.c | 26 --------------------------
xen/common/schedule.c | 16 ++++++++++++++--
xen/include/xen/sched-if.h | 3 ---
7 files changed, 14 insertions(+), 111 deletions(-)
diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c
index 17e765d..a4c6d00 100644
--- a/xen/common/sched_arinc653.c
+++ b/xen/common/sched_arinc653.c
@@ -712,9 +712,6 @@ static const struct scheduler sched_arinc653_def = {
.free_vdata = a653sched_free_vdata,
.alloc_vdata = a653sched_alloc_vdata,
- .init_domain = NULL,
- .destroy_domain = NULL,
-
.insert_vcpu = NULL,
.remove_vcpu = NULL,
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index e2133df..0178ff5 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -1293,35 +1293,12 @@ csched_alloc_domdata(const struct scheduler *ops,
struct domain *dom)
return sdom;
}
-static int
-csched_dom_init(const struct scheduler *ops, struct domain *dom)
-{
- struct csched_dom *sdom;
-
- if ( is_idle_domain(dom) )
- return 0;
-
- sdom = csched_alloc_domdata(ops, dom);
- if ( IS_ERR(sdom) )
- return PTR_ERR(sdom);
-
- dom->sched_priv = sdom;
-
- return 0;
-}
-
static void
csched_free_domdata(const struct scheduler *ops, void *data)
{
xfree(data);
}
-static void
-csched_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
- csched_free_domdata(ops, CSCHED_DOM(dom));
-}
-
/*
* This is a O(n) optimized sort of the runq.
*
@@ -2259,9 +2236,6 @@ static const struct scheduler sched_credit_def = {
.sched_id = XEN_SCHEDULER_CREDIT,
.sched_data = NULL,
- .init_domain = csched_dom_init,
- .destroy_domain = csched_dom_destroy,
-
.insert_vcpu = csched_vcpu_insert,
.remove_vcpu = csched_vcpu_remove,
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 29a24d6..5a635e8 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -3035,23 +3035,6 @@ csched2_alloc_domdata(const struct scheduler *ops,
struct domain *dom)
return sdom;
}
-static int
-csched2_dom_init(const struct scheduler *ops, struct domain *dom)
-{
- struct csched2_dom *sdom;
-
- if ( is_idle_domain(dom) )
- return 0;
-
- sdom = csched2_alloc_domdata(ops, dom);
- if ( IS_ERR(sdom) )
- return PTR_ERR(sdom);
-
- dom->sched_priv = sdom;
-
- return 0;
-}
-
static void
csched2_free_domdata(const struct scheduler *ops, void *data)
{
@@ -3073,14 +3056,6 @@ csched2_free_domdata(const struct scheduler *ops, void
*data)
}
static void
-csched2_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
- ASSERT(csched2_dom(dom)->nr_vcpus == 0);
-
- csched2_free_domdata(ops, csched2_dom(dom));
-}
-
-static void
csched2_vcpu_insert(const struct scheduler *ops, struct vcpu *vc)
{
struct csched2_vcpu *svc = vc->sched_priv;
@@ -4016,9 +3991,6 @@ static const struct scheduler sched_credit2_def = {
.sched_id = XEN_SCHEDULER_CREDIT2,
.sched_data = NULL,
- .init_domain = csched2_dom_init,
- .destroy_domain = csched2_dom_destroy,
-
.insert_vcpu = csched2_vcpu_insert,
.remove_vcpu = csched2_vcpu_remove,
diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c
index 4dd405b..58e306a 100644
--- a/xen/common/sched_null.c
+++ b/xen/common/sched_null.c
@@ -259,26 +259,6 @@ static void null_free_domdata(const struct scheduler *ops,
void *data)
}
}
-static int null_dom_init(const struct scheduler *ops, struct domain *d)
-{
- struct null_dom *ndom;
-
- if ( is_idle_domain(d) )
- return 0;
-
- ndom = null_alloc_domdata(ops, d);
- if ( IS_ERR(ndom) )
- return PTR_ERR(ndom);
-
- d->sched_priv = ndom;
-
- return 0;
-}
-static void null_dom_destroy(const struct scheduler *ops, struct domain *d)
-{
- null_free_domdata(ops, null_dom(d));
-}
-
/*
* vCPU to pCPU assignment and placement. This _only_ happens:
* - on insert,
@@ -923,9 +903,6 @@ const struct scheduler sched_null_def = {
.alloc_domdata = null_alloc_domdata,
.free_domdata = null_free_domdata,
- .init_domain = null_dom_init,
- .destroy_domain = null_dom_destroy,
-
.insert_vcpu = null_vcpu_insert,
.remove_vcpu = null_vcpu_remove,
diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index e4ff5c1..1c72ea8 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -851,30 +851,6 @@ rt_free_domdata(const struct scheduler *ops, void *data)
}
}
-static int
-rt_dom_init(const struct scheduler *ops, struct domain *dom)
-{
- struct rt_dom *sdom;
-
- /* IDLE Domain does not link on rt_private */
- if ( is_idle_domain(dom) )
- return 0;
-
- sdom = rt_alloc_domdata(ops, dom);
- if ( IS_ERR(sdom) )
- return PTR_ERR(sdom);
-
- dom->sched_priv = sdom;
-
- return 0;
-}
-
-static void
-rt_dom_destroy(const struct scheduler *ops, struct domain *dom)
-{
- rt_free_domdata(ops, rt_dom(dom));
-}
-
static void *
rt_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)
{
@@ -1585,8 +1561,6 @@ static const struct scheduler sched_rtds_def = {
.deinit_pdata = rt_deinit_pdata,
.alloc_domdata = rt_alloc_domdata,
.free_domdata = rt_free_domdata,
- .init_domain = rt_dom_init,
- .destroy_domain = rt_dom_destroy,
.alloc_vdata = rt_alloc_vdata,
.free_vdata = rt_free_vdata,
.insert_vcpu = rt_vcpu_insert,
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 08a31b6..5f596f0 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -413,25 +413,37 @@ void sched_destroy_vcpu(struct vcpu *v)
int sched_init_domain(struct domain *d, int poolid)
{
+ void *sdom;
int ret;
ASSERT(d->cpupool == NULL);
+ ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
if ( (ret = cpupool_add_domain(d, poolid)) )
return ret;
SCHED_STAT_CRANK(dom_init);
TRACE_1D(TRC_SCHED_DOM_ADD, d->domain_id);
- return SCHED_OP(dom_scheduler(d), init_domain, d);
+
+ sdom = sched_alloc_domdata(dom_scheduler(d), d);
+ if ( IS_ERR(sdom) )
+ return PTR_ERR(sdom);
+
+ d->sched_priv = sdom;
+
+ return 0;
}
void sched_destroy_domain(struct domain *d)
{
ASSERT(d->cpupool != NULL || is_idle_domain(d));
+ ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
SCHED_STAT_CRANK(dom_destroy);
TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id);
- SCHED_OP(dom_scheduler(d), destroy_domain, d);
+
+ sched_free_domdata(dom_scheduler(d), d->sched_priv);
+ d->sched_priv = NULL;
cpupool_rm_domain(d);
}
diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h
index 56e7d0c..4895242 100644
--- a/xen/include/xen/sched-if.h
+++ b/xen/include/xen/sched-if.h
@@ -155,9 +155,6 @@ struct scheduler {
void (*switch_sched) (struct scheduler *, unsigned int,
void *, void *);
- int (*init_domain) (const struct scheduler *, struct domain *);
- void (*destroy_domain) (const struct scheduler *, struct domain *);
-
/* Activate / deactivate vcpus in a cpu pool */
void (*insert_vcpu) (const struct scheduler *, struct vcpu *);
void (*remove_vcpu) (const struct scheduler *, struct vcpu *);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |