Re: [PATCH] KVM: selftests: hyperv_tlb_flush: use swap() to swap PTEs

From: Sean Christopherson

Date: Thu May 28 2026 - 09:13:27 EST


On Thu, May 28, 2026, Piotr Zarycki wrote:
> Replace the open-coded swap with the swap() macro.
>
> Signed-off-by: Piotr Zarycki <piotr.zarycki@xxxxxxxxx>
> ---
> tools/testing/selftests/kvm/include/test_util.h | 2 ++
> tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c | 6 +-----
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
> index d9b433b834f1..a66bc9ccba65 100644
> --- a/tools/testing/selftests/kvm/include/test_util.h
> +++ b/tools/testing/selftests/kvm/include/test_util.h
> @@ -26,6 +26,8 @@
>
> #define msecs_to_usecs(msec) ((msec) * 1000ULL)
>
> +#define swap(a, b) do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)

This belongs in a common tools/ header, not in KVM's test_util.h. I don't see
an obvious place, maybe tools/include/linux/kernel.h?