mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Meng Xu <mengxu@cis.upenn.edu>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
This commit is contained in:
1 parent
340edc3902
commit
c3715dd8fb
7 files changed
+14
-111
No files matched your search
@@ -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,
|
||||
|
||||
|
||||
@@ -1292,35 +1292,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.
|
||||
*
|
||||
@@ -2257,9 +2234,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,
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -3072,14 +3055,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)
|
||||
{
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
+14
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 *);
|
||||
|
||||