public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* rseq CPU ID not correct on 6.0 kernels for pinned threads
@ 2023-01-11 11:26 Florian Weimer
  2023-01-11 14:52 ` Mathieu Desnoyers
  0 siblings, 1 reply; 8+ messages in thread
From: Florian Weimer @ 2023-01-11 11:26 UTC (permalink / raw)
  To: Mathieu Desnoyers, linux-kernel; +Cc: Ingo Molnar, Peter Zijlstra, libc-alpha

The glibc test suite contains a test that verifies that sched_getcpu
returns the expected CPU number for a thread that is pinned (via
sched_setaffinity) to a specific CPU.  There are other threads running
which attempt to de-schedule the pinned thread from its CPU.  I believe
the test is correctly doing what it is expected to do; it is invalid
only if one believes that it is okay for the kernel to disregard the
affinity mask for scheduling decisions.

These days, we use the cpu_id rseq field as the return value of
sched_getcpu if the kernel has rseq support (which it has in these
cases).

This test has started failing sporadically for us, some time around
kernel 6.0.  I see failure occasionally on a Fedora builder, it runs:

Linux buildvm-x86-26.iad2.fedoraproject.org 6.0.15-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 21 18:33:23 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

I think I've seen it on the x86-64 builder only, but that might just be
an accident.

The failing tests log this output:

=====FAIL: nptl/tst-thread-affinity-pthread.out=====
info: Detected CPU set size (in bits): 64
info: Maximum test CPU: 5
error: Pinned thread 1 ran on impossible cpu 0
error: Pinned thread 0 ran on impossible cpu 0
info: Main thread ran on 4 CPU(s) of 6 available CPU(s)
info: Other threads ran on 6 CPU(s)
=====FAIL: nptl/tst-thread-affinity-pthread2.out=====
info: Detected CPU set size (in bits): 64
info: Maximum test CPU: 5
error: Pinned thread 1 ran on impossible cpu 1
error: Pinned thread 2 ran on impossible cpu 0
error: Pinned thread 3 ran on impossible cpu 3
info: Main thread ran on 5 CPU(s) of 6 available CPU(s)
info: Other threads ran on 6 CPU(s)

But I also encountered one local failure, but it is rare.  Maybe it's
load-related.  There shouldn't be any CPU unplug or anything like that
involved here.

I am not entirely sure if something is changing CPU affinities from
outside the process (which would be quite wrong, but not a kernel bug).
But in the past, our glibc test has detected real rseq cpu_id
brokenness, so I'm leaning towards that as the cause this time, too.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-01-13 16:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 11:26 rseq CPU ID not correct on 6.0 kernels for pinned threads Florian Weimer
2023-01-11 14:52 ` Mathieu Desnoyers
2023-01-11 19:31   ` Mathieu Desnoyers
2023-01-11 21:51     ` Mathieu Desnoyers
2023-01-12 16:33   ` Florian Weimer
2023-01-12 20:25     ` Mathieu Desnoyers
2023-01-13 16:06       ` Florian Weimer
2023-01-13 16:13         ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).