From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Piotr Zarycki <piotr.zarycki@gmail.com>
Cc: kvm@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com,
shuah@kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Piotr Zarycki <piotr.zarycki@gmail.com>
Subject: Re: [PATCH v2] KVM: selftests: hyperv_tlb_flush: replace NOP loop with udelay()
Date: Thu, 23 Apr 2026 09:50:16 +0200 [thread overview]
Message-ID: <87se8mglon.fsf@redhat.com> (raw)
In-Reply-To: <20260422130307.1171808-1-piotr.zarycki@gmail.com>
Piotr Zarycki <piotr.zarycki@gmail.com> writes:
> 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>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Thanks!
> ---
> .../testing/selftests/kvm/x86/hyperv_tlb_flush.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 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..4b7f089542c1 100644
> --- a/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
> +++ b/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
> @@ -141,17 +141,6 @@ 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");
> -}
> -
> /*
> * Prepare to test: 'disable' workers by setting the expectation to '0',
> * clear hypercall input page and then swap two test pages.
> @@ -169,7 +158,7 @@ static inline void prepare_to_test(struct test_data *data)
> wmb();
>
> /* Make sure workers have enough time to notice */
> - do_delay();
> + udelay(100);
>
> /* Swap test page mappings */
> swap_two_test_pages(data->test_pages_pte[0], data->test_pages_pte[1]);
> @@ -189,7 +178,7 @@ static inline void post_test(struct test_data *data, u64 exp1, u64 exp2)
> set_expected_val((void *)data->test_pages, exp2, WORKER_VCPU_ID_2);
>
> /* Make sure workers have enough time to test */
> - do_delay();
> + udelay(100);
> }
>
> #define TESTVAL1 0x0101010101010101
--
Vitaly
prev parent reply other threads:[~2026-04-23 7:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-04-22 9:13 ` Piotr Zarycki
2026-04-22 12:36 ` Vitaly Kuznetsov
2026-04-22 13:03 ` [PATCH v2] " Piotr Zarycki
2026-04-23 7:50 ` Vitaly Kuznetsov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87se8mglon.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=piotr.zarycki@gmail.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.