Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
	 Mathias Krause <minipli@grsecurity.net>,
	Andrew Jones <andrew.jones@linux.dev>
Subject: [kvm-unit-tests PATCH v3 14/20] x86/kvmclock: Replace spaces with tabs
Date: Thu, 14 May 2026 14:04:54 -0700	[thread overview]
Message-ID: <20260514210500.1626871-15-seanjc@google.com> (raw)
In-Reply-To: <20260514210500.1626871-1-seanjc@google.com>

Replace (8) spaces with tabs in the kvmclock code so that upcoming changes
don't propagate the antiquated formatting.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/kvmclock.c      |  42 ++++-----
 x86/kvmclock_test.c | 218 ++++++++++++++++++++++----------------------
 2 files changed, 130 insertions(+), 130 deletions(-)

diff --git a/x86/kvmclock.c b/x86/kvmclock.c
index f9f21032..ea9c0e7e 100644
--- a/x86/kvmclock.c
+++ b/x86/kvmclock.c
@@ -56,7 +56,7 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
 # define do_div(n,base) ({					\
 	u32 __base = (base);    				\
 	u32 __rem;						\
-	__rem = ((u64)(n)) % __base;                            \
+	__rem = ((u64)(n)) % __base;			    \
 	(n) = ((u64)(n)) / __base;				\
 	__rem;							\
  })
