Re: [PATCH v3 03/12] KVM: selftests: Pre-set threads affinity in hardware disable test when possible
Sean Christopherson <[email protected]> Fri, 31 Jul 2026 13:50:48 -0700
| Newsgroups | dev.linux.lists.kvmarm,dev.linux.lists.sashiko-reviews,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
+Aqib On Fri, Jul 31, 2026, [email protected] wrote: > > 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 Aqib, Do you happen to definitively know which is the "right" macro to check to detect support for pthread_attr_setaffinity_np()? Belatedly, I saw that you used __GLIBC__ in a patch that ultimately wasn't applied[*]. I initially used __USE_GNU here, but then Sashiko yelled at me, so I switched to _GNU_SOURCE based on Sashiko's suggestion, and now it's yelling at me again :-) [*] https://lore.kernel.org/all/[email protected] > [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