Skip to content

Commit c6f37f1

Browse files
committed
PM/Suspend: Do not shrink memory before suspend
Remove the shrinking of memory from the suspend-to-RAM code, where it is not really necessary. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Nigel Cunningham <nigel@tuxonice.net> Acked-by: Wu Fengguang <fengguang.wu@intel.com>
1 parent e240b58 commit c6f37f1

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

‎kernel/power/main.c‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ static void suspend_test_finish(const char *label)
188188

189189
#endif
190190

191-
/* This is just an arbitrary number */
192-
#define FREE_PAGE_NUMBER (100)
193-
194191
static struct platform_suspend_ops *suspend_ops;
195192

196193
/**
@@ -226,7 +223,6 @@ int suspend_valid_only_mem(suspend_state_t state)
226223
static int suspend_prepare(void)
227224
{
228225
int error;
229-
unsigned int free_pages;
230226

231227
if (!suspend_ops || !suspend_ops->enter)
232228
return -EPERM;
@@ -241,24 +237,10 @@ static int suspend_prepare(void)
241237
if (error)
242238
goto Finish;
243239

244-
if (suspend_freeze_processes()) {
245-
error = -EAGAIN;
246-
goto Thaw;
247-
}
248-
249-
free_pages = global_page_state(NR_FREE_PAGES);
250-
if (free_pages < FREE_PAGE_NUMBER) {
251-
pr_debug("PM: free some memory\n");
252-
shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
253-
if (nr_free_pages() < FREE_PAGE_NUMBER) {
254-
error = -ENOMEM;
255-
printk(KERN_ERR "PM: No enough memory\n");
256-
}
257-
}
240+
error = suspend_freeze_processes();
258241
if (!error)
259242
return 0;
260243

261-
Thaw:
262244
suspend_thaw_processes();
263245
usermodehelper_enable();
264246
Finish:

‎mm/vmscan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,7 @@ unsigned long global_lru_pages(void)
20562056
+ global_page_state(NR_INACTIVE_FILE);
20572057
}
20582058

2059-
#ifdef CONFIG_PM
2059+
#ifdef CONFIG_HIBERNATION
20602060
/*
20612061
* Helper function for shrink_all_memory(). Tries to reclaim 'nr_pages' pages
20622062
* from LRU lists system-wide, for given pass and priority.
@@ -2196,7 +2196,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
21962196

21972197
return sc.nr_reclaimed;
21982198
}
2199-
#endif
2199+
#endif /* CONFIG_HIBERNATION */
22002200

22012201
/* It's optimal to keep kswapds on the same CPUs as their memory, but
22022202
not required for correctness. So if the last cpu in a node goes

0 commit comments

Comments
 (0)