Re: [PATCH 2/2] mm: support POSIX_FADV_NOREUSE for generic fadvise handler

From: Yu Zhao
Date: Thu Dec 22 2022 - 16:37:45 EST


On Wed, Dec 21, 2022 at 11:13 PM Yuanchu Xie <yuanchu@xxxxxxxxxx> wrote:

Thanks for following up on this.

> POSIX_FADV_NOREUSE allows an application to specify that accesses to
> file data does not follow LRU and is used only once. Since 2.6.18 this
> is a no-op. We add FMODE_NOREUSE, checked in vma_has_locality to prevent
> LRU activation.

This needs to include what you plan to write on the man page.

A few questions to answer:
1. Does this flag work with accesses via FDs?
2. If there is a random or sequential file VMA, should the user choose
this flag or the VMA flag or both? Consider a) how those flags affect
readahead; b) their scopes, i.e., per VMA or per file.

Please also follow up with Jens to add this flag to fio.

Micheal reported that SVT-AV1 regressed with MGLRU, which is the only
real one [1]. The following not only fixes the regression but also
improves the baseline. Please follow up on that as well.

--- a/Source/App/EncApp/EbAppMain.c
+++ b/Source/App/EncApp/EbAppMain.c
@@ -115,6 +115,7 @@ void init_memory_file_map(EbConfig* config) {
fseeko(config->input_file, curr_loc, SEEK_SET); // seek
back to that location
#ifndef _WIN32
config->mmap.fd = fileno(config->input_file);
+ posix_fadvise(config->mmap.fd, 0, 0, POSIX_FADV_NOREUSE);
#endif
}
config->mmap.file_frame_it = 0;

[1] https://openbenchmarking.org/result/2209259-PTS-MGLRU8GB57