[PATCH] x86: use round_jiffies() for the corruption check timer

Previous thread: [PATCH] [RFC] tracehook: Hook in syscall tracing markers. by Paul Mundt on Saturday, September 20, 2008 - 7:16 pm. (6 messages)

Next thread: none
From: Arjan van de Ven
Date: Saturday, September 20, 2008 - 8:35 pm

From: Arjan van de Ven <arjan@linux.intel.com>
Date: Sat, 20 Sep 2008 20:32:43 -0700
Subject: [PATCH] x86: use round_jiffies() for the corruption check timer

the exact timing of the corruption check isn't too important (it's once a
minute timer), use round_jiffies() to align it and avoid extra wakeups.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
CC: Hugh Dickins <hugh@veritas.com>
CC: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/kernel/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d5bd679..a9998cb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -715,7 +715,7 @@ void check_for_bios_corruption(void)
 static void periodic_check_for_corruption(unsigned long data)
 {
 	check_for_bios_corruption();
-	mod_timer(&periodic_check_timer, jiffies + corruption_check_period*HZ);
+	mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
 }
 
 void start_periodic_check_for_corruption(void)
-- 
1.5.5.1



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--

From: Ingo Molnar
Date: Monday, September 22, 2008 - 1:29 am

applied to tip/x86/memory-corruption-check, thanks Arjan!

	Ingo
--

From: Arjan van de Ven
Date: Monday, September 22, 2008 - 2:04 pm

From: Arjan van de Ven <arjan@linux.intel.com>
Date: Mon, 22 Sep 2008 09:35:06 -0700
Subject: [PATCH] corruption check: move the corruption checks into their own file

The corruption check code is rather sizable and it's likely to grow over time when
we add checks for more types of corruptions (there's a few candidates in kerneloops.org
that I want to add checks for)... so lets move it to its own file

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>

---
 arch/x86/kernel/Makefile          |    1 +
 arch/x86/kernel/corruptioncheck.c |  156 +++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/setup.c           |  151 -----------------------------------
 include/asm-x86/setup.h           |    4 +
 4 files changed, 161 insertions(+), 151 deletions(-)
 create mode 100644 arch/x86/kernel/corruptioncheck.c

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 8db0877..29f9ef2 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -36,6 +36,7 @@ obj-y			+= bootflag.o e820.o
 obj-y			+= pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
 obj-y			+= alternative.o i8253.o pci-nommu.o
 obj-y			+= tsc.o io_delay.o rtc.o
+obj-y			+= corruptioncheck.o
 
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline.o
 obj-y				+= process.o
diff --git a/arch/x86/kernel/corruptioncheck.c b/arch/x86/kernel/corruptioncheck.c
new file mode 100644
index 0000000..a7e80ed
--- /dev/null
+++ b/arch/x86/kernel/corruptioncheck.c
@@ -0,0 +1,156 @@
+#include <linux/module.h>
+#include <linux/sched.h>
+
+#include <asm/e820.h>
+#include <asm/proto.h>
+
+/*
+ * Some BIOSes seem to corrupt the low 64k of memory during events
+ * like suspend/resume and unplugging an HDMI cable.  Reserve all
+ * remaining free memory in that area and fill it with a distinct
+ * pattern.
+ */
+#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
+#define MAX_SCAN_AREAS	8
+
+static int __read_mostly memory_corruption_check = -1;
+
+static unsigned __read_mostly corruption_check_size = ...
From: Arjan van de Ven
Date: Monday, September 22, 2008 - 2:05 pm

From: Arjan van de Ven <arjan@linux.intel.com>
Date: Mon, 22 Sep 2008 13:42:15 -0700
Subject: [PATCH] corruption check: run the corruption checks from a work queue

the corruption checks are better off run from a work queue; there's nothing
time critical about them and this way the amount of interrupt-context work
is reduced (including interrupt latency)

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 arch/x86/kernel/corruptioncheck.c |   21 +++++++++++++++++----
 arch/x86/mm/init_32.c             |    2 --
 arch/x86/mm/init_64.c             |    2 --
 include/linux/kernel.h            |    2 +-
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/corruptioncheck.c b/arch/x86/kernel/corruptioncheck.c
index a7e80ed..cd89219 100644
--- a/arch/x86/kernel/corruptioncheck.c
+++ b/arch/x86/kernel/corruptioncheck.c
@@ -1,5 +1,6 @@
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/kthread.h>
 
 #include <asm/e820.h>
 #include <asm/proto.h>
