[lkml]   [2006]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[Suspend2][ 04/20] [Suspend2] Calculate pagedir1 growth allowance.
While writing the LRU, and (more importantly) as a result of suspending the
drivers, the amount of memory needed for the atomic copy may increase
significantly. This amount is always predictable - LRU I/O will only ever
get a few more slab pages allocated, and drivers suspend and resume will
allocate a fixed number. The problem is that most drivers use virtually
nothing, so that the default allowance of 100 pages is ample. NVidia
drivers especially, however, allocate thousands of pages in some
configurations, so we need a way for the user to be able to tune or
autotune this value.

This routine provides a method for autotuning. If the allowance is set to
zero, this routine will be invoked, determining how much extra memory will
be allocated by the drivers when the real call is made later. We can then
take that, plus our normal 100 page allowance, as the value to use.

Signed-off-by: Nigel Cunningham <>

kernel/power/prepare_image.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index cb1a3da..271f904 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -81,3 +81,29 @@ long real_nr_free_pages(void)
return nr_free_pages() + num_pcp_pages();

+ * Discover how much extra memory will be required by the drivers
+ * when they're asked to suspend. We can then ensure that amount
+ * of memory is available when we really want it.
+ */
+static void get_extra_pd1_allowance(void)
+ int orig_num_free = real_nr_free_pages(), final;
+ suspend_prepare_status(CLEAR_BAR, "Finding allowance for drivers.");
+ device_suspend(PMSG_FREEZE);
+ local_irq_disable(); /* irqs might have been re-enabled on us */
+ device_power_down(PMSG_FREEZE);
+ final = real_nr_free_pages();
+ device_power_up();
+ local_irq_enable();
+ device_resume();
+ extra_pd1_pages_allowance = max(
+ orig_num_free - final + MIN_EXTRA_PAGES_ALLOWANCE,
Nigel Cunningham nigel at suspend2 dot net
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-06-27 01:37    [W:0.169 / U:6.044 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site