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

From: Wei Yang
Date: Thu Jul 17 2025 - 20:08:47 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>

--
Wei Yang
Help you, Help me