lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 2 May 2009 00:27:30 +0200
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	pavel@....cz, torvalds@...ux-foundation.org, jens.axboe@...cle.com,
	alan-jenkins@...fmail.co.uk, linux-kernel@...r.kernel.org,
	kernel-testers@...r.kernel.org,
	pm list <linux-pm@...ts.linux-foundation.org>
Subject: [PATCH 1/3] PM: Disable OOM killer during system-wide power transitions

From: Rafael J. Wysocki <rjw@...k.pl>

The OOM killer is not particularly useful during system-wide power
transitions, so do not use it if such a transition is in progress.

Signed-off-by: Rafael J. Wysocki <rjw@...k.pl>
---
 include/linux/suspend.h |    4 ++++
 kernel/power/disk.c     |   13 ++++++++++++-
 kernel/power/main.c     |   13 +++++++++++++
 kernel/power/power.h    |    1 +
 mm/page_alloc.c         |    8 ++++++--
 5 files changed, 36 insertions(+), 3 deletions(-)

Index: linux-2.6/include/linux/suspend.h
===================================================================
--- linux-2.6.orig/include/linux/suspend.h
+++ linux-2.6/include/linux/suspend.h
@@ -282,6 +282,8 @@ extern int unregister_pm_notifier(struct
 		{ .notifier_call = fn, .priority = pri };	\
 	register_pm_notifier(&fn##_nb);			\
 }
+
+extern bool pm_transition_in_progress(void);
 #else /* !CONFIG_PM_SLEEP */
 
 static inline int register_pm_notifier(struct notifier_block *nb)
@@ -295,6 +297,8 @@ static inline int unregister_pm_notifier
 }
 
 #define pm_notifier(fn, pri)	do { (void)(fn); } while (0)
+
+static inline bool pm_transition_in_progress(void) { return false; }
 #endif /* !CONFIG_PM_SLEEP */
 
 #ifndef CONFIG_HIBERNATION
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -1619,8 +1619,12 @@ nofail_alloc:
 			goto got_pg;
 		}
 
-		/* The OOM killer will not help higher order allocs so fail */
-		if (order > PAGE_ALLOC_COSTLY_ORDER) {
+		/*
+		 * The OOM killer will not help higher order allocs and it is
+		 * not useful during system-wide power transitions, so fail.
+		 */
+		if (order > PAGE_ALLOC_COSTLY_ORDER
+		    || pm_transition_in_progress()) {
 			clear_zonelist_oom(zonelist, gfp_mask);
 			goto nopage;
 		}
Index: linux-2.6/kernel/power/disk.c
===================================================================
--- linux-2.6.orig/kernel/power/disk.c
+++ linux-2.6/kernel/power/disk.c
@@ -299,9 +299,11 @@ int hibernation_snapshot(int platform_mo
 {
 	int error;
 
+	transition_in_progress = true;
+
 	error = platform_begin(platform_mode);
 	if (error)
-		return error;
+		goto Out;
 
 	/* Free memory before shutting down devices. */
 	error = swsusp_shrink_memory();
@@ -325,6 +327,9 @@ int hibernation_snapshot(int platform_mo
 	resume_console();
  Close:
 	platform_end(platform_mode);
+
+ Out:
+	transition_in_progress = false;
 	return error;
 
  Recover_platform:
@@ -607,6 +612,7 @@ int hibernate(void)
 		pr_debug("PM: Image restored successfully.\n");
 		swsusp_free();
 	}
+
  Thaw:
 	thaw_processes();
  Finish:
@@ -724,6 +730,8 @@ static int software_resume(void)
 		goto Done;
 	}
 
+	transition_in_progress = true;
+
 	pr_debug("PM: Reading hibernation image.\n");
 
 	error = swsusp_read(&flags);
@@ -732,6 +740,9 @@ static int software_resume(void)
 
 	printk(KERN_ERR "PM: Restore failed, recovering.\n");
 	swsusp_free();
+
+	transition_in_progress = false;
+
 	thaw_processes();
  Done:
 	free_basic_memory_bitmaps();
Index: linux-2.6/kernel/power/main.c
===================================================================
--- linux-2.6.orig/kernel/power/main.c
+++ linux-2.6/kernel/power/main.c
@@ -32,6 +32,13 @@ EXPORT_SYMBOL(pm_flags);
 
 #ifdef CONFIG_PM_SLEEP
 
+bool transition_in_progress;
+
+bool pm_transition_in_progress(void)
+{
+	return transition_in_progress;
+}
+
 /* Routines for PM-transition notifications */
 
 static BLOCKING_NOTIFIER_HEAD(pm_chain_head);
@@ -246,6 +253,8 @@ static int suspend_prepare(void)
 		goto Thaw;
 	}
 
+	transition_in_progress = true;
+
 	free_pages = global_page_state(NR_FREE_PAGES);
 	if (free_pages < FREE_PAGE_NUMBER) {
 		pr_debug("PM: free some memory\n");
@@ -258,6 +267,8 @@ static int suspend_prepare(void)
 	if (!error)
 		return 0;
 
+	transition_in_progress = false;
+
  Thaw:
 	suspend_thaw_processes();
 	usermodehelper_enable();
@@ -403,6 +414,8 @@ int suspend_devices_and_enter(suspend_st
  */
 static void suspend_finish(void)
 {
+	transition_in_progress = false;
+
 	suspend_thaw_processes();
 	usermodehelper_enable();
 	pm_notifier_call_chain(PM_POST_SUSPEND);
Index: linux-2.6/kernel/power/power.h
===================================================================
--- linux-2.6.orig/kernel/power/power.h
+++ linux-2.6/kernel/power/power.h
@@ -173,6 +173,7 @@ static inline int suspend_devices_and_en
 #ifdef CONFIG_PM_SLEEP
 /* kernel/power/main.c */
 extern int pm_notifier_call_chain(unsigned long val);
+extern bool transition_in_progress;
 #endif
 
 #ifdef CONFIG_HIGHMEM
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