OpenCloudOS-Kernel/tools/testing/selftests/kvm
Gavin Shan e923b0537d KVM: selftests: Fix target thread to be migrated in rseq_test
In rseq_test, there are two threads, which are vCPU thread and migration
worker separately. Unfortunately, the test has the wrong PID passed to
sched_setaffinity() in the migration worker. It forces migration on the
migration worker because zeroed PID represents the calling thread, which
is the migration worker itself. It means the vCPU thread is never enforced
to migration and it can migrate at any time, which eventually leads to
failure as the following logs show.

  host# uname -r
  5.19.0-rc6-gavin+
  host# # cat /proc/cpuinfo | grep processor | tail -n 1
  processor    : 223
  host# pwd
  /home/gavin/sandbox/linux.main/tools/testing/selftests/kvm
  host# for i in `seq 1 100`; do \
        echo "--------> $i"; ./rseq_test; done
  --------> 1
  --------> 2
  --------> 3
  --------> 4
  --------> 5
  --------> 6
  ==== Test Assertion Failure ====
    rseq_test.c:265: rseq_cpu == cpu
    pid=3925 tid=3925 errno=4 - Interrupted system call
       1  0x0000000000401963: main at rseq_test.c:265 (discriminator 2)
       2  0x0000ffffb044affb: ?? ??:0
       3  0x0000ffffb044b0c7: ?? ??:0
       4  0x0000000000401a6f: _start at ??:?
    rseq CPU = 4, sched CPU = 27

Fix the issue by passing correct parameter, TID of the vCPU thread, to
sched_setaffinity() in the migration worker.

Fixes: 61e52f1630 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Message-Id: <20220719020830.3479482-1-gshan@redhat.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-07-19 09:03:49 -04:00
..
aarch64 Merge branch kvm-arm64/psci-suspend into kvmarm-master/next 2022-05-16 17:48:20 +01:00
include KVM: selftests: Add option to run dirty_log_perf_test vCPUs in L2 2022-06-09 10:52:27 -04:00
lib selftests: KVM: Handle compiler optimizations in ucall 2022-06-23 10:26:41 -04:00
s390x KVM: s390: selftest: Test suppression indication on key prot exception 2022-05-20 16:38:42 +02:00
x86_64 KVM: selftests: Replace x86_page_size with PG_LEVEL_XX 2022-06-09 10:52:22 -04:00
.gitignore KVM: selftests: x86: Sync the new name of the test case to .gitignore 2022-05-25 05:15:48 -04:00
Makefile KVM: selftests: Add option to run dirty_log_perf_test vCPUs in L2 2022-06-09 10:52:27 -04:00
access_tracking_perf_test.c KVM: selftests: Move vCPU thread creation and joining to common helpers 2021-11-16 07:43:28 -05:00
config selftests: kvm: Adding config fragments 2019-08-09 16:52:38 +02:00
demand_paging_test.c KVM: selftests: Move vCPU thread creation and joining to common helpers 2021-11-16 07:43:28 -05:00
dirty_log_perf_test.c KVM: selftests: Add option to run dirty_log_perf_test vCPUs in L2 2022-06-09 10:52:27 -04:00
dirty_log_test.c KVM: selftests: Expose align() helpers to tests 2021-11-16 07:43:24 -05:00
hardware_disable_test.c KVM: selftests: Unconditionally use memslot 0 when loading elf binary 2021-06-24 04:31:17 -04:00
kvm_binary_stats_test.c KVM: selftests: Add checks for histogram stats bucket_size field 2021-08-20 16:06:32 -04:00
kvm_create_max_vcpus.c KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILE 2021-11-26 08:14:20 -05:00
kvm_page_table_test.c KVM: selftests: Silence compiler warning in the kvm_page_table_test 2022-04-21 13:16:14 -04:00
max_guest_memory_test.c KVM: selftests: Replace x86_page_size with PG_LEVEL_XX 2022-06-09 10:52:22 -04:00
memslot_modification_stress_test.c KVM: selftests: Use perf_test_destroy_vm in memslot_modification_stress_test 2021-11-16 07:43:28 -05:00
memslot_perf_test.c KVM: selftests: Make memslot_perf_test arch independent 2021-10-21 11:36:34 +01:00
rseq_test.c KVM: selftests: Fix target thread to be migrated in rseq_test 2022-07-19 09:03:49 -04:00
set_memory_region_test.c KVM: selftests: Move raw KVM_SET_USER_MEMORY_REGION helper to utils 2022-03-08 10:59:10 -05:00
settings selftests: kvm: Raise the default timeout to 120 seconds 2021-02-09 08:17:08 -05:00
steal_time.c selftests: KVM: Create helper for making SMCCC calls 2022-05-04 09:28:45 +01:00
system_counter_offset_test.c selftests: KVM: Introduce system counter offset test 2021-10-18 14:43:46 -04:00