- Declare that the test needs 4 GB of memory so it can be automatically skipped on systems with low memory.
- Switch back to mmap() as in my initial prototype. Using malloc() is simpler, but on systems with malloc debugging enabled, malloc() will prefault the entire buffer, resulting in a false positive. Using mmap() also guarantees that the buffer is page-aligned, which renders the test determinstic: we now only need to prefault exactly 2 GB, and the difference between ret and len will be exactly the amount that we prefaulted.
- To prefault the buffer, instead of a simple loop that writes zeroes to it, which a compiler might recognize as dead stores and eliminate, read the first INT_MAX bytes from the file into it.
PR: 298159
Fixes: ba02bbbe86ae ("tests: Add test for vn_io_fault1 bug")