diff mbox

[QEMU-KVM,6/7] test: Add ipi_halt benchmark

Message ID 1253523338-22784-7-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Sept. 21, 2009, 8:55 a.m. UTC
Wait for 2000 cycles after the IPI to allow the host to schedule out.
Measures wake-from-idle overhead.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 kvm/user/test/x86/vmexit.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Comments

Marcelo Tosatti Sept. 22, 2009, 1:54 a.m. UTC | #1
On Mon, Sep 21, 2009 at 11:55:37AM +0300, Avi Kivity wrote:
> Wait for 2000 cycles after the IPI to allow the host to schedule out.
> Measures wake-from-idle overhead.
> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  kvm/user/test/x86/vmexit.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
> index 29bb32a..5088dc9 100644
> --- a/kvm/user/test/x86/vmexit.c
> +++ b/kvm/user/test/x86/vmexit.c
> @@ -66,6 +66,16 @@ static void ipi(void)
>  	on_cpu(1, nop, 0);
>  }
>  
> +static void ipi_halt(void)
> +{
> +	unsigned long long t;
> +
> +	on_cpu(1, nop, 0);
> +	t = rdtsc() + 2000;
> +	while (rdtsc() < t)
> +		;

I don't get the 2000 cycle thing. Since vcpu1 is on hlt by default, just
IPI'ing it to do nop() already includes wake-from-idle overhead?

Other than this the remaining is very nice, please apply.

> +}
> +
>  static struct test {
>  	void (*func)(void);
>  	const char *name;
> @@ -76,6 +86,7 @@ static struct test {
>  	{ mov_from_cr8, "mov_from_cr8" },
>  	{ mov_to_cr8, "mov_to_cr8" },
>  	{ ipi, "ipi", is_smp },
> +	{ ipi_halt, "ipi+halt", is_smp },
>  };
>  
>  static void do_test(struct test *test)
> -- 
> 1.6.4.1
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Sept. 22, 2009, 6:12 a.m. UTC | #2
On 09/22/2009 04:54 AM, Marcelo Tosatti wrote:
> On Mon, Sep 21, 2009 at 11:55:37AM +0300, Avi Kivity wrote:
>    
>> Wait for 2000 cycles after the IPI to allow the host to schedule out.
>> Measures wake-from-idle overhead.
>>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>> ---
>>   kvm/user/test/x86/vmexit.c |   11 +++++++++++
>>   1 files changed, 11 insertions(+), 0 deletions(-)
>>
>> diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
>> index 29bb32a..5088dc9 100644
>> --- a/kvm/user/test/x86/vmexit.c
>> +++ b/kvm/user/test/x86/vmexit.c
>> @@ -66,6 +66,16 @@ static void ipi(void)
>>   	on_cpu(1, nop, 0);
>>   }
>>
>> +static void ipi_halt(void)
>> +{
>> +	unsigned long long t;
>> +
>> +	on_cpu(1, nop, 0);
>> +	t = rdtsc() + 2000;
>> +	while (rdtsc()<  t)
>> +		;
>>      
> I don't get the 2000 cycle thing. Since vcpu1 is on hlt by default, just
> IPI'ing it to do nop() already includes wake-from-idle overhead?
>    

Without the delay, by the time vcpu1 gets to schedule() it will already 
have been woken up by vcpu0.  So it never switches to the idle thread.

The purpose of this test was to measure the just-in-time MSR switching, 
and that only helps if a context switch takes place.
diff mbox

Patch

diff --git a/kvm/user/test/x86/vmexit.c b/kvm/user/test/x86/vmexit.c
index 29bb32a..5088dc9 100644
--- a/kvm/user/test/x86/vmexit.c
+++ b/kvm/user/test/x86/vmexit.c
@@ -66,6 +66,16 @@  static void ipi(void)
 	on_cpu(1, nop, 0);
 }
 
+static void ipi_halt(void)
+{
+	unsigned long long t;
+
+	on_cpu(1, nop, 0);
+	t = rdtsc() + 2000;
+	while (rdtsc() < t)
+		;
+}
+
 static struct test {
 	void (*func)(void);
 	const char *name;
@@ -76,6 +86,7 @@  static struct test {
 	{ mov_from_cr8, "mov_from_cr8" },
 	{ mov_to_cr8, "mov_to_cr8" },
 	{ ipi, "ipi", is_smp },
+	{ ipi_halt, "ipi+halt", is_smp },
 };
 
 static void do_test(struct test *test)