linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: wang lian <lianux.mm@gmail.com>
To: akpm@linux-foundation.org
Cc: Liam.Howlett@oracle.com, brauner@kernel.org, broonie@kernel.org,
	david@redhat.com, gkwang@linx-info.com, jannh@google.com,
	lianux.mm@gmail.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, lorenzo.stoakes@oracle.com,
	ludovico.zy.wu@gmail.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] selftests/mm: reuse FORCE_READ to replace "asm volatile("" : "+r" (XXX));"
Date: Thu, 17 Jul 2025 18:48:11 +0800	[thread overview]
Message-ID: <20250717104811.3773-1-lianux.mm@gmail.com> (raw)
In-Reply-To: <20250716151543.998b121a58064011e9ce68cb@linux-foundation.org>

> On Wed, 16 Jul 2025 20:31:26 +0800 wang lian <lianux.mm@gmail.com> wrote:

> > Several mm selftests use the `asm volatile("" : "+r" (variable));`
> > construct to force a read of a variable, preventing the compiler from
> > optimizing away the memory access. This idiom is cryptic and duplicated
> > across multiple test files.
> >
> > Following a suggestion from David[1], this patch refactors this
> > common pattern into a FORCE_READ() macro
> > 
> >  tools/testing/selftests/mm/cow.c              | 30 +++++++++----------
> >  tools/testing/selftests/mm/hugetlb-madvise.c  |  5 +---
> >  tools/testing/selftests/mm/migration.c        | 13 ++++----
> >  tools/testing/selftests/mm/pagemap_ioctl.c    |  4 +--
> >  .../selftests/mm/split_huge_page_test.c       |  4 +--
> >  5 files changed, 24 insertions(+), 32 deletions(-)

> The patch forgot to move the FORCE_READ definition into a header?

Hi Andrew,
You are absolutely right. My apologies for the inconvenience.
This patch was sent standalone based on a suggestion from David during 
the discussion of a previous, larger patch series. In that original series, 
I had already moved the FORCE_READ() macro definition into vm_util.h.

You can find the original patch series and discussion at this link:
https://lore.kernel.org/lkml/20250714130009.14581-1-lianux.mm@gmail.com/
It should also be in your mailing list archive.

To make this easier to review and apply, I can send a new, small patch series 
that first introduces the FORCE_READ() macro in vm_util.h and then applies this refactoring. 
Please let me know if you'd prefer that.
Sorry again for the confusion.


Best regards,
wang lian


  parent reply	other threads:[~2025-07-17 10:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16 12:31 [PATCH] selftests/mm: reuse FORCE_READ to replace "asm volatile("" : "+r" (XXX));" wang lian
2025-07-16 13:16 ` David Hildenbrand
2025-07-16 22:15 ` Andrew Morton
2025-07-17  6:58   ` Wei Yang
2025-07-17 10:48   ` wang lian [this message]
2025-07-17 11:43     ` David Hildenbrand
2025-07-19  9:27       ` David Laight
2025-07-20  9:23         ` Lorenzo Stoakes
2025-07-20 11:03           ` 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=20250717104811.3773-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-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=ludovico.zy.wu@gmail.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;
as well as URLs for NNTP newsgroup(s).