Re: [PATCH v10 0/6] selftests/mm: refactor pkey helpers and fix mmap error handling
From: Hongfu Li
Date: Mon Jul 06 2026 - 23:27:25 EST
Hi,
> > The main changes in this series are to refactor shared tracing and assertion
> > helpers into a common file, unify both pkey selftests on pkey_assert() and
> > per-test tracing for consistent diagnostics, and add missing mmap() return
> > checks with MAP_FAILED used throughout for readability and consistency.
>
> Thanks, I've updated mm.git to this version.
>
> > v10:
> > - Add patch 6/6 to fix a pre-existing cleartid race: remove unused
> > settid/cleartid clone flags and wait for the clone child to exit in
> > the sigsegv test.
>
> Below is how v10 altered mm.git. As you mentioned, this is all from
> the addition of [patch 6/6].
>
> btw, I thought the official way to wait for a child thread to exit is
> pthread_join()? Why is that sched_yield() loop used?
Thanks a lot for your question.
As I understand it, the primary reason is pthread_create automatically
enables rseq on all threads, which corrupts the isolated pkey signal
handling kernel context this selftest is designed to exercise. We use
raw clone_raw explicitly to avoid rseq interference as noted in the
code comment.
Besides, pthread_join cannot work here. Since the thread is created via
raw clone instead of pthread_create, it is not tracked by libpthread at
all, so invoking pthread_join with its TID will return EINVAL.
Best regards,
Hongfu