From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: wang lian <lianux.mm@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mark Brown <broonie@kernel.org>,
David Hildenbrand <david@redhat.com>,
SeongJae Park <sj@kernel.org>, Zi Yan <ziy@nvidia.com>,
linux-kernel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>,
Jann Horn <jannh@google.com>,
Liam Howlett <Liam.Howlett@oracle.com>,
Shuah Khan <shuah@kernel.org>, Vlastimil Babka <vbabka@suse.cz>,
gkwang <gkwang@linx-info.com>, p1ucky0923 <p1ucky0923@gmail.com>,
ryncsn <ryncsn@gmail.com>,
"zijing . zhang" <zijing.zhang@proton.me>,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] selftests/mm: refactor common code and improve test skipping in guard_region
Date: Mon, 14 Jul 2025 15:20:08 +0100 [thread overview]
Message-ID: <1efa2f5a-d93f-439a-9363-ff3a24a5e209@lucifer.local> (raw)
In-Reply-To: <20250714130009.14581-1-lianux.mm@gmail.com>
On Mon, Jul 14, 2025 at 09:00:09PM +0800, wang lian wrote:
> Move the generic `FORCE_READ` macro from `guard-regions.c` to the shared
> `vm_util.h` header to promote code reuse.
>
> In `guard-regions.c`, replace `ksft_exit_skip()` with the `SKIP()` macro
> to ensure only the current test is skipped on permission failure, instead
> of terminating the entire test binary.
>
> Signed-off-by: wang lian <lianux.mm@gmail.com>
LGTM, so:
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> tools/testing/selftests/mm/guard-regions.c | 9 +--------
> tools/testing/selftests/mm/vm_util.h | 7 +++++++
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
> index 93af3d3760f9..b0d42eb04e3a 100644
> --- a/tools/testing/selftests/mm/guard-regions.c
> +++ b/tools/testing/selftests/mm/guard-regions.c
> @@ -35,13 +35,6 @@
> static volatile sig_atomic_t signal_jump_set;
> static sigjmp_buf signal_jmp_buf;
>
> -/*
> - * Ignore the checkpatch warning, we must read from x but don't want to do
> - * anything with it in order to trigger a read page fault. We therefore must use
> - * volatile to stop the compiler from optimising this away.
> - */
> -#define FORCE_READ(x) (*(volatile typeof(x) *)x)
> -
> /*
> * How is the test backing the mapping being tested?
> */
> @@ -582,7 +575,7 @@ TEST_F(guard_regions, process_madvise)
>
> /* OK we don't have permission to do this, skip. */
> if (count == -1 && errno == EPERM)
> - ksft_exit_skip("No process_madvise() permissions, try running as root.\n");
> + SKIP(return, "No process_madvise() permissions, try running as root.\n");
Lol oops! :P yes thi is better.
>
> /* Returns the number of bytes advised. */
> ASSERT_EQ(count, 6 * page_size);
> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
> index 2b154c287591..c20298ae98ea 100644
> --- a/tools/testing/selftests/mm/vm_util.h
> +++ b/tools/testing/selftests/mm/vm_util.h
> @@ -18,6 +18,13 @@
> #define PM_SWAP BIT_ULL(62)
> #define PM_PRESENT BIT_ULL(63)
>
> +/*
> + * Ignore the checkpatch warning, we must read from x but don't want to do
> + * anything with it in order to trigger a read page fault. We therefore must use
> + * volatile to stop the compiler from optimising this away.
> + */
> +#define FORCE_READ(x) (*(volatile typeof(x) *)x)
> +
Cool makes sense to share this.
If this contradicts previous review, take this review to be the correct one
:P
> extern unsigned int __page_size;
> extern unsigned int __page_shift;
>
> --
> 2.43.0
>
prev parent reply other threads:[~2025-07-14 14:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 13:00 wang lian
2025-07-14 13:39 ` Mark Brown
2025-07-14 13:44 ` David Hildenbrand
2025-07-14 14:21 ` Lorenzo Stoakes
2025-07-15 11:05 ` wang lian
2025-07-14 14:20 ` Lorenzo Stoakes [this message]
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=1efa2f5a-d93f-439a-9363-ff3a24a5e209@lucifer.local \
--to=lorenzo.stoakes@oracle.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=lianux.mm@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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