All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hongfu Li <lihongfu@kylinos.cn>
Cc: david@kernel.org, ljs@kernel.org, liam@infradead.org,
	vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
	mhocko@suse.com, shuah@kernel.org, jhubbard@nvidia.com,
	joey.gouly@arm.com, keith.lucas@oracle.com,
	kevin.brodsky@arm.com, usama.anjum@collabora.com,
	yury.khrustalev@arm.com, zwisler@google.com, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	hongfu.li@linux.dev
Subject: Re: [PATCH v10 0/6] selftests/mm: refactor pkey helpers and fix mmap error handling
Date: Mon, 6 Jul 2026 16:28:41 -0700	[thread overview]
Message-ID: <20260706162841.b34d9bc1ba1aaa4be4f6254e@linux-foundation.org> (raw)
In-Reply-To: <20260706081600.3570203-1-lihongfu@kylinos.cn>

On Mon,  6 Jul 2026 16:15:54 +0800 Hongfu Li <lihongfu@kylinos.cn> wrote:

> 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?


 tools/testing/selftests/mm/pkey_sighandler_tests.c |   20 ++++++-----
 1 file changed, 12 insertions(+), 8 deletions(-)

--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c~b
+++ a/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -290,7 +290,6 @@ static void test_sigsegv_handler_with_di
 	static stack_t sigstack;
 	void *stack;
 	int pkey;
-	int parent_pid = 0;
 	int child_pid = 0;
 	u64 pkey_reg;
 	long ret;
@@ -330,11 +329,10 @@ static void test_sigsegv_handler_with_di
 	/* Use clone to avoid newer glibcs using rseq on new threads */
 	ret = clone_raw(CLONE_VM | CLONE_FS | CLONE_FILES |
 			CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM |
-			CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
 			CLONE_DETACHED,
 			stack + STACK_SIZE,
-			&parent_pid,
-			&child_pid);
+			NULL,
+			NULL);
 
 	if (ret < 0) {
 		errno = -ret;
@@ -344,11 +342,19 @@ static void test_sigsegv_handler_with_di
 		syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0);
 	}
 
+	child_pid = ret;
+
 	pthread_mutex_lock(&mutex);
 	while (siginfo.si_signo == 0)
 		pthread_cond_wait(&cond, &mutex);
 	pthread_mutex_unlock(&mutex);
 
+	/* Wait for child to exit before returning */
+	do {
+		sched_yield();
+		ret = syscall_raw(SYS_tkill, child_pid, 0, 0, 0, 0, 0);
+	} while (ret != -ESRCH && ret != -EINVAL);
+
 	ksft_test_result(siginfo.si_signo == SIGSEGV &&
 			 siginfo.si_code == SEGV_MAPERR &&
 			 siginfo.si_addr == NULL,
@@ -445,7 +451,6 @@ static void test_pkru_sigreturn(void)
 	static stack_t sigstack;
 	void *stack;
 	int pkey;
-	int parent_pid = 0;
 	int child_pid = 0;
 	u64 pkey_reg;
 	long ret;
@@ -504,11 +509,10 @@ static void test_pkru_sigreturn(void)
 	/* Use clone to avoid newer glibcs using rseq on new threads */
 	ret = clone_raw(CLONE_VM | CLONE_FS | CLONE_FILES |
 			CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM |
-			CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
 			CLONE_DETACHED,
 			stack + STACK_SIZE,
-			&parent_pid,
-			&child_pid);
+			NULL,
+			NULL);
 
 	if (ret < 0) {
 		errno = -ret;
_



  parent reply	other threads:[~2026-07-06 23:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  8:15 [PATCH v10 0/6] selftests/mm: refactor pkey helpers and fix mmap error handling Hongfu Li
2026-07-06  8:15 ` [PATCH v10 1/6] selftests/mm: move pkey selftest helpers to pkey_util.c Hongfu Li
2026-07-06  8:15 ` [PATCH v10 2/6] selftests/mm: unify pkey sighandler selftest assertions and tracing Hongfu Li
2026-07-06  8:15 ` [PATCH v10 3/6] selftests/mm: use pkey_assert on clone_raw failure in pkey test Hongfu Li
2026-07-06  8:15 ` [PATCH v10 4/6] selftests/mm: add missing mmap() return checks in pkey tests Hongfu Li
2026-07-06  8:15 ` [PATCH v10 5/6] selftests/mm: add missing pthread_create() " Hongfu Li
2026-07-06  8:16 ` [PATCH v10 6/6] selftests/mm: fix clone cleartid race in pkey sighandler tests Hongfu Li
2026-07-06 23:28 ` Andrew Morton [this message]
2026-07-07  3:25   ` [PATCH v10 0/6] selftests/mm: refactor pkey helpers and fix mmap error handling Hongfu Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260706162841.b34d9bc1ba1aaa4be4f6254e@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hongfu.li@linux.dev \
    --cc=jhubbard@nvidia.com \
    --cc=joey.gouly@arm.com \
    --cc=keith.lucas@oracle.com \
    --cc=kevin.brodsky@arm.com \
    --cc=liam@infradead.org \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=usama.anjum@collabora.com \
    --cc=vbabka@kernel.org \
    --cc=yury.khrustalev@arm.com \
    --cc=zwisler@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.