@@ -194,9 +194,9 @@ static cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 	} while (pvclock_read_retry(src, version));
 
 	if ((valid_flags & PVCLOCK_RAW_CYCLE_BIT) ||
-            ((valid_flags & PVCLOCK_TSC_STABLE_BIT) &&
-             (flags & PVCLOCK_TSC_STABLE_BIT)))
-                return ret;
+	    ((valid_flags & PVCLOCK_TSC_STABLE_BIT) &&
+	     (flags & PVCLOCK_TSC_STABLE_BIT)))
+		return ret;
 
 	/*
 	 * Assumption here is that last_value, a global accumulator, always goes
@@ -224,27 +224,27 @@ static cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 
 cycle_t kvm_clock_read(void)
 {
-        struct pvclock_vcpu_time_info *src;
-        cycle_t ret;
-        int index = smp_id();
+	struct pvclock_vcpu_time_info *src;
+	cycle_t ret;
+	int index = smp_id();
 
-        src = &hv_clock[index];
-        ret = pvclock_clocksource_read(src);
-        return ret;
+	src = &hv_clock[index];
+	ret = pvclock_clocksource_read(src);
+	return ret;
 }
 
 void kvm_clock_init(void *data)
 {
-        int index = smp_id();
-        struct pvclock_vcpu_time_info *hvc = &hv_clock[index];
+	int index = smp_id();
+	struct pvclock_vcpu_time_info *hvc = &hv_clock[index];
 
-        printf("kvm-clock: cpu %d, msr %p\n", index, hvc);
-        wrmsr(MSR_KVM_SYSTEM_TIME_NEW, (unsigned long)hvc | 1);
+	printf("kvm-clock: cpu %d, msr %p\n", index, hvc);
+	wrmsr(MSR_KVM_SYSTEM_TIME_NEW, (unsigned long)hvc | 1);
 }
 
 void kvm_clock_clear(void *data)
 {
-        wrmsr(MSR_KVM_SYSTEM_TIME_NEW, 0LL);
+	wrmsr(MSR_KVM_SYSTEM_TIME_NEW, 0LL);
 }
 
 static void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
@@ -275,15 +275,15 @@ static void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
 
 void kvm_get_wallclock(struct timespec *ts)
 {
-        struct pvclock_vcpu_time_info *vcpu_time;
-        int index = smp_id();
+	struct pvclock_vcpu_time_info *vcpu_time;
+	int index = smp_id();
 
-        wrmsr(MSR_KVM_WALL_CLOCK_NEW, (unsigned long)&wall_clock);
-        vcpu_time = &hv_clock[index];
-        pvclock_read_wallclock(&wall_clock, vcpu_time, ts);
+	wrmsr(MSR_KVM_WALL_CLOCK_NEW, (unsigned long)&wall_clock);
+	vcpu_time = &hv_clock[index];
+	pvclock_read_wallclock(&wall_clock, vcpu_time, ts);
 }
 
 void pvclock_set_flags(unsigned char flags)
 {
-        valid_flags = flags;
+	valid_flags = flags;
 }
diff --git a/x86/kvmclock_test.c b/x86/kvmclock_test.c
index de4b5e13..d21c6c72 100644
--- a/x86/kvmclock_test.c
+++ b/x86/kvmclock_test.c
@@ -12,144 +12,144 @@ long sec = 0;
 long threshold = DEFAULT_THRESHOLD;
 
 struct test_info {
-        struct spinlock lock;
-        u64 warps;                /* warp count */
-        u64 stalls;               /* stall count */
-        long long worst;          /* worst warp */
-        volatile cycle_t last;    /* last cycle seen by test */
-        int check;                /* check cycle ? */
+	struct spinlock lock;
+	u64 warps;		/* warp count */
+	u64 stalls;		/* stall count */
+	long long worst;	/* worst warp */
+	volatile cycle_t last;	/* last cycle seen by test */
+	int check;		/* check cycle ? */
 };
 
 struct test_info ti[4];
 
 static void wallclock_test(void *data)
 {
-        int *p_err = data;
-        long ksec, offset;
-        struct timespec ts;
+	int *p_err = data;
+	long ksec, offset;
+	struct timespec ts;
 
-        kvm_get_wallclock(&ts);
-        ksec = ts.tv_sec;
+	kvm_get_wallclock(&ts);
+	ksec = ts.tv_sec;
 
-        offset = ksec - sec;
-        printf("Raw nanoseconds value from kvmclock: %" PRIu64 " (cpu %d)\n", kvm_clock_read(), smp_id());
-        printf("Seconds get from kvmclock: %ld (cpu %d, offset: %ld)\n", ksec, smp_id(), offset);
+	offset = ksec - sec;
+	printf("Raw nanoseconds value from kvmclock: %" PRIu64 " (cpu %d)\n", kvm_clock_read(), smp_id());
+	printf("Seconds get from kvmclock: %ld (cpu %d, offset: %ld)\n", ksec, smp_id(), offset);
 
-        if (offset > threshold || offset < -threshold) {
-                printf("offset too large!\n");
-                (*p_err)++;
-        }
+	if (offset > threshold || offset < -threshold) {
+		printf("offset too large!\n");
+		(*p_err)++;
+	}
 }
 
 static void kvm_clock_test(void *data)
 {
-        struct test_info *hv_test_info = (struct test_info *)data;
-        long i, check = hv_test_info->check;
+	struct test_info *hv_test_info = (struct test_info *)data;
+	long i, check = hv_test_info->check;
 
-        for (i = 0; i < loops; i++){
-                cycle_t t0, t1;
-                long long delta;
+	for (i = 0; i < loops; i++){
+		cycle_t t0, t1;
+		long long delta;
 
-                if (check == 0) {
-                        kvm_clock_read();
-                        continue;
-                }
+		if (check == 0) {
+			kvm_clock_read();
+			continue;
+		}
 
-                spin_lock(&hv_test_info->lock);
-                t1 = kvm_clock_read();
-                t0 = hv_test_info->last;
-                hv_test_info->last = kvm_clock_read();
-                spin_unlock(&hv_test_info->lock);
+		spin_lock(&hv_test_info->lock);
+		t1 = kvm_clock_read();
+		t0 = hv_test_info->last;
+		hv_test_info->last = kvm_clock_read();
+		spin_unlock(&hv_test_info->lock);
 
-                delta = t1 - t0;
-                if (delta < 0) {
-                        spin_lock(&hv_test_info->lock);
-                        ++hv_test_info->warps;
-                        if (delta < hv_test_info->worst){
-                                hv_test_info->worst = delta;
-                                printf("Worst warp %lld\n", hv_test_info->worst);
-                        }
-                        spin_unlock(&hv_test_info->lock);
-                }
-                if (delta == 0)
-                        ++hv_test_info->stalls;
+		delta = t1 - t0;
+		if (delta < 0) {
+			spin_lock(&hv_test_info->lock);
+			++hv_test_info->warps;
+			if (delta < hv_test_info->worst){
+				hv_test_info->worst = delta;
+				printf("Worst warp %lld\n", hv_test_info->worst);
+			}
+			spin_unlock(&hv_test_info->lock);
+		}
+		if (delta == 0)
+			++hv_test_info->stalls;
 
-                if (!((unsigned long)i & 31))
-                        asm volatile("rep; nop");
-        }
+		if (!((unsigned long)i & 31))
+			asm volatile("rep; nop");
+	}
 }
 
 static int cycle_test(int check, struct test_info *ti)
 {
-        unsigned long long begin, end;
+	unsigned long long begin, end;
 
-        begin = rdtsc();
+	begin = rdtsc();
 
-        ti->check = check;
-        on_cpus(kvm_clock_test, ti);
+	ti->check = check;
+	on_cpus(kvm_clock_test, ti);
 
-        end = rdtsc();
+	end = rdtsc();
 
-        printf("Total vcpus: %d\n", cpu_count());
-        printf("Test  loops: %ld\n", loops);
-        if (check == 1) {
-                printf("Total warps:  %" PRId64 "\n", ti->warps);
-                printf("Total stalls: %" PRId64 "\n", ti->stalls);
-                printf("Worst warp:   %lld\n", ti->worst);
-        } else
-                printf("TSC cycles:  %lld\n", end - begin);
+	printf("Total vcpus: %d\n", cpu_count());
+	printf("Test  loops: %ld\n", loops);
+	if (check == 1) {
+		printf("Total warps:  %" PRId64 "\n", ti->warps);
+		printf("Total stalls: %" PRId64 "\n", ti->stalls);
+		printf("Worst warp:   %lld\n", ti->worst);
+	} else
+		printf("TSC cycles:  %lld\n", end - begin);
 
-        return ti->warps ? 1 : 0;
+	return ti->warps ? 1 : 0;
 }
 
 int main(int ac, char **av)
 {
-        int nerr = 0;
-        int ncpus;
-        int i;
-
-        if (ac > 1)
-                loops = atol(av[1]);
-        if (ac > 2)
-                sec = atol(av[2]);
-        if (ac > 3)
-                threshold = atol(av[3]);
-
-        ncpus = cpu_count();
-        if (ncpus > MAX_CPU)
-                report_abort("number cpus exceeds %d", MAX_CPU);
-
-        on_cpus(kvm_clock_init, NULL);
-
-        if (ac > 2) {
-                printf("Wallclock test, threshold %ld\n", threshold);
-                printf("Seconds get from host:     %ld\n", sec);
-                for (i = 0; i < ncpus; ++i)
-                        on_cpu(i, wallclock_test, &nerr);
-        }
-
-        printf("Check the stability of raw cycle ...\n");
-        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
-                          | PVCLOCK_RAW_CYCLE_BIT);
-        if (cycle_test(1, &ti[0]))
-                printf("Raw cycle is not stable\n");
-        else
-                printf("Raw cycle is stable\n");
-
-        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
-        printf("Monotonic cycle test:\n");
-        nerr += cycle_test(1, &ti[1]);
-
-        printf("Measure the performance of raw cycle ...\n");
-        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
-                          | PVCLOCK_RAW_CYCLE_BIT);
-        cycle_test(0, &ti[2]);
-
-        printf("Measure the performance of adjusted cycle ...\n");
-        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
-        cycle_test(0, &ti[3]);
-
-        on_cpus(kvm_clock_clear, NULL);
-
-        return nerr > 0 ? 1 : 0;
+	int nerr = 0;
+	int ncpus;
+	int i;
+
+	if (ac > 1)
+		loops = atol(av[1]);
+	if (ac > 2)
+		sec = atol(av[2]);
+	if (ac > 3)
+		threshold = atol(av[3]);
+
+	ncpus = cpu_count();
+	if (ncpus > MAX_CPU)
+		report_abort("number cpus exceeds %d", MAX_CPU);
+
+	on_cpus(kvm_clock_init, NULL);
+
+	if (ac > 2) {
+		printf("Wallclock test, threshold %ld\n", threshold);
+		printf("Seconds get from host:     %ld\n", sec);
+		for (i = 0; i < ncpus; ++i)
+			on_cpu(i, wallclock_test, &nerr);
+	}
+
+	printf("Check the stability of raw cycle ...\n");
+	pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
+			  | PVCLOCK_RAW_CYCLE_BIT);
+	if (cycle_test(1, &ti[0]))
+		printf("Raw cycle is not stable\n");
+	else
+		printf("Raw cycle is stable\n");
+
+	pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
+	printf("Monotonic cycle test:\n");
+	nerr += cycle_test(1, &ti[1]);
+
+	printf("Measure the performance of raw cycle ...\n");
+	pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
+			  | PVCLOCK_RAW_CYCLE_BIT);
+	cycle_test(0, &ti[2]);
+
+	printf("Measure the performance of adjusted cycle ...\n");
+	pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
+	cycle_test(0, &ti[3]);
+
+	on_cpus(kvm_clock_clear, NULL);
+
+	return nerr > 0 ? 1 : 0;
 }
