Skip to content

Commit ec5f551

Browse files
committed
Merge: KVM: selftests: Allow skipping the KVM_RUN sanity check in rseq_test
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5850 JIRA: https://issues.redhat.com/browse/RHEL-28186 Signed-off-by: Vitaly Kuznetsov <[email protected]> Approved-by: Maxim Levitsky <[email protected]> Approved-by: Emanuele Giuseppe Esposito <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Rado Vrbovsky <[email protected]>
2 parents b052dd1 + 1d9adaf commit ec5f551

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

tools/testing/selftests/kvm/rseq_test.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,35 @@ static void calc_min_max_cpu(void)
198198
"Only one usable CPU, task migration not possible");
199199
}
200200

201+
static void help(const char *name)
202+
{
203+
puts("");
204+
printf("usage: %s [-h] [-u]\n", name);
205+
printf(" -u: Don't sanity check the number of successful KVM_RUNs\n");
206+
puts("");
207+
exit(0);
208+
}
209+
201210
int main(int argc, char *argv[])
202211
{
212+
bool skip_sanity_check = false;
203213
int r, i, snapshot;
204214
struct kvm_vm *vm;
205215
struct kvm_vcpu *vcpu;
206216
u32 cpu, rseq_cpu;
217+
int opt;
218+
219+
while ((opt = getopt(argc, argv, "hu")) != -1) {
220+
switch (opt) {
221+
case 'u':
222+
skip_sanity_check = true;
223+
break;
224+
case 'h':
225+
default:
226+
help(argv[0]);
227+
break;
228+
}
229+
}
207230

208231
r = sched_getaffinity(0, sizeof(possible_mask), &possible_mask);
209232
TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)", errno,
@@ -264,9 +287,17 @@ int main(int argc, char *argv[])
264287
* getcpu() to stabilize. A 2:1 migration:KVM_RUN ratio is a fairly
265288
* conservative ratio on x86-64, which can do _more_ KVM_RUNs than
266289
* migrations given the 1us+ delay in the migration task.
290+
*
291+
* Another reason why it may have small migration:KVM_RUN ratio is that,
292+
* on systems with large low power mode wakeup latency, it may happen
293+
* quite often that the scheduler is not able to wake up the target CPU
294+
* before the vCPU thread is scheduled to another CPU.
267295
*/
268-
TEST_ASSERT(i > (NR_TASK_MIGRATIONS / 2),
269-
"Only performed %d KVM_RUNs, task stalled too much?", i);
296+
TEST_ASSERT(skip_sanity_check || i > (NR_TASK_MIGRATIONS / 2),
297+
"Only performed %d KVM_RUNs, task stalled too much?\n\n"
298+
" Try disabling deep sleep states to reduce CPU wakeup latency,\n"
299+
" e.g. via cpuidle.off=1 or setting /dev/cpu_dma_latency to '0',\n"
300+
" or run with -u to disable this sanity check.", i);
270301

271302
pthread_join(migration_thread, NULL);
272303

0 commit comments

Comments
 (0)