Here is the first attempt to provide an interface that allows user-space tasks to trigger an opportunistic memory reclaim before hibernating a system. Reclaiming memory in advance (e.g., when the system is idle) allows to reduce the size of the hibernation image and significantly speed up the time to hibernate and resume. The typical use case of this feature is to allow high-priority cloud instances to preempt low-priority instances (e.g., "spot" instances [1]) by hibernating them. Opportunistic memory reclaim is very effective to quickly hibernate instances that allocate a large chunk of memory and remain mostly idle for the majority of the time, only using a minimum working set. This topic has been mentioned during the OSPM 2020 conference [2]. See [RFC PATCH 2/2] for details about the proposed solution. Feedbacks are welcome. Thanks, -Andrea [1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html [2] https://lwn.net/Articles/821158/ ---------------------------------------------------------------- Andrea Righi (2): mm: swap: allow partial swapoff with try_to_unuse() PM: hibernate: introduce opportunistic memory reclaim Documentation/ABI/testing/sysfs-power | 38 ++++++++++++++ include/linux/swapfile.h | 8 +++ kernel/power/hibernate.c | 94 ++++++++++++++++++++++++++++++++++- mm/swapfile.c | 45 ++++++++++++++--- 4 files changed, 176 insertions(+), 9 deletions(-)