Skip to contentSkip to conversation

x86: use round_jiffies() for the corruption check timer

PATCH Applied Arjan van de Ven 3 participants 8 messages Sep 21, 2008 – Sep 23, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: use round_jiffies() for the corruption check timer

From: Arjan van de Ven <[email protected]>
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.

CC Hugh Dickins <[email protected]>
CC Jeremy Fitzhardinge <[email protected]>
---
 arch/x86/kernel/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/setup.c +1 -1
index d5bd679..a9998cb 100644
@@ -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)
Signature · 8 lines
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
Applied
#1 lore raw
Quoted 11 lines · Arjan van de Ven

From: Arjan van de Ven <[email protected]>
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.

CC Hugh Dickins <[email protected]>
CC Jeremy Fitzhardinge <[email protected]>

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

Ingo

#2 lore raw

PATCH 1/2 corruption check: move the corruption checks into their own file

In reply to Arjan van de Ven

From: Arjan van de Ven <[email protected]>
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

---
 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
arch/x86/kernel/Makefile +1 -0
index 8db0877..29f9ef2 100644
@@ -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
arch/x86/kernel/corruptioncheck.c new file +156 -0

156 lines not on this page · raw message

arch/x86/kernel/setup.c +0 -151

157 lines not on this page · raw message

include/asm-x86/setup.h +4 -0
index 11b6cc1..5c55fc1 100644
@@ -8,6 +8,10 @@
 /* Interrupt control for vSMPowered x86_64 systems */
 void vsmp_init(void);
 
+
+void setup_bios_corruption_check(void);
+
+
 #ifdef CONFIG_X86_VISWS
 extern void visws_early_detect(void);
 extern int is_visws_box(void);
Signature · 1 line
1.5.5.1
#3 lore raw

PATCH 2/2 corruption check: run the corruption checks from a work queue

From: Arjan van de Ven <[email protected]>
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)

---
 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(-)
arch/x86/kernel/corruptioncheck.c +17 -4
index a7e80ed..cd89219 100644
@@ -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 = &periodic_check_for_corruption;
-	periodic_check_for_corruption(0);
+	mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
+//	periodic_check_for_corruption(0);
+	return 0;
 }
+
+module_init(start_periodic_check_for_corruption);
 #endif
arch/x86/mm/init_32.c +0 -2
index b4c3a92..16ea9d0 100644
@@ -905,8 +905,6 @@ void __init mem_init(void)
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 
-	start_periodic_check_for_corruption();
-
 #ifdef CONFIG_FLATMEM
 	BUG_ON(!mem_map);
 #endif
arch/x86/mm/init_64.c +0 -2
index b565721..b65492e 100644
@@ -822,8 +822,6 @@ void __init mem_init(void)
 {
 	long codesize, reservedpages, datasize, initsize;
 
-	start_periodic_check_for_corruption();
-
 	pci_iommu_alloc();
 
 	/* clear_bss() already clear the empty_zero_page */
include/linux/kernel.h +1 -1
index a5afee2..01085d2 100644
@@ -260,7 +260,7 @@ extern int root_mountflags;
  * able to scatter it around anywhere in the kernel.
  */
 void check_for_bios_corruption(void);
-void start_periodic_check_for_corruption(void);
+int start_periodic_check_for_corruption(void);
 #else
 static inline void check_for_bios_corruption(void)
 {
Signature · 8 lines
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
#4 lore raw

Re: [PATCH 2/2] corruption check: run the corruption checks from a work queue

eh a stray debug // snuck in; update attached

From: Arjan van de Ven <[email protected]>
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.

---
 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(-)
arch/x86/kernel/corruptioncheck.c +17 -4
index a7e80ed..cd89219 100644
@@ -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 = &periodic_check_for_corruption;
-	periodic_check_for_corruption(0);
+	mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
+
+	return 0;
 }
+
+module_init(start_periodic_check_for_corruption);
 #endif
arch/x86/mm/init_32.c +0 -2
index b4c3a92..16ea9d0 100644
@@ -905,8 +905,6 @@ void __init mem_init(void)
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 
-	start_periodic_check_for_corruption();
-
 #ifdef CONFIG_FLATMEM
 	BUG_ON(!mem_map);
 #endif
arch/x86/mm/init_64.c +0 -2
index b565721..b65492e 100644
@@ -822,8 +822,6 @@ void __init mem_init(void)
 {
 	long codesize, reservedpages, datasize, initsize;
 
-	start_periodic_check_for_corruption();
-
 	pci_iommu_alloc();
 
 	/* clear_bss() already clear the empty_zero_page */
include/linux/kernel.h +1 -1
index a5afee2..01085d2 100644
@@ -260,7 +260,7 @@ extern int root_mountflags;
  * able to scatter it around anywhere in the kernel.
  */
 void check_for_bios_corruption(void);
-void start_periodic_check_for_corruption(void);
+int start_periodic_check_for_corruption(void);
 #else
 static inline void check_for_bios_corruption(void)
 {
Signature · 8 lines
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
#5 lore raw

Re: [PATCH 2/2] corruption check: run the corruption checks from a work queue

Quoted 1 line · Arjan van de Ven

eh a stray debug // snuck in; update attached

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

Signature · 1 line
~Randy
#6 lore raw

Re: [PATCH 2/2] corruption check: run the corruption checks from a work queue

Quoted 6 lines · On Mon, 22 Sep 2008 16:28:23 -0700 (PDT) "Randy.Dunlap" <[email protected]>…
Quoted 1 line · Arjan van de Ven

eh a stray debug // snuck in; update attached

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

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)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#7 lore raw

Re: [PATCH 2/2] corruption check: run the corruption checks from a work queue

Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 22 Sep 2008 16:28:23 -0700 (PDT) "Randy.Dunlap" <[email protected]>…
Quoted 1 line · Arjan van de Ven

eh a stray debug // snuck in; update attached

Quoted 8 lines
Quoted 2 lines

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

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)

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