aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <juergen.gross@ts.fujitsu.com>2012-01-24 14:19:58 +0000
committerJuergen Gross <juergen.gross@ts.fujitsu.com>2012-01-24 14:19:58 +0000
commit9b80635f9dd46b584f04c8e948a71c48bd412f96 (patch)
tree65d633f3bdd797f2207ecd2fef863ccf48c2d07c
parent04b9829949d79e753c8047f4ef620a82b1743349 (diff)
downloadxen-9b80635f9dd46b584f04c8e948a71c48bd412f96.tar.gz
xen-9b80635f9dd46b584f04c8e948a71c48bd412f96.tar.bz2
xen-9b80635f9dd46b584f04c8e948a71c48bd412f96.zip
introduce and use common macros for selecting cpupool based cpumasks
There are several instances of the same construct finding the cpumask for a cpupool. Use macros instead. Signed-off-by: juergen.gross@ts.fujitsu.com Committed-by: Keir Fraser <keir@xen.org>
-rw-r--r--xen/common/domctl.c2
-rw-r--r--xen/common/sched_credit.c6
-rw-r--r--xen/common/sched_credit2.c2
-rw-r--r--xen/common/sched_sedf.c8
-rw-r--r--xen/common/schedule.c6
-rw-r--r--xen/include/xen/sched-if.h5
6 files changed, 13 insertions, 16 deletions
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 14ab515ae7..5b0fc4a511 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -518,7 +518,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
goto maxvcpu_out;
ret = -ENOMEM;
- online = (d->cpupool == NULL) ? &cpu_online_map : d->cpupool->cpu_valid;
+ online = cpupool_online_cpumask(d->cpupool);
if ( max > d->max_vcpus )
{
struct vcpu **vcpus;
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index 01f5999ffb..015ea21a70 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -72,8 +72,6 @@
#define CSCHED_VCPU(_vcpu) ((struct csched_vcpu *) (_vcpu)->sched_priv)
#define CSCHED_DOM(_dom) ((struct csched_dom *) (_dom)->sched_priv)
#define RUNQ(_cpu) (&(CSCHED_PCPU(_cpu)->runq))
-#define CSCHED_CPUONLINE(_pool) \
- (((_pool) == NULL) ? &cpupool_free_cpus : (_pool)->cpu_valid)
/*
@@ -471,7 +469,7 @@ _csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t commit)
* Pick from online CPUs in VCPU's affinity mask, giving a
* preference to its current processor if it's in there.
*/
- online = CSCHED_CPUONLINE(vc->domain->cpupool);
+ online = cpupool_scheduler_cpumask(vc->domain->cpupool);
cpumask_and(&cpus, online, vc->cpu_affinity);
cpu = cpumask_test_cpu(vc->processor, &cpus)
? vc->processor
@@ -1230,7 +1228,7 @@ csched_load_balance(struct csched_private *prv, int cpu,
int peer_cpu;
BUG_ON( cpu != snext->vcpu->processor );
- online = CSCHED_CPUONLINE(per_cpu(cpupool, cpu));
+ online = cpupool_scheduler_cpumask(per_cpu(cpupool, cpu));
/* If this CPU is going offline we shouldn't steal work. */
if ( unlikely(!cpumask_test_cpu(cpu, online)) )
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index ac2be2a268..785303b259 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -169,8 +169,6 @@ integer_param("sched_credit2_migrate_resist", opt_migrate_resist);
((struct csched_private *)((_ops)->sched_data))
#define CSCHED_VCPU(_vcpu) ((struct csched_vcpu *) (_vcpu)->sched_priv)
#define CSCHED_DOM(_dom) ((struct csched_dom *) (_dom)->sched_priv)
-#define CSCHED_CPUONLINE(_pool) \
- (((_pool) == NULL) ? &cpupool_free_cpus : (_pool)->cpu_valid)
/* CPU to runq_id macro */
#define c2r(_ops, _cpu) (CSCHED_PRIV(_ops)->runq_map[(_cpu)])
/* CPU to runqueue struct macro */
diff --git a/xen/common/sched_sedf.c b/xen/common/sched_sedf.c
index 11b0af4775..644787bc7f 100644
--- a/xen/common/sched_sedf.c
+++ b/xen/common/sched_sedf.c
@@ -13,9 +13,6 @@
#include <xen/time.h>
#include <xen/errno.h>
-#define SEDF_CPUONLINE(_pool) \
- (((_pool) == NULL) ? &cpupool_free_cpus : (_pool)->cpu_valid)
-
#ifndef NDEBUG
#define SEDF_STATS
#define CHECK(_p) \
@@ -397,7 +394,7 @@ static int sedf_pick_cpu(const struct scheduler *ops, struct vcpu *v)
cpumask_t online_affinity;
cpumask_t *online;
- online = SEDF_CPUONLINE(v->domain->cpupool);
+ online = cpupool_scheduler_cpumask(v->domain->cpupool);
cpumask_and(&online_affinity, v->cpu_affinity, online);
return cpumask_first(&online_affinity);
}
@@ -801,7 +798,8 @@ static struct task_slice sedf_do_schedule(
*/
if ( tasklet_work_scheduled ||
(list_empty(runq) && list_empty(waitq)) ||
- unlikely(!cpumask_test_cpu(cpu, SEDF_CPUONLINE(per_cpu(cpupool, cpu)))) )
+ unlikely(!cpumask_test_cpu(cpu,
+ cpupool_scheduler_cpumask(per_cpu(cpupool, cpu)))) )
{
ret.task = IDLETASK(cpu);
ret.time = SECONDS(1);
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 54658adca1..c494017fc5 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -77,9 +77,7 @@ static struct scheduler __read_mostly ops;
#define DOM2OP(_d) (((_d)->cpupool == NULL) ? &ops : ((_d)->cpupool->sched))
#define VCPU2OP(_v) (DOM2OP((_v)->domain))
-#define VCPU2ONLINE(_v) \
- (((_v)->domain->cpupool == NULL) ? &cpu_online_map \
- : (_v)->domain->cpupool->cpu_valid)
+#define VCPU2ONLINE(_v) cpupool_online_cpumask((_v)->domain->cpupool)
static inline void trace_runstate_change(struct vcpu *v, int new_state)
{
@@ -1418,7 +1416,7 @@ void schedule_dump(struct cpupool *c)
cpumask_t *cpus;
sched = (c == NULL) ? &ops : c->sched;
- cpus = (c == NULL) ? &cpupool_free_cpus : c->cpu_valid;
+ cpus = cpupool_scheduler_cpumask(c);
printk("Scheduler: %s (%s)\n", sched->name, sched->opt_name);
SCHED_OP(sched, dump_settings);
diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h
index 03f9d8ddcc..d6fa15a702 100644
--- a/xen/include/xen/sched-if.h
+++ b/xen/include/xen/sched-if.h
@@ -204,4 +204,9 @@ struct cpupool
atomic_t refcnt;
};
+#define cpupool_scheduler_cpumask(_pool) \
+ (((_pool) == NULL) ? &cpupool_free_cpus : (_pool)->cpu_valid)
+#define cpupool_online_cpumask(_pool) \
+ (((_pool) == NULL) ? &cpu_online_map : (_pool)->cpu_valid)
+
#endif /* __XEN_SCHED_IF_H__ */