From: wang lian <lianux.mm@gmail.com>
To: broonie@kernel.org
Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org,
brauner@kernel.org, david@redhat.com, gkwang@linx-info.com,
jannh@google.com, lianux.mm@gmail.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, lorenzo.stoakes@oracle.com,
p1ucky0923@gmail.com, ryncsn@gmail.com, shuah@kernel.org,
sj@kernel.org, vbabka@suse.cz, zijing.zhang@proton.me,
ziy@nvidia.com
Subject: Re: [PATCH v3] selftests/mm: add process_madvise() tests
Date: Fri, 11 Jul 2025 20:19:48 +0800 [thread overview]
Message-ID: <20250711121952.17380-1-lianux.mm@gmail.com> (raw)
In-Reply-To: <aG_DPLhtZ5qDuWHY@finisterre.sirena.org.uk>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=yes, Size: 3755 bytes --]
Hi Mark Brown,
> On Thu, Jul 10, 2025 at 07:22:49PM +0800, wang lian wrote:
>
> > Add tests for process_madvise(), focusing on verifying behavior under
> > various conditions including valid usage and error cases.
>
> > --- a/tools/testing/selftests/mm/guard-regions.c
> > +++ b/tools/testing/selftests/mm/guard-regions.c
>
> > -static void handle_fatal(int c)
> > -{
> > - if (!signal_jump_set)
> > - return;
> > -
> > - siglongjmp(signal_jmp_buf, c);
> > -}
> I see from looking later in the patch that you're factoring this out of
> the guard regions test into vm_util.c so that it can be used by your new
> test. This is good and sensible but it's a bit surprising, especially
> since your changelog only said you were adding a new test. It would be
> better to split this out into a separate refactoring patch that just
> does the code motion, as covered in submitting-patches.rst it's better
> if changes just do one thing.
Thanks for the suggestion. I’ll split this out into a separate patch
that just moves the helper to vm_util.c, and follow up with the new
test in a second patch.
> > +#include <linux/pidfd.h>
> > +#include <linux/uio.h>
>
> Does this work without 'make headers_install' for the systems that were
> affectd by missing headers? Lorenzo mentioned that we shouldn't depend
> on that for the mm tests (I'm not enthusiastic about that approach
> myself, but if it's what mm needs).
You're right, and I’ve seen build issues due to that as well. I’ll drop
<linux/pidfd.h> and define PIDFD_SELF locally to avoid requiring
installed headers.
> > + ret = read(pipe_info[0], &info, sizeof(info));
> > + if (ret <= 0) {
> > + waitpid(self->child_pid, NULL, 0);
> > + ksft_exit_skip("Failed to read child info from pipe.\n");
> > + }
> If you're using the harness you should use SKIP() rather than the ksft
> APIs for reporting test results. Don't mix and match the result
> reporting APIs, harness will call the ksft_ APIs appropriately for you.
Understood. I’ll convert this and other cases to use SKIP() and ensure
the test consistently uses the test harness macros.
> > + if (errno == EAGAIN) {
> > + ksft_test_result_skip(
> > + "THP is 'always', process_madvise returned EAGAIN due to an expected race with khugepaged.\n");
> > + } else {
> > + ksft_test_result_fail(
> > + "process_madvise failed with unexpected errno %d in 'always' mode.\n",
> > + errno);
> > + }
> Similarly, to fail use an ASSERT or EXPECT. Note also that when using
> the ksft_ API for reporting results each test should report a consistent
> test name as the string, if you want to report an error message print it
> separately to the test result.
I’ll revise this to use ASSERT/EXPECT, and separate error output from
test result strings, as you suggested.
> > + * Test process_madvise() with various invalid pidfds to ensure correct
> > + * error handling. This includes negative fds, non-pidfd fds, and pidfds for
> > + * processes that no longer exist.
> This sounds like it should be a series of small tests rather than a
> single omnibus test, that'd result in clearer error reporting from test
> frameworks since they will say which operation failed directly rather
> than having to look at the logs then match them to the source.
That makes sense. I’ll break this out into multiple smaller tests so
each case reports independently.
> > + pidfd = syscall(__NR_pidfd_open, child_pid, 0);
> > + ASSERT_GE(pidfd, 0);
> This is particularly the case given the use of ASSERTs, we'll not report
> any issues other than the first one we hit.
Thanks, I’ll switch to EXPECT_* where appropriate to allow multiple
checks per test case.
Thanks again for the detailed review!
Best regards,
Wang Lian
next prev parent reply other threads:[~2025-07-11 12:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 11:22 [PATCH v4] " wang lian
2025-07-10 13:42 ` Mark Brown
2025-07-10 16:21 ` Zi Yan
2025-07-11 8:05 ` Mark Brown
2025-07-11 12:19 ` wang lian [this message]
2025-07-10 16:57 ` Lorenzo Stoakes
2025-07-11 8:11 ` Mark Brown
2025-07-11 8:53 ` Lorenzo Stoakes
2025-07-11 9:29 ` Mark Brown
2025-07-11 11:16 ` wang lian
2025-07-11 11:33 ` Lorenzo Stoakes
2025-07-11 12:02 ` wang lian
-- strict thread matches above, loose matches on Subject: below --
2025-07-03 4:43 [PATCH v3] " wang lian
2025-07-05 19:32 ` Lorenzo Stoakes
2025-07-08 17:44 ` Zi Yan
2025-07-09 12:32 ` wang lian
2025-07-09 12:51 ` Lorenzo Stoakes
2025-07-10 11:29 ` wang lian
2025-07-09 14:46 ` Zi Yan
2025-07-10 8:42 ` Mark Brown
2025-07-10 16:28 ` Zi Yan
2025-07-11 8:34 ` Mark Brown
2025-07-11 8:49 ` Lorenzo Stoakes
2025-07-11 12:09 ` wang lian
2025-07-10 11:40 ` wang lian
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=20250711121952.17380-1-lianux.mm@gmail.com \
--to=lianux.mm@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=broonie@kernel.org \
--cc=david@redhat.com \
--cc=gkwang@linx-info.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=p1ucky0923@gmail.com \
--cc=ryncsn@gmail.com \
--cc=shuah@kernel.org \
--cc=sj@kernel.org \
--cc=vbabka@suse.cz \
--cc=zijing.zhang@proton.me \
--cc=ziy@nvidia.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