kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost
@ 2019-10-03 15:24 Paolo Bonzini
  2019-10-03 20:57 ` Konrad Rzeszutek Wilk
  2019-10-08  3:32 ` Wanpeng Li
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-10-03 15:24 UTC (permalink / raw)
  To: kvm

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/vmexit.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/x86/vmexit.c b/x86/vmexit.c
index 66d3458..81b743b 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -65,22 +65,30 @@ static void nop(void *junk)
 }
 
 volatile int x = 0;
+volatile uint64_t tsc_eoi = 0;
+volatile uint64_t tsc_ipi = 0;
 
 static void self_ipi_isr(isr_regs_t *regs)
 {
 	x++;
+	uint64_t start = rdtsc();
 	eoi();
+	tsc_eoi += rdtsc() - start;
 }
 
 static void x2apic_self_ipi(int vec)
 {
+	uint64_t start = rdtsc();
 	wrmsr(0x83f, vec);
+	tsc_ipi += rdtsc() - start;
 }
 
 static void apic_self_ipi(int vec)
 {
+	uint64_t start = rdtsc();
         apic_icr_write(APIC_INT_ASSERT | APIC_DEST_SELF | APIC_DEST_PHYSICAL |
 		       APIC_DM_FIXED | IPI_TEST_VECTOR, vec);
+	tsc_ipi += rdtsc() - start;
 }
 
 static void self_ipi_sti_nop(void)
@@ -180,7 +188,9 @@ static void x2apic_self_ipi_tpr_sti_hlt(void)
 
 static void ipi(void)
 {
+	uint64_t start = rdtsc();
 	on_cpu(1, nop, 0);
+	tsc_ipi += rdtsc() - start;
 }
 
 static void ipi_halt(void)
@@ -511,6 +521,7 @@ static bool do_test(struct test *test)
 	}
 
 	do {
+		tsc_eoi = tsc_ipi = 0;
 		iterations *= 2;
 		t1 = rdtsc();
 
@@ -523,6 +534,11 @@ static bool do_test(struct test *test)
 		t2 = rdtsc();
 	} while ((t2 - t1) < GOAL);
 	printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
+	if (tsc_ipi)
+		printf("  ipi %s %d\n", test->name, (int)(tsc_ipi / iterations));
+	if (tsc_eoi)
+		printf("  eoi %s %d\n", test->name, (int)(tsc_eoi / iterations));
+
 	return test->next;
 }
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost
  2019-10-03 15:24 [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost Paolo Bonzini
@ 2019-10-03 20:57 ` Konrad Rzeszutek Wilk
  2019-10-08  3:32 ` Wanpeng Li
  1 sibling, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2019-10-03 20:57 UTC (permalink / raw)
  To: Paolo Bonzini, kvm

On 10/3/19 8:24 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost
  2019-10-03 15:24 [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost Paolo Bonzini
  2019-10-03 20:57 ` Konrad Rzeszutek Wilk
@ 2019-10-08  3:32 ` Wanpeng Li
  2019-10-08 12:10   ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Wanpeng Li @ 2019-10-08  3:32 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

On Fri, 4 Oct 2019 at 00:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  x86/vmexit.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/x86/vmexit.c b/x86/vmexit.c
> index 66d3458..81b743b 100644
> --- a/x86/vmexit.c
> +++ b/x86/vmexit.c
> @@ -65,22 +65,30 @@ static void nop(void *junk)
>  }
>
>  volatile int x = 0;
> +volatile uint64_t tsc_eoi = 0;
> +volatile uint64_t tsc_ipi = 0;
>
>  static void self_ipi_isr(isr_regs_t *regs)
>  {
>         x++;
> +       uint64_t start = rdtsc();
>         eoi();
> +       tsc_eoi += rdtsc() - start;
>  }
>
>  static void x2apic_self_ipi(int vec)
>  {
> +       uint64_t start = rdtsc();
>         wrmsr(0x83f, vec);
> +       tsc_ipi += rdtsc() - start;
>  }
>
>  static void apic_self_ipi(int vec)
>  {
> +       uint64_t start = rdtsc();
>          apic_icr_write(APIC_INT_ASSERT | APIC_DEST_SELF | APIC_DEST_PHYSICAL |
>                        APIC_DM_FIXED | IPI_TEST_VECTOR, vec);
> +       tsc_ipi += rdtsc() - start;
>  }
>
>  static void self_ipi_sti_nop(void)
> @@ -180,7 +188,9 @@ static void x2apic_self_ipi_tpr_sti_hlt(void)
>
>  static void ipi(void)
>  {
> +       uint64_t start = rdtsc();
>         on_cpu(1, nop, 0);
> +       tsc_ipi += rdtsc() - start;
>  }
>
>  static void ipi_halt(void)
> @@ -511,6 +521,7 @@ static bool do_test(struct test *test)
>         }
>
>         do {
> +               tsc_eoi = tsc_ipi = 0;
>                 iterations *= 2;
>                 t1 = rdtsc();
>
> @@ -523,6 +534,11 @@ static bool do_test(struct test *test)
>                 t2 = rdtsc();
>         } while ((t2 - t1) < GOAL);
>         printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
> +       if (tsc_ipi)
> +               printf("  ipi %s %d\n", test->name, (int)(tsc_ipi / iterations));
> +       if (tsc_eoi)
> +               printf("  eoi %s %d\n", test->name, (int)(tsc_eoi / iterations));
> +
>         return test->next;
>  }

