KVM SMP support, early version
cover KVM SMP support, early version
Hi guys,
This is an early version of smp support in kvm that kinda works. It has some known problems that I am still tracking. For example, it does not reset very well. Also, initialization is a bit slow, probably because of the number of remote ioctl calls involved. But I believe Jan's patch to do a single ioctl can make it better.
Normal operation seem to be going smooth for me. I can boot the machine and get it going decently. I'll keep working on the issues, but comments are welcome in the mean time.
PATCH 1/7 Don't mess with halted state.
When we have irqchip in kernel, halted state is kernel business. So don't initialize it in our code.
--- hw/apic-kvm.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
hw/apic-kvm.c +1 -2
@@ -122,10 +122,9 @@ static void kvm_apic_reset(void *opaque) s->dev.next_time =0 ; s->dev.wait_for_sipi =1 ; - s->cpu_env->halted = !(s->dev.apicbase &MSR_IA32_APICBASE_BSP ); s->cpu_env->mp_state - = s->cpu_env->halted ?KVM_MP_STATE_UNINITIALIZED :KVM_MP_STATE_RUNNABLE ; + = bsp ?KVM_MP_STATE_RUNNABLE :KVM_MP_STATE_UNINITIALIZED ;kvm_put_mp_state (s->cpu_env);
Signature · 1 line
1.6.5.2
PATCH 2/7 store thread-specific env information
Since we'll have multiple cpu threads, at least for kvm, we need a way to store and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.
I am using pthread functions for that, for portability, but we could as well use __thread keyword.
--- vl.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
vl.c +21 -0
@@ -3436,6 +3436,24 @@ static void block_io_signals(void);static void unblock_io_signals (void );static int tcg_has_work (void ); +static pthread_key_t current_env; + +CPUState *qemu_get_current_env (void ); +CPUState *qemu_get_current_env (void ) +{ +return pthread_getspecific (current_env); +} + +static void qemu_set_current_env (CPUState *env) +{ +pthread_setspecific (current_env, env); +} + +static void qemu_init_current_env (void ) +{ +pthread_key_create (¤t_env,NULL ); +} +static int qemu_init_main_loop (void ) {int ret;
@@ -3448,6 +3466,7 @@ static int qemu_init_main_loop(void)qemu_mutex_init (&qemu_fair_mutex);qemu_mutex_init (&qemu_global_mutex);qemu_mutex_lock (&qemu_global_mutex); +qemu_init_current_env ();unblock_io_signals ();qemu_thread_self (&io_thread);
@@ -3486,6 +3505,8 @@ static void *kvm_cpu_thread_fn(void *arg)block_io_signals ();qemu_thread_self (env->thread); +qemu_set_current_env (env); +if (kvm_enabled ())kvm_init_vcpu (env);
Signature · 1 line
1.6.5.2
PATCH 3/7 update halted state on mp_state sync
If we are using in-kernel irqchip, halted state belongs in the kernel. So everytime we grab kernel's idea of mpstate, we also need to propagate halted state to userspace.
--- target-i386/kvm.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
target-i386/kvm.c +5 -0
@@ -825,6 +825,11 @@ static int kvm_get_mp_state(CPUState *env)return ret; } env->mp_state = mp_state.mp_state; + +if (kvm_irqchip_in_kernel ()) { + env->halted = (env->mp_state ==KVM_MP_STATE_HALTED ); + } +return 0 ; }
Signature · 1 line
1.6.5.2
PATCH 4/7 qemu_flush_work for remote vcpu execution
This function is similar to qemu-kvm's on_vcpu mechanism. Totally synchronous, and guarantees that a given function will be executed at the specified vcpu.
The approach I am taking is to put it under the hood, in kvm_vcpu_ioctl. This way, the kvm_vcpu_ioctl can be used anywhere, and we guarantee it will never be executed outside its realm.
This is not much of a problem, since remote execution is rare. It does happen at lot at machine bootup, because saving/restoring registers spans a lot of ioctls, but this should get better if we move to Jan's patch of doing it all at once.
--- cpu-all.h | 3 ++ cpu-defs.h | 14 +++++++++++ kvm-all.c | 75 ++++++++++++++++++++++++----------------------------------- kvm.h | 7 +++++ vl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 113 insertions(+), 49 deletions(-)
cpu-all.h +3 -0
@@ -763,6 +763,9 @@ extern CPUState *cpu_single_env;extern int64_t qemu_icount;extern int use_icount; +void qemu_queue_work (CPUState *env,void (*func)(void *data),void *data); +void qemu_flush_work (CPUState *env); +#define CPU_INTERRUPT_HARD 0x02/* hardware interrupt pending */ #define CPU_INTERRUPT_EXITTB 0x04/* exit the current TB (use for x86 a20 case) */ #define CPU_INTERRUPT_TIMER 0x08/* internal timer exception pending */
cpu-defs.h +14 -0
@@ -31,6 +31,8 @@#include "qemu-queue.h" #include "targphys.h" +#include "qemu-thread.h" +#ifndef TARGET_LONG_BITS #error TARGET_LONG_BITS must be defined before including this header#endif
@@ -134,6 +136,13 @@ typedef struct CPUWatchpoint {QTAILQ_ENTRY (CPUWatchpoint) entry; } CPUWatchpoint; +typedef struct QemuWorkItem { +void (*func)(void *data); +void *data; +int done; +}QemuWorkItem ; + +#define CPU_TEMP_BUF_NLONGS 128#define CPU_COMMON \ struct TranslationBlock *current_tb;/* currently executing TB */ \
@@ -175,6 +184,10 @@ typedef struct CPUWatchpoint { QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \CPUWatchpoint *watchpoint_hit; \ \ +QemuWorkItem queued_work; \ +uint64_t queued_local, queued_total; \ +struct QemuMutex queue_lock; \ + \struct GDBRegisterState *gdb_regs; \ \/* Core interrupt code */ \
@@ -194,6 +207,7 @@ typedef struct CPUWatchpoint {uint32_t created; \struct QemuThread *thread; \struct QemuCond *halt_cond; \ +struct QemuCond work_cond; \const char *cpu_model_str; \struct KVMState *kvm_state; \struct kvm_run *kvm_run; \
kvm-all.c +31 -44
115 lines not on this page · raw message
kvm.h +7 -0
@@ -149,4 +149,11 @@ static inline void cpu_synchronize_state(CPUState *env) } } +typedef struct KVMIoctl { +int fd; +int type; +int ret; +void *data; +}KVMIoctl ; +#endif
vl.c +58 -5
114 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 5/7 tell kernel about all registers instead of just mp_state
This fix a bug with -smp in kvm. Since we have updated apic_base, we also have to tell kernel about it. So instead of just updating mp_state, update every regs.
--- hw/apic-kvm.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
hw/apic-kvm.c +4 -1
@@ -126,7 +126,10 @@ static void kvm_apic_reset(void *opaque) s->cpu_env->mp_state = bsp ?KVM_MP_STATE_RUNNABLE :KVM_MP_STATE_UNINITIALIZED ; -kvm_put_mp_state (s->cpu_env); +/* We have to tell the kernel about mp_state, but also save sregs, since +* apic base was just updated +*/ +kvm_arch_put_registers (s->cpu_env);if (bsp) {/*
Signature · 1 line
1.6.5.2
PATCH 6/7 Don't call kvm cpu reset on initialization
All reset functions are called from the same place, and this was a leftover
--- kvm-all.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
kvm-all.c +0 -2
@@ -204,8 +204,6 @@ int kvm_init_vcpu(CPUState *env) ret =kvm_arch_init_vcpu (env);if (ret ==0 ) {qemu_register_reset (kvm_reset_vcpu, env); -kvm_arch_reset_vcpu (env); - ret =kvm_arch_put_registers (env); } err:return ret;
Signature · 1 line
1.6.5.2
PATCH 7/7 remove smp restriction from kvm
We don't support smp without irqchip in kernel, so only abort in that situation
--- kvm-all.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-)
kvm-all.c +11 -7
@@ -439,16 +439,25 @@ static int kvm_create_irqchip(KVMState *s) {int ret =0 ;#if defined(CONFIG_IOTHREAD ) + ret =-1 ;if (!kvm_check_extension (s,KVM_CAP_IRQCHIP )) -return -1 ; + goto failed; ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP );if (ret <0 ) -return ret; + goto failed; s->irqchip_in_kernel =1 ; +#endif return ret; + +failed: +if (smp_cpus >1 ) { +fprintf (stderr,"No SMP KVM support, use '-smp 1'\n" ); + ret = -EINVAL ; + } +return ret; }int kvm_init (int smp_cpus)
@@ -460,11 +469,6 @@ int kvm_init(int smp_cpus)int ret;int i; -if (smp_cpus >1 ) { -fprintf (stderr,"No SMP KVM support, use '-smp 1'\n" ); -return -EINVAL ; - } - s =qemu_mallocz (sizeof (KVMState));#ifdef KVM_CAP_SET_GUEST_DEBUG
Signature · 1 line
1.6.5.2
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
In reply to Glauber CostaQuoted 14 lines · Glauber Costa
This fix a bug with -smp in kvm. Since we have updated
apic_base, we also have to tell kernel about it. So instead of just updatingmp_state, update every regs.Signed-off-by Glauber Costa<[email protected]>--- hw/apic-kvm.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)hw/apic-kvm.c +0
-0
hw/apic-kvm.c static void kvm_apic_reset(void *opaque) · line 134
Quoted 10 lines
hw/apic-kvm.c +4
-1@@ -126,7 +126,10 @@ static void kvm_apic_reset(void *opaque) s->cpu_env->mp_state = bsp ?KVM_MP_STATE_RUNNABLE :KVM_MP_STATE_UNINITIALIZED ; -kvm_put_mp_state (s->cpu_env); +/* We have to tell the kernel about mp_state, but also save sregs, since +* apic base was just updated +*/ +kvm_arch_put_registers (s->cpu_env);
Better to use cpu_synchronize_state() instead.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
Quoted 9 lines
Quoted 6 lines
since
+ * apic base was just updated
+ */
+ kvm_arch_put_registers(s->cpu_env);Better to use
cpu_synchronize_state()instead.
I might be misreading it, but :
void kvm_cpu_synchronize_state(CPUState *env)
{
if (!env->kvm_state->regs_modified) {
kvm_arch_get_registers(env);
env->kvm_state->regs_modified = 1;
}
}Only does get. And we need put.
Glauber Costa.
"Free as in Freedom"
http://glommer.net
"The less confident you are, the more serious you have to act."
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
Quoted 12 lines · Glauber Costa
Quoted 9 lines
Quoted 6 lines
since
+ * apic base was just updated
+ */
+ kvm_arch_put_registers(s->cpu_env);Better to use
cpu_synchronize_state()instead.I might be misreading it, but :
void
kvm_cpu_synchronize_state(CPUState *env)
Quoted 9 lines
{ if (!env->kvm_state->regs_modified) { kvm_arch_get_registers(env); env->kvm_state->regs_modified = 1; } }Only does get. And we need put.
Put is on the entry into the kernel in vcpu_run.
--
Gleb.
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
In reply to Glauber CostaQuoted 7 lines · Glauber Costa
Quoted 4 lines
Better to use
cpu_synchronize_state()instead.I might be misreading it, but :
void
kvm_cpu_synchronize_state(CPUState *env)
Quoted 9 lines
{ if (!env->kvm_state->regs_modified) { kvm_arch_get_registers(env); env->kvm_state->regs_modified = 1; } }Only does get. And we need put.
It will autoput during the next guest entry.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Glauber Costa
Quoted 4 lines
Better to use
cpu_synchronize_state()instead.I might be misreading it, but :
void
kvm_cpu_synchronize_state(CPUState *env)
{
if (!env->kvm_state->regs_modified) {
kvm_arch_get_registers(env);
env->kvm_state->regs_modified= 1;
}
}
Quoted 4 lines
Quoted 2 lines
Only does get. And we need put.
It will autoput during the next guest entry.
So it should be working already, no?
We do a cpu_synchronize_state() on the beginning of that function, and vcpu does not run
until it is finished.
Quoted 5 lines
--
error compilingcommittee.c: too many arguments to function
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [Qemu-devel] [PATCH 5/7] tell kernel about all registers instead of just mp_state
Quoted 11 lines · Glauber Costa
Quoted 6 lines
Quoted 4 lines
Only does get. And we need put.
It will autoput during the next guest entry.
So it should be working already, no?
We do a
cpu_synchronize_state()on the beginning of that function, and vcpu does not run
until it is finished
Yes.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 4/7] qemu_flush_work for remote vcpu execution
In reply to Glauber CostaQuoted 11 lines · Glauber Costa
This function is similar to qemu-kvm's
on_vcpumechanism. Totally synchronous, and guarantees that a given function will be executed at the specified vcpu.The approach I am taking is to put it under the hood, in
kvm_vcpu_ioctl. This way, thekvm_vcpu_ioctlcan be used anywhere, and we guarantee it will never be executed outside its realm.This is not much of a problem, since remote execution is rare. It does happen at lot at machine bootup, because saving/restoring registers spans a lot of ioctls, but this should get better if we move to Jan's patch of doing it all at once.
I really dislike this. In general vcpu ioctls are used as components of some work to be done, for example RMW of some state. In this case it is meaningless to execute the ioctls remotely, you need to execute the entire RMW remotely instead.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 4/7] qemu_flush_work for remote vcpu execution
Quoted 6 lines
I really dislike this. In general vcpu ioctls are used as components of some work to be done, for example RMW of some state. In this case it is meaningless to execute the ioctls remotely, you need to execute the entire RMW remotely instead.
Why? The "M" part of RMW is executed in shared memory. Only the R and W parts have any restrictions on where to be executed.
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [Qemu-devel] [PATCH 4/7] qemu_flush_work for remote vcpu execution
Quoted 10 lines · Glauber Costa
Quoted 6 lines
I really dislike this. In general vcpu ioctls are used as components of some work to be done, for example RMW of some state. In this case it is meaningless to execute the ioctls remotely, you need to execute the entire RMW remotely instead.
Why? The "M" part of RMW is executed in shared memory. Only the R and W parts have any restrictions on where to be executed.
If the guest continues to run during the RMW, you will get inconsistent results.
This may be prevented by qemu_mutex, but I'd rather not rely on it.
Also, I'd like remote operations to be visible.
Signature · 1 line
error compiling committee.c: too many arguments to function
[Qemu-devel] Re: [PATCH 4/7] qemu_flush_work for remote vcpu execution
In reply to Glauber CostaQuoted 1 line · Glauber Costa
+CPUState
*qemu_get_current_env(void);
Useless forward reference (to a function that doesn't exist in that file at all).
Paolo
Re: [Qemu-devel] [PATCH 2/7] store thread-specific env information
In reply to Glauber CostaQuoted 8 lines · Glauber Costa
Since we'll have multiple cpu threads, at least for kvm, we need a way to store and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.
I am using pthread functions for that, for portability, but we could as well use
__threadkeyword.
Where is __thread not supported?
It's likely a bit faster than pthread_getspecific().
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 2/7] store thread-specific env information
Am 29.11.2009 um 16:29 schrieb Avi Kivity:
Quoted 11 lines · Glauber Costa
Quoted 8 lines
Since we'll have multiple cpu threads, at least for kvm, we need a way to store and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.
I am using pthread functions for that, for portability, but we could as well use
__threadkeyword.Where is
__threadnot supported?
Apple, Sun.
Andreas
Re: [Qemu-devel] [PATCH 2/7] store thread-specific env information
Quoted 8 lines · Andreas Färber
Am 29.11.2009 um 16:29 schrieb Avi Kivity:
Quoted 5 lines · Glauber Costa
Quoted 4 lines
Since we'll have multiple cpu threads, at least for kvm, we need a way to store and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I am using pthread functions for that, for portability, but we could as well use
__threadkeyword.Where is
__threadnot supported?Apple, Sun.
Well, pthread_getspecific is around 130 bytes of code, whereas __thread is just on instruction. Maybe we should support both.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 2/7] store thread-specific env information
Am 29.11.2009 um 16:42 schrieb Avi Kivity:
Quoted 14 lines · Andreas Färber
Quoted 13 lines
Am 29.11.2009 um 16:29 schrieb Avi Kivity:
Quoted 10 lines · Glauber Costa
Quoted 8 lines
Since we'll have multiple cpu threads, at least for kvm, we need a way to store and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.
I am using pthread functions for that, for portability, but we could as well use
__threadkeyword.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Where is
__threadnot supported?Apple, Sun.
Well,
pthread_getspecificis around 130 bytes of code, whereas__threadis just on instruction. Maybe we should support both.
Maybe. Mono does so, they have some autoconf-based check plus a configure switch --with-tls={pthread|__thread} to override.
Andreas
Re: [Qemu-devel] [PATCH 2/7] store thread-specific env information
In reply to Avi KivityQuoted 4 lines · Andreas Färber
Quoted 3 lines
Am 29.11.2009 um 16:29 schrieb Avi Kivity:
Quoted 1 line
Where is
__threadnot supported?Apple, Sun.
Some flavours of uClinux :-)
Quoted 2 lines · Avi Kivity
Well,
pthread_getspecificis around 130 bytes of code, whereas__threadis just on instruction. Maybe we should support both.
It's easy enough, they are quite similar. Except that pthread_key_create lets you provide a destructor which is called as each thread is destroyed (unfortunately no constructor for new threads; and you can use both methods if you need a destructor and speed together).
It's not always one instruction - it's more complicated in shared libraries, but it's always close to that.
Anyway, I decided to measure them both as I wondered about this for another program.
On my 2.0GHz Core Duo (32-bit), tight unrolled loop, everything in cache:
Read void *__thread variable ~ 0.6 ns
Call pthread_getspecific(key) ~ 8.8 ns
__thread is preferable but it's not much overhead to call pthread_getspecific().
Imho, it's not worth making code less portable or more complicated to handle both, but it's a nice touch.
However, I did notice that the compiler optimises away references to __thread variables much better, such as hoisting from inside loops.
In my programs I have taken to wrapping everything inside a thread_specific(var) macro, similar to the one in the kernel, which expands to call pthread_getspecific() or use __thread[*], That keeps the complexity in one place, which is where the macro is defined.
( [*] - Windows has __thread, but it sometimes crashes when used in a DLL, so I use the Windows equivalent of pthread_getspecific() in the same wrapper macro, which is fine. )
-- Jamie
[Qemu-devel] Re: [PATCH 2/7] store thread-specific env information
In reply to Andreas FärberQuoted 15 lines · Andreas Färber
Am 29.11.2009 um 16:29 schrieb Avi Kivity:
Quoted 12 lines · Glauber Costa
Quoted 10 lines
Since we'll have multiple cpu threads, at least for kvm, we need a way to store
and retrieve the CPUState associated with the current execution thread. For the I/O thread, this will be NULL.I am using pthread functions for that, for portability, but we could as well
use__threadkeyword.
Quoted 3 lines
Quoted 1 line
Where is
__threadnot supported?Apple, Sun.
Not sure about Sun.
Anyway on Windows neither __thread nor pthread_getspecific is supported, so some configury is needed anyway.
Paolo
Re: [Qemu-devel] Re: [PATCH 2/7] store thread-specific env information
Quoted 4 lines
Anyway on Windows neither
__threadnorpthread_getspecificis supported, so some configury is needed anyway.Paolo
For the record, I am a big fan of __thread. The only reason I used the pthread library was
portability. I can surely put in some configure knobs to use __thread where available
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Re: [Qemu-devel] Re: [PATCH 2/7] store thread-specific env information
Quoted 3 lines · Glauber Costa
For the record, I am a big fan of
__thread. The only reason I used the pthread library was portability. I can surely put in some configure knobs to use__threadwhere available
Plus, do you really need to support SMP when __thread is not available?...
Paolo
Re: [Qemu-devel] Re: [PATCH 2/7] store thread-specific env information
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Glauber Costa
For the record, I am a big fan of
__thread. The only reason I used the pthread library was portability. I can surely put in some configure knobs to use__threadwhere availablePlus, do you really need to support SMP when
__threadis not available?...
Good point.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 7 lines · Glauber Costa
Hi guys,
This is an early version of smp support in kvm that kinda works. It has some known problems that I am still tracking. For example, it does not reset very well. Also, initialization is a bit slow, probably because of the number of remote ioctl calls involved. But I believe Jan's patch to do a single ioctl can make it better.
That approach has been buried, we decided to continue extending via new ioctls.
But why do you need that many remote calls during init? Aren't the initial ioctls issued by the vcpu threads themselves?
Jan
Quoted 9 lines · Jan Kiszka
Quoted 7 lines · Glauber Costa
Hi guys,
This is an early version of smp support in kvm that kinda works. It has some known problems that I am still tracking. For example, it does not reset very well. Also, initialization is a bit slow, probably because of the number of remote ioctl calls involved. But I believe Jan's patch to do a single ioctl can make it better.
Quoted 5 lines
That approach has been buried, we decided to continue extending via new ioctls.
But why do you need that many remote calls during init? Aren't the initial ioctls issued by the vcpu threads themselves?
Yes, but system_reset is called from the io-thread, and it fires a lot of ioctls.
However, I have an already working version that does a much better job than that.
Will post today with details
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Quoted 11 lines
Quoted 2 lines
But why do you need that many remote calls during init? Aren't the initial ioctls issued by the vcpu threads themselves?
Yes, but
system_resetis called from the io-thread, and it fires a lot of ioctls.However, I have an already working version that does a much better job than that.
Will post today with details
Btw, The approach I've taken (code to follow), was to register reset functions that
issues ioctls in a separate handler, that later calls all of them already in the vcpu-thread.
So, no code movement, and thus, no races.
reset code is responsible for most remote calls in qemu. One of the only ones we still
have left is the gdb stuff. Do you have any suggestion to do that without the currenton_vcpu mechanism?
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Quoted 7 lines · Glauber Costa
reset code is responsible for most remote calls in qemu. One of the only ones we still
have left is the gdb stuff. Do you have any suggestion to do that without the currenton_vcpumechanism?
No. But what's wrong with on_vcpu?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 10 lines · Avi Kivity
Quoted 7 lines · Glauber Costa
reset code is responsible for most remote calls in qemu. One of the only ones we still
have left is the gdb stuff. Do you have any suggestion to do that without the currenton_vcpumechanism?No. But what's wrong with
on_vcpu?
intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like the vcpu_reset() I've just posted)
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Quoted 8 lines · Glauber Costa
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Glauber Costa
reset code is responsible for most remote calls in qemu. One of the only ones we still
have left is the gdb stuff. Do you have any suggestion to do that without the currenton_vcpumechanism?
Quoted 9 lines
Quoted 1 line
No. But what's wrong with
on_vcpu?intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with
on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like thevcpu_reset()I've just posted)
If you don't want immediate execution of update_guest_debug, save the state that shall be transferred, set some flag, and run the transfer before guest entry inside the vcpu threads (after putting the registers as older kernels may otherwise overwrite the flags register). Should work, may even avoid redundant calls during a gdb session.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 11 lines · Jan Kiszka
Quoted 11 lines
Quoted 3 lines
No. But what's wrong with
on_vcpu?intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with
on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like thevcpu_reset()I've just posted)
Quoted 6 lines
If you don't want immediate execution of
update_guest_debug, save the state that shall be transferred, set some flag, and run the transfer before guest entry inside the vcpu threads (after putting the registers as older kernels may otherwise overwrite the flags register). Should work, may even avoid redundant calls during a gdb session.
There's no guarantee the vcpu will ever exit to qemu, so you have to signal the vcpu thread anyway. When you do that, you might as well load the new state.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 18 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
Quoted 10 lines
Quoted 2 lines
No. But what's wrong with
on_vcpu?intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with
on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like thevcpu_reset()I've just posted)Quoted 6 lines
If you don't want immediate execution of
update_guest_debug, save the state that shall be transferred, set some flag, and run the transfer before guest entry inside the vcpu threads (after putting the registers as older kernels may otherwise overwrite the flags register). Should work, may even avoid redundant calls during a gdb session.
Quoted 3 lines
There's no guarantee the vcpu will ever exit to qemu, so you have to signal the vcpu thread anyway. When you do that, you might as well load the new state.
Debugging is special here as it involves vmstop before you start playing with the debug settings. But I may also oversee some corner case right now.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Avi Kivity
Quoted 16 lines · Jan Kiszka
Quoted 10 lines
Quoted 2 lines
No. But what's wrong with
on_vcpu?intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with
on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like thevcpu_reset()I've just posted)If you don't want immediate execution of
update_guest_debug, save the state that shall be transferred, set some flag, and run the transfer before guest entry inside the vcpu threads (after putting the registers as older kernels may otherwise overwrite the flags register). Should work, may even avoid redundant calls during a gdb session.
Quoted 7 lines
Quoted 3 lines
There's no guarantee the vcpu will ever exit to qemu, so you have to signal the vcpu thread anyway. When you do that, you might as well load the new state.
Debugging is special here as it involves vmstop before you start playing with the debug settings. But I may also oversee some corner case right now.
I imagined so. In this case, it might be better to set a flag before vmstop, and then
honor it on vcpu entry. I had this feeling that in most cases where we current signal the
vcpu, the VM will be already stopped anyway, so we don't need to resignal.
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Quoted 26 lines · Glauber Costa
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Avi Kivity
Quoted 16 lines · Jan Kiszka
Quoted 10 lines
Quoted 2 lines
No. But what's wrong with
on_vcpu?intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with
on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like thevcpu_reset()I've just posted)If you don't want immediate execution of
update_guest_debug, save the state that shall be transferred, set some flag, and run the transfer before guest entry inside the vcpu threads (after putting the registers as older kernels may otherwise overwrite the flags register). Should work, may even avoid redundant calls during a gdb session.Quoted 6 lines
Quoted 3 lines
There's no guarantee the vcpu will ever exit to qemu, so you have to signal the vcpu thread anyway. When you do that, you might as well load the new state.
Debugging is special here as it involves vmstop before you start playing with the debug settings. But I may also oversee some corner case right now.
Quoted 6 lines
I imagined so. In this case, it might be better to set a flag before vmstop, and then
honor it on vcpu entry. I had this feeling that in most cases where we current signal the
vcpu, the VM will be already stopped anyway, so we don't need to resignal.
Do not set the flag before the machine stop, otherwise you risk to race with vcpus that exit and re-enter briefly before that. This manipulation should really be done under vmstop protection.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 10 lines · Avi Kivity
Quoted 7 lines · Glauber Costa
reset code is responsible for most remote calls in qemu. One of the only ones we still
have left is the gdb stuff. Do you have any suggestion to do that without the currenton_vcpumechanism?No. But what's wrong with
on_vcpu?
intrinsically racy. signal passing slow down things, etc.
That said, as I've stated many times: I don't believe there's anything fundamentally wrong with on_vcpu. But we might get benefits from a re-design of things to avoid it whenever possible. (just like the vcpu_reset() I've just posted)
Signature · 5 lines
Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."
Quoted 1 line · Glauber Costa
This is an early version of smp support in kvm that kinda works.
Can you please elaborate on "smp support"? The KVM FAQ makes some rather broad claims about smp support already:
Does KVM support SMP hosts?
Yes.
Does KVM support SMP guests?
Yes. Up to 16 CPUs can be specified using the -smp option.
Thanks,
--Ed
Quoted 5 lines · Ed Swierk
Quoted 1 line · Glauber Costa
This is an early version of smp support in kvm that kinda works.
Can you please elaborate on "smp support"? The KVM FAQ makes some rather broad claims about smp support already:
I see now that you're integrating smp support into qemu proper from the kvm fork of qemu. Sorry for the noise.
--Ed
Quoted 8 lines · Glauber Costa
Hi guys,
This is an early version of smp support in kvm that kinda works. It has some known problems that I am still tracking. For example, it does not reset very well. Also, initialization is a bit slow, probably because of the number of remote ioctl calls involved. But I believe Jan's patch to do a single ioctl can make it better.
Quoted 4 lines
Normal operation seem to be going smooth for me. I can boot the machine and get it going decently. I'll keep working on the issues, but comments are welcome in the mean time.
Can you shut down with that series? I'm trying to get SMP working with S390X and it looks pretty good, apart from the VCPU threads having cpu_single_env == NULL on SIGUSR1, which makes them not get out of their guest context.
Alex