Skip to contentSkip to conversation

RFC: Create kvm_arch_vcpu_runnable() function

PATCH Applied Hollis Blanchard 3 participants 6 messages Dec 3, 2007 – Dec 5, 2007 3 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: Create kvm_arch_vcpu_runnable() function

---
vcpu->mp_state looks like an arch-specific field, so what do we think about this patch? It might make sense to fold the kvm_cpu_has_interrupt() test inside kvm_arch_vcpu_runnable() as well.

2 files changed, 9 insertions(+), 3 deletions(-)
drivers/kvm/kvm_main.c |    3 +--
drivers/kvm/x86.h      |    9 ++++++++-
drivers/kvm/kvm_main.c +1 -2
@@ -643,8 +643,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcp
 	 */
 	while (!kvm_cpu_has_interrupt(vcpu)
 	       && !signal_pending(current)
-	       && vcpu->mp_state != VCPU_MP_STATE_RUNNABLE
-	       && vcpu->mp_state != VCPU_MP_STATE_SIPI_RECEIVED) {
+	       && !kvm_arch_vcpu_runnable(vcpu)) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		vcpu_put(vcpu);
 		schedule();
drivers/kvm/x86.h +8 -1
@@ -471,4 +471,11 @@ static inline u32 get_rdx_init_val(void)
 #define TSS_IOPB_SIZE (65536 / 8)
 #define TSS_REDIRECTION_SIZE (256 / 8)
 #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
-#endif
+
+static inline int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
+{
+	return vcpu->mp_state == VCPU_MP_STATE_RUNNABLE
+	       || vcpu->mp_state == VCPU_MP_STATE_SIPI_RECEIVED;
+}
+
+#endif

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Hollis Blanchard

We'll need this too on big iron.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

#3 lore raw
In reply to a message not in the archive
Quoted 5 lines · Carsten Otte
Quoted 1 line · Hollis Blanchard

We'll need this too on big iron.

What about merging kvm_cpu_has_interrupt() into _runnable()?

My feeling is that we can keep it separated.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
#5 lore raw
In reply to a message not in the archive
Quoted 3 lines · Avi Kivity

What about merging kvm_cpu_has_interrupt() into _runnable()?

My feeling is that we can keep it separated.

On s390 there is a difference between has_interrupt and not runnable:
CPUs can be in stopped state, and they can be in enabled wait (enabled for interrupts, similar to hlt state on x86) or in disabled wait state. All those states indicate that the CPU is not runnable. Interrupts on the other hand are typically floating between all virtual CPUs and can be accepted by running CPUs only (that is either running, or in enabled wait).

I agree that we should keep it seperated.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

#7 lore raw
In reply to a message not in the archive
Quoted 14 lines · Carsten Otte
Quoted 4 lines · Avi Kivity

What about merging kvm_cpu_has_interrupt() into _runnable()?

My feeling is that we can keep it separated.

On s390 there is a difference between has_interrupt and not runnable:
CPUs can be in stopped state, and they can be in enabled wait (enabled for interrupts, similar to hlt state on x86) or in disabled wait state. All those states indicate that the CPU is not runnable. Interrupts on the other hand are typically floating between all virtual CPUs and can be accepted by running CPUs only (that is either running, or in enabled wait).

Quoted 2 lines

I agree that we should keep it seperated.

On x86, running hlt with interrupts disabled is similar to your disabled wait. Interrupts in general are directed towards a specific cpu, though older processors supported round-robin or priority based dispatching. With extensive caches this is a performance loss, so the feature is not missed.

Thanks for the clarification.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Applied
#8 lore raw
In reply to Hollis Blanchard
Quoted 2 lines · Hollis Blanchard

Applied, thanks. Note that there is free advertising space between the summary and the signoff that you can use to explain the change.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4