[PATCH 6/8] stabilish default affinity for newly created cpus

Glauber Costa
2008-03-04T16:21:59Z

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
qemu/qemu-kvm.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index a36fbf6..80fe8e5 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -68,6 +68,12 @@ void kvm_register_default_affinities(void)
}
}

+static inline void kvm_default_affinity(int cpu)
+{
+ sched_setaffinity(vcpu_info[cpu].thread_id, sizeof(cpu_set_t),
+ &vcpu_info[cpu].cpu_set);
+}
+
static inline unsigned long kvm_get_thread_id(void)
{
return syscall(SYS_gettid);
@@ -353,6 +359,7 @@ static void *ap_main_loop(void *_env)
vcpu = &vcpu_info[env->cpu_index];
vcpu->env = env;
vcpu->thread_id = kvm_get_thread_id();
+ kvm_default_affinity(env->cpu_index);
sigfillset(&signals);
//sigdelset(&signals, SIG_IPI);
sigprocmask(SIG_BLOCK, &signals, NULL);
@@ -400,6 +407,7 @@ int kvm_init_ap(void)
vcpu = &vcpu_info[0];
vcpu->env = first_cpu;
vcpu->thread_id = kvm_get_thread_id();
+ kvm_default_affinity(0);
signal(SIG_IPI, sig_ipi_handler);
for (i = 1; i < smp_cpus; ++i) {
kvm_init_new_ap(i, env);
--
1.5.0.6