On Mon, Jun 08, 2020 at 03:23:22PM -0700, Luigi Semenzato wrote: > Hi Andrea, > > 1. This mechanism is quite general. It is possible that, although > hibernation may be an important use, there will be other uses for it. > I suggest leaving the hibernation example and performance analysis, > but not mentioning PM or hibernation in the patch subject. I was actually thinking to make this feature even more generic, since there might be other potential users of this forced "memory reclaim" feature outside hibernation. So, instead of adding the new sysfs files under /sys/power/mm_reclaim/, maybe move them to /sys/kernel/mm/ (since it's more like a mm feature, rather than a PM/hibernation feature). > > 2. It may be useful to have run_show() return the number of pages > reclaimed in the last attempt. (I had suggested something similar in > https://lore.kernel.org/linux-mm/CAA25o9SxajRaa+ZyhvTYdaKdXokcrNYXgEUimax4sUJGCmRYLA@xxxxxxxxxxxxxx/). I like this idea, I'll add that in the next version. > > 3. It is not clear how much mm_reclaim/release is going to help. If > the preloading of the swapped-out pages uses some kind of LIFO order, > and can batch multiple pages, then it might help. Otherwise demand > paging is likely to be more effective. If the preloading does indeed > help, it may be useful to explain why in the commit message. Swap readahead helps a lot in terms of performance if we preload all at once. But I agree that for the majority of cases on-demand paging just works fine. My specific use-case for mm_reclaim/release is to make sure a VM that is just resumed is immediately "fast" by preloading the swapped-out pages back to memory all at once. Without mm_reclaim/release I've been using the trick of running swapoff followed by a swapon to force all the pages back to memory, but it's kinda ugly and I was looking for a better way to do this. I've been trying also the ptrace() + reading all the VMAs via /proc/pid/mem, it works, but it's not as fast as swapoff+swapon or mm_reclaim/release. I'll report performance numbers of mm_reclaim/release vs ptrace() + /proc/pid/mem in the next version of this patch. > > Thanks! Thanks for your review! -Andrea