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, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.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, hongfu.li@linux.dev
Subject: Re: [PATCH v9 0/5] selftests/mm: refactor pkey helpers and fix mmap error handling
Date: Sun, 5 Jul 2026 13:48:19 -0700 [thread overview]
Message-ID: <20260705134819.871dbf41d2b06681f0facf12@linux-foundation.org> (raw)
In-Reply-To: <20260702062332.911786-1-lihongfu@kylinos.cn>
On Thu, 2 Jul 2026 14:23:27 +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.
Updated, thanks.
AI review might have found a pre-existing thing:
https://sashiko.dev/#/patchset/20260702062332.911786-1-lihongfu@kylinos.cn
> v9:
> - In patch 1/5, define test_nr, iteration_nr and dprint_in_signal in
> pkey_util.c and remove them from protection_keys.c and
> pkey_sighandler_tests.c.
> - In patch 1/5, cat_into_file() used the wrong argument in the open()
> failure message; print file instead of str. Update the commit message
> accordingly.
> - In patch 2/5, align clone_raw() continuation lines to the opening parenthesis.
> - In patch 5/5, set errno from pthread_create() return value before
> pkey_assert(0) on thread creation failure.
> - Add Acked-by, Reviewed-by and Tested-by tags to each patch.
Here's how v9 altered mm.git:
tools/testing/selftests/mm/pkey_sighandler_tests.c | 38 +++++------
tools/testing/selftests/mm/pkey_util.c | 6 +
tools/testing/selftests/mm/protection_keys.c | 4 -
3 files changed, 25 insertions(+), 23 deletions(-)
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c~b
+++ a/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -35,10 +35,6 @@ static pthread_mutex_t mutex = PTHREAD_M
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static siginfo_t siginfo = {0};
-int iteration_nr = 1;
-int test_nr;
-int dprint_in_signal;
-
/*
* We need to use inline assembly instead of glibc's syscall because glibc's
* syscall will attempt to access the PLT in order to call a library function
@@ -225,7 +221,10 @@ static void test_sigsegv_handler_with_pk
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&thr, &attr, thread_segv_with_pkey0_disabled, NULL);
- pkey_assert(ret == 0);
+ if (ret) {
+ errno = ret;
+ pkey_assert(0);
+ }
pthread_mutex_lock(&mutex);
while (siginfo.si_signo == 0)
@@ -265,7 +264,10 @@ static void test_sigsegv_handler_cannot_
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&thr, &attr, thread_segv_pkuerr_stack, NULL);
- pkey_assert(ret == 0);
+ if (ret) {
+ errno = ret;
+ pkey_assert(0);
+ }
pthread_mutex_lock(&mutex);
while (siginfo.si_signo == 0)
@@ -327,12 +329,12 @@ 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);
+ CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM |
+ CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
+ CLONE_DETACHED,
+ stack + STACK_SIZE,
+ &parent_pid,
+ &child_pid);
if (ret < 0) {
errno = -ret;
@@ -501,12 +503,12 @@ 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);
+ CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM |
+ CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
+ CLONE_DETACHED,
+ stack + STACK_SIZE,
+ &parent_pid,
+ &child_pid);
if (ret < 0) {
errno = -ret;
--- a/tools/testing/selftests/mm/pkey_util.c~b
+++ a/tools/testing/selftests/mm/pkey_util.c
@@ -8,6 +8,10 @@
#include "pkey-helpers.h"
+int iteration_nr = 1;
+int test_nr;
+int dprint_in_signal;
+
#if CONTROL_TRACING > 0
static void cat_into_file(char *str, char *file)
{
@@ -20,7 +24,7 @@ static void cat_into_file(char *str, cha
* pkey_assert()
*/
if (fd < 0) {
- fprintf(stderr, "error opening '%s'\n", str);
+ fprintf(stderr, "error opening '%s'\n", file);
perror("error: ");
exit(__LINE__);
}
--- a/tools/testing/selftests/mm/protection_keys.c~b
+++ a/tools/testing/selftests/mm/protection_keys.c
@@ -49,11 +49,7 @@
#include "hugepage_settings.h"
#include "pkey-helpers.h"
-int iteration_nr = 1;
-int test_nr;
-
u64 shadow_pkey_reg;
-int dprint_in_signal;
noinline int read_ptr(int *ptr)
{
_
next parent reply other threads:[~2026-07-05 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260702062332.911786-1-lihongfu@kylinos.cn>
2026-07-05 20:48 ` Andrew Morton [this message]
2026-07-06 7:32 ` [PATCH v9 0/5] selftests/mm: refactor pkey helpers and fix mmap error handling Hongfu Li
[not found] ` <20260702062332.911786-2-lihongfu@kylinos.cn>
2026-07-06 9:28 ` [PATCH v9 1/5] selftests/mm: move pkey selftest helpers to pkey_util.c David Hildenbrand (Arm)
2026-07-06 10:31 ` Hongfu Li
2026-07-06 13:46 ` David Hildenbrand (Arm)
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=20260705134819.871dbf41d2b06681f0facf12@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox