The fair zone allocation policy interleaves allocation requests between
zones to avoid an age inversion problem whereby new pages are reclaimed
to balance a zone.
Get rid of this complexity when tasks are frozen during hibernation.
This allows to improve hibernation performance and reduce the risk of
OOMs.
Signed-off-by: Andrea Righi <email address hidden>
Signed-off-by: Kamal Mostafa <email address hidden>
If the size of the image created when hibernating is bigger than
image_size the kernel will try to reduce the size of the image. This can
slow down hibernation consistenly, so setting image_size to the total
amount of RAM by default ensures that the kernel doesn't waste time to
reduce the image, making hibernation faster.
Signed-off-by: Andrea Righi <email address hidden>
When swapping out THP (Transparent Huge Pages), sometimes we have to
fallback to split the THP into normal pages before swapping, because no
free swap clusters are available. This can make hibernation really slow
under memory pressure, so disable transparent huge pages by default.
Signed-off-by: Andrea Righi <email address hidden>
5919dde...
by
"Rafael J. Wysocki" <email address hidden>
Rework mark_unsafe_pages() to use a simpler method of clearing
all bits in free_pages_map and to set the bits for the "unsafe"
pages (ie. pages that were used by the image kernel before
hibernation) with the help of duplicate_memory_bitmap().
For this purpose, move the pfn_valid() check from mark_unsafe_pages()
to unpack_orig_pfns() where the "unsafe" pages are discovered.
Signed-off-by: Rafael J. Wysocki <email address hidden>
(cherry picked from commit 6dbecfd345a617888da370b13d5b190c9ff3df53)
Signed-off-by: Andrea Righi <email address hidden>
351f176...
by
"Rafael J. Wysocki" <email address hidden>
PM / hibernate: Recycle safe pages after image restoration
One of the memory bitmaps used by the hibernation image restoration
code is freed after the image has been loaded.
That is not quite efficient, though, because the memory pages used
for building that bitmap are known to be safe (ie. they were not
used by the image kernel before hibernation) and the arch-specific
code finalizing the image restoration may need them. In that case
it needs to allocate those pages again via the memory management
subsystem, check if they are really safe again by consulting the
other bitmaps and so on.
To avoid that, recycle those pages by putting them into the global
list of known safe pages so that they can be given to the arch code
right away when necessary.
Signed-off-by: Rafael J. Wysocki <email address hidden>
(cherry picked from commit 307c5971c972ef2bfd541d2850b36a692c6354c9)
Signed-off-by: Andrea Righi <email address hidden>
ef3b63d...
by
"Rafael J. Wysocki" <email address hidden>
PM / hibernate: Do not free preallocated safe pages during image restore
The core image restoration code preallocates some safe pages
(ie. pages that weren't used by the image kernel before hibernation)
for future use before allocating the bulk of memory for loading the
image data. Those safe pages are then freed so they can be allocated
again (with the memory management subsystem's help). That's done to
ensure that there will be enough safe pages for temporary data
structures needed during image restoration.
However, it is not really necessary to free those pages after they
have been allocated. They can be added to the (global) list of
safe pages right away and then picked up from there when needed
without freeing.
That reduces the overhead related to using safe pages, especially
in the arch-specific code, so modify the code accordingly.
Signed-off-by: Rafael J. Wysocki <email address hidden>
(cherry picked from commit 9c744481c003697de453e8fc039468143ba604aa)
Signed-off-by: Andrea Righi <email address hidden>