Re: [PATCH 1/2] selftests/mm: reuse FORCE_READ to replace "asm volatile("" : "+r" (XXX));"

From: wang lian
Date: Mon Jul 21 2025 - 07:52:13 EST


> On Thu, Jul 17, 2025 at 09:18:56PM +0800, wang lian 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
> >
> >[1] https://lore.kernel.org/lkml/4a3e0759-caa1-4cfa-bc3f-402593f1eee3@xxxxxxxxxx/
> >
> >Signed-off-by: wang lian <lianux.mm@xxxxxxxxx>
> >Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>

> Reviewed-by: Wei Yang <richard.weiyang@xxxxxxxxx>

Thanks!

> --
> Wei Yang
> Help you, Help me


Best regards,
Wang Lian