Skip to content

Commit 050632a

Browse files
Sebastian OttMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Fix thread migration in arch_timer_edge_cases
arch_timer_edge_cases tries to migrate itself across host cpus. Before the first test, it migrates to cpu 0 by setting up an affinity mask with only bit 0 set. After that it looks for the next possible cpu in the current affinity mask which still has only bit 0 set. So there is no migration at all. Fix this by reading the default mask at start and use this to find the next cpu in each iteration. Signed-off-by: Sebastian Ott <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 9a9864f commit 050632a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,17 +849,17 @@ static void guest_code(enum arch_timer timer)
849849
GUEST_DONE();
850850
}
851851

852+
static cpu_set_t default_cpuset;
853+
852854
static uint32_t next_pcpu(void)
853855
{
854856
uint32_t max = get_nprocs();
855857
uint32_t cur = sched_getcpu();
856858
uint32_t next = cur;
857-
cpu_set_t cpuset;
859+
cpu_set_t cpuset = default_cpuset;
858860

859861
TEST_ASSERT(max > 1, "Need at least two physical cpus");
860862

861-
sched_getaffinity(0, sizeof(cpuset), &cpuset);
862-
863863
do {
864864
next = (next + 1) % CPU_SETSIZE;
865865
} while (!CPU_ISSET(next, &cpuset));
@@ -1046,6 +1046,8 @@ int main(int argc, char *argv[])
10461046
if (!parse_args(argc, argv))
10471047
exit(KSFT_SKIP);
10481048

1049+
sched_getaffinity(0, sizeof(default_cpuset), &default_cpuset);
1050+
10491051
if (test_args.test_virtual) {
10501052
test_vm_create(&vm, &vcpu, VIRTUAL);
10511053
test_run(vm, vcpu);

0 commit comments

Comments
 (0)