Re: [PATCH v3 03/12] KVM: selftests: Pre-set threads affinity in hardware disable test when possible
[email protected] Fri, 31 Jul 2026 20:11:39 +0000
| Newsgroups | dev.linux.lists.kvmarm,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The fallback logic for setting thread CPU affinity is guarded by `#ifndef _GNU_SOURCE`, which is always false because KVM selftests unconditionally define `_GNU_SOURCE`. This renders the fallback dead code and breaks builds on non-glibc systems. -- --- Patch [3]: [PATCH v3 03/12] KVM: selftests: Pre-set threads affinity in hardware disable test when possible --- commit 242db3bb38cdcdb7592d9d34951b2c689c2c39b5 Author: Sean Christopherson <[email protected]> KVM: selftests: Pre-set threads affinity in hardware disable test when possible This commit pre-sets thread affinity using pthread_attr_setaffinity_np to reduce pthread creation latency on large NUMA systems. It attempts to add a fallback using kvm_sched_setaffinity when _GNU_SOURCE is not defined. > diff --git a/tools/testing/selftests/kvm/hardware_disable_test.c b/tools/testing/selftests/kvm/hardware_disable_test.c > index f088b4af3ccc7..b4edeadfa3f45 100644 > --- a/tools/testing/selftests/kvm/hardware_disable_test.c > +++ b/tools/testing/selftests/kvm/hardware_disable_test.c > @@ -36,7 +36,9 @@ static void *run_vcpu(void *arg) > struct kvm_vcpu *vcpu = arg; > struct kvm_run *run = vcpu->run; > > +#ifndef _GNU_SOURCE > kvm_sched_setaffinity(0, sizeof(cpu_set_t), &threads_cpu_set); > +#endif [Severity: Low] Since the KVM selftests build system unconditionally defines _GNU_SOURCE, will this fallback code ever be reached? [ ... ] > @@ -80,22 +84,28 @@ static inline void check_join(pthread_t thread, void **retval) > static void run_test(u32 run) > { > struct kvm_vcpu *vcpu; > + pthread_attr_t attr; > struct kvm_vm *vm; > pthread_t threads[VCPU_NUM]; > pthread_t throw_away; > void *b; > u32 i, j; > > + TEST_ASSERT_EQ(pthread_attr_init(&attr), 0); > +#ifdef _GNU_SOURCE > + TEST_ASSERT_EQ(pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &threads_cpu_set), 0); > +#endif [Severity: Low] Could this break the build on systems using alternative libc implementations like musl? If _GNU_SOURCE is unconditionally defined by the Makefile but the libc doesn't provide pthread_attr_setaffinity_np, this might result in a compilation error rather than using the intended fallback. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3