@@ -135,22 +136,34 @@ void check_for_bios_corruption(void)
 	WARN(corruption, KERN_ERR "Memory corruption detected in low memory\n");
 }
 
-static void periodic_check_for_corruption(unsigned long data)
+static void check_corruption(struct work_struct *dummy)
 {
 	check_for_bios_corruption();
+}
+
+static void periodic_check_for_corruption(unsigned long data)
+{
+	static DECLARE_WORK(corruptioncheck_work, check_corruption);
+	schedule_work(&corruptioncheck_work);
 	mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
 }
 
-void start_periodic_check_for_corruption(void)
+
+
+int start_periodic_check_for_corruption(void)
 {
 	if (!memory_corruption_check || corruption_check_period == 0)
-		return;
+		return 0;
 
 	printk(KERN_INFO "Scanning for low memory corruption every %d seconds\n",
 	       corruption_check_period);
 
 	init_timer(&periodic_check_timer);
 	periodic_check_timer.function = ...
From: Arjan van de Ven
Date: Monday, September 22, 2008 - 4:24 pm

eh a stray debug // snuck in; update attached


From: Arjan van de Ven <arjan@linux.intel.com>
Date: Mon, 22 Sep 2008 13:42:15 -0700
Subject: [PATCH] corruption check: run the corruption checks from a work queue

the corruption checks are better off run from a work queue; there's nothing
time critical about them and this way the amount of interrupt-context work
is reduced.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 arch/x86/kernel/corruptioncheck.c |   21 +++++++++++++++++----
 arch/x86/mm/init_32.c             |    2 --
 arch/x86/mm/init_64.c             |    2 --
 include/linux/kernel.h            |    2 +-
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/corruptioncheck.c b/arch/x86/kernel/corruptioncheck.c
index a7e80ed..cd89219 100644
--- a/arch/x86/kernel/corruptioncheck.c
+++ b/arch/x86/kernel/corruptioncheck.c
@@ -1,5 +1,6 @@
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/kthread.h>
 
 #include <asm/e820.h>
 #include <asm/proto.h>
@@ -135,22 +136,34 @@ void check_for_bios_corruption(void)
 	WARN(corruption, KERN_ERR "Memory corruption detected in low memory\n");
 }
 
-static void periodic_check_for_corruption(unsigned long data)
+static void check_corruption(struct work_struct *dummy)
 {
 	check_for_bios_corruption();
+}
+
+static void periodic_check_for_corruption(unsigned long data)
+{
+	static DECLARE_WORK(corruptioncheck_work, check_corruption);
+	schedule_work(&corruptioncheck_work);
 	mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
 }
 
-void start_periodic_check_for_corruption(void)
+
+
+int start_periodic_check_for_corruption(void)
 {
 	if (!memory_corruption_check || corruption_check_period == 0)
-		return;
+		return 0;
 
 	printk(KERN_INFO "Scanning for low memory corruption every %d seconds\n",
 	       corruption_check_period);
 
 	init_timer(&periodic_check_timer);
 	periodic_check_timer.function = ...
From: Randy.Dunlap
Date: Monday, September 22, 2008 - 4:28 pm

In that case, patch 1/2 contains "for(" and "while(".  :(

-- 
~Randy
--

From: Arjan van de Ven
Date: Monday, September 22, 2008 - 4:39 pm

On Mon, 22 Sep 2008 16:28:23 -0700 (PDT)

that's a dillema case.
I'm just moving code around in patch 1/2; I personally consider it bad
form to also change it at the same time.....

(and it confuses git change tracking)

-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--

From: Ingo Molnar
Date: Tuesday, September 23, 2008 - 4:33 am

correct. The right solution in this case (where code is moved around) to 
do a separate patch for the style errors Randy reported, once the code 
has been moved over.

	Ingo
--

Previous thread: [PATCH] [RFC] tracehook: Hook in syscall tracing markers. by Paul Mundt on Saturday, September 20, 2008 - 7:16 pm. (6 messages)

Next thread: none