-- 
2.54.0.563.g4f69b47b94-goog


  parent reply	other threads:[~2026-05-14 21:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 21:04 [kvm-unit-tests PATCH v3 00/20] x86: Better backtraces for leaf functions Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 01/20] x86/vmx: Drop unused SYSENTER "support" in nested VMX infrastructure Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 02/20] x86/vmx: Drop unused guest_regs " Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 03/20] x86/svm: Sort (and swap) GPRs by their index, not alphabetically Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 04/20] x86: Dedup guest/host context switch of registers across SVM and VMX Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 05/20] x86/virt: Use macro shenanigans to get reg offsets when swapping guest/host regs Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 06/20] x86/virt: Track "guest regs" using per-CPU variable Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 07/20] x86/svm: Don't VMLOAD/VMSAVE "guest" state around VMRUN Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 08/20] x86/vmx: Use separate VMCSes for BSP vs. AP in INIT test Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 09/20] x86/vmx: Swap GPRs after checking "launched" status Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 10/20] x86/vmx: Track VMCS "launched" state per-CPU Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 11/20] x86/vmx: Track "is this CPU in guest mode" per-CPU Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 12/20] x86/vmx: Communicate hypercalls via RAX, not a global field Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 13/20] x86/vmx: Initialize test stage in SIPI test *before* launching AP thread Sean Christopherson
2026-05-14 21:04 ` Sean Christopherson [this message]
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 15/20] x86/kvmclock: Skip kvmclock test when not running on KVM with CLOCKSOURCE2 Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 16/20] x86/vmx: Tag "struct vmx_msr_entry" as needing to be 16-byte aligned Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 17/20] x86/smp: Align the stack to a 16-byte boundary when invoking SMP function calls Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 18/20] x86/vmx: Write to KVM's WALL_CLOCK MSR via VM-Entry load list sync in SIPI test Sean Christopherson
2026-05-14 21:04 ` [kvm-unit-tests PATCH v3 19/20] x86: Better backtraces for leaf functions Sean Christopherson
2026-05-14 21:05 ` [kvm-unit-tests PATCH v3 20/20] x86: Prevent realmode test code instrumentation with nop-mcount Sean Christopherson

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=20260514210500.1626871-15-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=minipli@grsecurity.net \
    --cc=pbonzini@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox