public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: hyperv_tlb_flush: replace NOP loop with udelay()
@ 2026-04-21 17:29 Piotr Zarycki
  2026-04-21 20:10 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Piotr Zarycki @ 2026-04-21 17:29 UTC (permalink / raw)
  To: kvm
  Cc: seanjc, pbonzini, shuah, vkuznets, linux-kselftest, linux-kernel,
	kernel-janitors, Piotr Zarycki

Replace the open-coded NOP loop with udelay() which was added to KVM
selftests in commit 6b878cbb87bf ("KVM: selftests: Add guest udelay()
utility for x86"). The NOP loop is CPU speed dependent while udelay()
provides a deterministic delay regardless of host CPU frequency.

Signed-off-by: Piotr Zarycki <piotr.zarycki@gmail.com>
---
 tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c b/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
index c542cc4762b1..68ebd790ff41 100644
--- a/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
+++ b/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
@@ -141,15 +141,9 @@ static void swap_two_test_pages(vm_paddr_t pte_gva1, vm_paddr_t pte_gva2)
 	*(uint64_t *)pte_gva2 = tmp;
 }
 
-/*
- * TODO: replace the silly NOP loop with a proper udelay() implementation.
- */
 static inline void do_delay(void)
 {
-	int i;
-
-	for (i = 0; i < 1000000; i++)
-		asm volatile("nop");
+	udelay(100);
 }
 
 /*
-- 
2.53.0


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

* Re: [PATCH] KVM: selftests: hyperv_tlb_flush: replace NOP loop with udelay()
  2026-04-21 17:29 [PATCH] KVM: selftests: hyperv_tlb_flush: replace NOP loop with udelay() Piotr Zarycki
@ 2026-04-21 20:10 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-04-21 20:10 UTC (permalink / raw)
  To: Piotr Zarycki
  Cc: kvm, seanjc, pbonzini, shuah, vkuznets, linux-kselftest,
	linux-kernel, kernel-janitors

On Tue, Apr 21, 2026 at 07:29:53PM +0200, Piotr Zarycki wrote:
> Replace the open-coded NOP loop with udelay() which was added to KVM
> selftests in commit 6b878cbb87bf ("KVM: selftests: Add guest udelay()
> utility for x86"). The NOP loop is CPU speed dependent while udelay()
> provides a deterministic delay regardless of host CPU frequency.
> 
> Signed-off-by: Piotr Zarycki <piotr.zarycki@gmail.com>
> ---

How did you test this?

regards,
dan carpenter


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

end of thread, other threads:[~2026-04-21 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-21 17:29 [PATCH] KVM: selftests: hyperv_tlb_flush: replace NOP loop with udelay() Piotr Zarycki
2026-04-21 20:10 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox