Re: [PATCH v1] selftests/mm: add simple VM_PFNMAP tests based on mmap'ing /dev/mem

From: David Hildenbrand
Date: Fri May 09 2025 - 06:44:02 EST


Is this not pretty much equivalent to a volatile read where you're forcing
the compiler to not optimise this unused thing away? In guard-regions I set:

#define FORCE_READ(x) (*(volatile typeof(x) *)x)

For this purpose, which would make this:

FORCE_READ(addr);
FORCE_READ(&addr[pagesize]);

Hmmm, a compiler might be allowed to optimize out a volatile read.

Looking into this, the compiler should not be allowed to do that. So FORCE_READ() should work!

--
Cheers,

David / dhildenb