On Tue, Feb 27, 2024 at 07:32:32AM -0800, Paul E. McKenney wrote: > At a ridiculously high level, reclaim is looking for memory to free. > Some read-only memory can often be dropped immediately on the grounds > that its data can be read back in if needed. Other memory can only be > dropped after being written out, which involves a delay. There are of > course many other complications, but this will do for a start. Hi Paul, I appreciate the necessity of describing what's going on at a very high level, but there's a wrinkle that I'm not sure you're aware of which may substantially change your argument. For anonymous memory, we do indeed wait until reclaim to start writing it to swap. That may or may not be the right approach given how anonymous memory is used (and could be the topic of an interesting discussion at LSFMM). For file-backed memory, we do not write back memory in reclaim. If it has got to the point of calling ->writepage in vmscan, things have gone horribly wrong to the point where calling ->writepage will make things worse. This is why we're currently removing ->writepage from every filesystem (only ->writepages will remain). Instead, the page cache is written back much earlier, once we get to balance_dirty_pages(). That lets us write pages in filesystem-friendly ways instead of in MM LRU order.