Thanks for this, do you have more idea to optimize the virtual ipi latency?

    Wanpeng

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost
  2019-10-08  3:32 ` Wanpeng Li
@ 2019-10-08 12:10   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2019-10-08 12:10 UTC (permalink / raw)
  To: Wanpeng Li; +Cc: kvm

On 08/10/19 05:32, Wanpeng Li wrote:
> On Fri, 4 Oct 2019 at 00:00, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  x86/vmexit.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/x86/vmexit.c b/x86/vmexit.c
>> index 66d3458..81b743b 100644
>> --- a/x86/vmexit.c
>> +++ b/x86/vmexit.c
>> @@ -65,22 +65,30 @@ static void nop(void *junk)
>>  }
>>
>>  volatile int x = 0;
>> +volatile uint64_t tsc_eoi = 0;
>> +volatile uint64_t tsc_ipi = 0;
>>
>>  static void self_ipi_isr(isr_regs_t *regs)
>>  {
>>         x++;
>> +       uint64_t start = rdtsc();
>>         eoi();
>> +       tsc_eoi += rdtsc() - start;
>>  }
>>
>>  static void x2apic_self_ipi(int vec)
>>  {
>> +       uint64_t start = rdtsc();
>>         wrmsr(0x83f, vec);
>> +       tsc_ipi += rdtsc() - start;
>>  }
>>
>>  static void apic_self_ipi(int vec)
>>  {
>> +       uint64_t start = rdtsc();
>>          apic_icr_write(APIC_INT_ASSERT | APIC_DEST_SELF | APIC_DEST_PHYSICAL |
>>                        APIC_DM_FIXED | IPI_TEST_VECTOR, vec);
>> +       tsc_ipi += rdtsc() - start;
>>  }
>>
>>  static void self_ipi_sti_nop(void)
>> @@ -180,7 +188,9 @@ static void x2apic_self_ipi_tpr_sti_hlt(void)
>>
>>  static void ipi(void)
>>  {
>> +       uint64_t start = rdtsc();
>>         on_cpu(1, nop, 0);
>> +       tsc_ipi += rdtsc() - start;
>>  }
>>
>>  static void ipi_halt(void)
>> @@ -511,6 +521,7 @@ static bool do_test(struct test *test)
>>         }
>>
>>         do {
>> +               tsc_eoi = tsc_ipi = 0;
>>                 iterations *= 2;
>>                 t1 = rdtsc();
>>
>> @@ -523,6 +534,11 @@ static bool do_test(struct test *test)
>>                 t2 = rdtsc();
>>         } while ((t2 - t1) < GOAL);
>>         printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
>> +       if (tsc_ipi)
>> +               printf("  ipi %s %d\n", test->name, (int)(tsc_ipi / iterations));
>> +       if (tsc_eoi)
>> +               printf("  eoi %s %d\n", test->name, (int)(tsc_eoi / iterations));
>> +
>>         return test->next;
>>  }
> 
> Thanks for this, do you have more idea to optimize the virtual ipi latency?

I haven't thought about it recently; this was a patch I had written
years ago and I randomly found on my computer. :)

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-08 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 15:24 [PATCH kvm-unit-tests] vmexit: measure IPI and EOI cost Paolo Bonzini
2019-10-03 20:57 ` Konrad Rzeszutek Wilk
2019-10-08  3:32 ` Wanpeng Li
2019-10-08 12:10   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).