Skip to content

Commit 410cb01

Browse files
vittyvksean-jc
authored andcommitted
KVM: selftests: Use generic sys_clocksource_is_tsc() in vmx_nested_tsc_scaling_test
Despite its name, system_has_stable_tsc() just checks that system clocksource is 'tsc'; this can now be done with generic sys_clocksource_is_tsc(). No functional change intended. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20240109141121.1619463-3-vkuznets@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent e440c5f commit 410cb01

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,6 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
116116
GUEST_DONE();
117117
}
118118

119-
static bool system_has_stable_tsc(void)
120-
{
121-
bool tsc_is_stable;
122-
FILE *fp;
123-
char buf[4];
124-
125-
fp = fopen("/sys/devices/system/clocksource/clocksource0/current_clocksource", "r");
126-
if (fp == NULL)
127-
return false;
128-
129-
tsc_is_stable = fgets(buf, sizeof(buf), fp) &&
130-
!strncmp(buf, "tsc", sizeof(buf));
131-
132-
fclose(fp);
133-
return tsc_is_stable;
134-
}
135-
136119
int main(int argc, char *argv[])
137120
{
138121
struct kvm_vcpu *vcpu;
@@ -148,7 +131,7 @@ int main(int argc, char *argv[])
148131

149132
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_VMX));
150133
TEST_REQUIRE(kvm_has_cap(KVM_CAP_TSC_CONTROL));
151-
TEST_REQUIRE(system_has_stable_tsc());
134+
TEST_REQUIRE(sys_clocksource_is_tsc());
152135

153136
/*
154137
* We set L1's scale factor to be a random number from 2 to 10.

0 commit comments

Comments
 (0)