On 4/28/26 11:52, Vineet Agarwal wrote: > ftruncate() is needed before mmap(), since the file is created with > O_TRUNC and initially has size 0. Without resizing it first, mapping > and accessing the full range can go beyond EOF.
Ah, that makes sense, worth spelling it out. Indeed, we otherwise get $ sudo ./khugepaged madvise:file . Save THP and khugepaged settings... OK Allocate huge page on fault... OK Split huge PMD on MADV_DONTNEED... OK Run test: collapse_full (madvise:file) Creating ./collapse_test_file for collapse...Bus error -- Cheers, David

