linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: wang lian <lianux.mm@gmail.com>,
	akpm@linux-foundation.org, broonie@kernel.org,
	lorenzo.stoakes@oracle.com, sj@kernel.org, ziy@nvidia.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: brauner@kernel.org, gkwang@linx-info.com, jannh@google.com,
	Liam.Howlett@oracle.com, ludovico.zy.wu@gmail.com,
	p1ucky0923@gmail.com, richard.weiyang@gmail.com,
	ryncsn@gmail.com, shuah@kernel.org, vbabka@suse.cz,
	zijing.zhang@proton.me
Subject: Re: [PATCH 1/2] selftests/mm: refactor common code and improve test skipping in guard_region
Date: Thu, 17 Jul 2025 13:44:12 +0200	[thread overview]
Message-ID: <2fdacd57-2314-47c7-9eeb-6928221ce516@redhat.com> (raw)
In-Reply-To: <20250717112407.13507-2-lianux.mm@gmail.com>

On 17.07.25 13:24, 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>
> 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");
>   
>   	/* 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)
> +
>   extern unsigned int __page_size;
>   extern unsigned int __page_shift;
>   

The FORCE_READ() stuff belongs into patch #2.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-07-17 11:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 11:24 [PATCH v2 0/2] selftests/mm: reuse FORCE_READ to replace "asm volatile("" : "+r" (XXX));" wang lian
2025-07-17 11:24 ` [PATCH 1/2] selftests/mm: refactor common code and improve test skipping in guard_region wang lian
2025-07-17 11:44   ` David Hildenbrand [this message]
2025-07-17 12:09     ` wang lian
2025-07-17 11:24 ` [PATCH 2/2] selftests/mm: reuse FORCE_READ to replace "asm volatile("" : "+r" (XXX));" 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=2fdacd57-2314-47c7-9eeb-6928221ce516@redhat.com \
    --to=david@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=broonie@kernel.org \
    --cc=gkwang@linx-info.com \
    --cc=jannh@google.com \
    --cc=lianux.mm@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=ludovico.zy.wu@gmail.com \
    --cc=p1ucky0923@gmail.com \
    --cc=richard.weiyang@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