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.sashiko-reviews,dev.linux.lists.kvmarm,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/tool= s/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 =3D arg; > > struct kvm_run *run =3D vcpu->run; > > =20 > > +#ifndef _GNU_SOURCE > > kvm_sched_setaffinity(0, sizeof(cpu_set_t), &threads_cpu_set); > > +#endif >=20 > [Severity: Low] > Since the KVM selftests build system unconditionally defines _GNU_SOURCE, > will this fallback code ever be reached? >=20 > [ ... ] >=20 > > @@ -80,22 +84,28 @@ static inline void check_join(pthread_t thread, voi= d **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; > > =20 > > + 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 d= etect 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 switch= ed 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 implementati= ons > like musl? >=20 > 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. >=20 > --=20 > Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260731195612.26= [email protected]?part=3D3