Skip to content

Commit 82634d7

Browse files
zhangqiang4akpm00
authored andcommitted
memtest: use {READ,WRITE}_ONCE in memory scanning
memtest failed to find bad memory when compiled with clang. So use {WRITE,READ}_ONCE to access memory to avoid compiler over optimization. Link: https://lkml.kernel.org/r/20240312080422.691222-1-qiang4.zhang@intel.com Signed-off-by: Qiang Zhang <qiang4.zhang@intel.com> Cc: Bill Wendling <morbo@google.com> Cc: Justin Stitt <justinstitt@google.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent cd197c3 commit 82634d7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

mm/memtest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static void __init memtest(u64 pattern, phys_addr_t start_phys, phys_addr_t size
5151
last_bad = 0;
5252

5353
for (p = start; p < end; p++)
54-
*p = pattern;
54+
WRITE_ONCE(*p, pattern);
5555

5656
for (p = start; p < end; p++, start_phys_aligned += incr) {
57-
if (*p == pattern)
57+
if (READ_ONCE(*p) == pattern)
5858
continue;
5959
if (start_phys_aligned == last_bad + incr) {
6060
last_bad += incr;

0 commit comments

Comments
 (0)