[PATCH] kmemcheck: custom queue size and overflow detection

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vegard Nossum
Date: Thursday, May 8, 2008 - 11:56 am

Hi,

This is also missing from x86.git. Thanks.

Vegard


From 7966e04efed4c52bc0d09e8aa5ae47e9aa225a6a Mon Sep 17 00:00:00 2001
From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Thu, 1 May 2008 19:26:06 +0200
Subject: [PATCH] kmemcheck: custom queue size and overflow detection

Add an option to Kconfig to set the size of the queue/buffer which
kmemcheck uses to report errors. Also keep count on how many times this
buffer was overflowed (e.g. the number of "lost reports") so this can be
printed as well.

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
 arch/x86/Kconfig.debug      |   11 +++++++++++
 arch/x86/kernel/kmemcheck.c |   14 ++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 5d3e83a..255d054 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -287,6 +287,17 @@ config KMEMCHECK_ONESHOT_BY_DEFAULT
 
 endchoice
 
+config KMEMCHECK_QUEUE_SIZE
+	int "kmemcheck: error queue size"
+	depends on KMEMCHECK
+	default 64
+	help
+	  Select the maximum number of errors to store in the queue. This
+	  queue will be emptied once every second, so this is effectively a
+	  limit on how many reports to print in one go. Note however, that
+	  if the number of errors occuring between two bursts is larger than
+	  this number, the extra error reports will get lost.
+
 config KMEMCHECK_PARTIAL_OK
 	bool "kmemcheck: allow partially uninitialized memory"
 	depends on KMEMCHECK
diff --git a/arch/x86/kernel/kmemcheck.c b/arch/x86/kernel/kmemcheck.c
index 408ba6d..ebdbe20 100644
--- a/arch/x86/kernel/kmemcheck.c
+++ b/arch/x86/kernel/kmemcheck.c
@@ -61,10 +61,11 @@ struct kmemcheck_error {
  * from the kmemcheck traps, since this may call the console drivers and
  * result in a recursive fault.
  */
-static struct kmemcheck_error error_fifo[32];
+static struct kmemcheck_error error_fifo[CONFIG_KMEMCHECK_QUEUE_SIZE];
 static unsigned int error_count;
 static unsigned int error_rd;
 static unsigned int error_wr;
+static unsigned int error_missed_count;
 
 static struct timer_list kmemcheck_timer;
 
@@ -73,8 +74,10 @@ error_next_wr(void)
 {
 	struct kmemcheck_error *e;
 
-	if (error_count == ARRAY_SIZE(error_fifo))
+	if (error_count == ARRAY_SIZE(error_fifo)) {
+		++error_missed_count;
 		return NULL;
+	}
 
 	e = &error_fifo[error_wr];
 	if (++error_wr == ARRAY_SIZE(error_fifo))
@@ -194,6 +197,13 @@ do_wakeup(unsigned long data)
 {
 	while (error_count > 0)
 		error_recall();
+
+	if (error_missed_count > 0) {
+		printk(KERN_WARNING "kmemcheck: Lost %d error reports because "
+			"the queue was too small\n", error_missed_count);
+		error_missed_count = 0;
+	}
+
 	mod_timer(&kmemcheck_timer, kmemcheck_timer.expires + HZ);
 }
 
-- 
1.5.4.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] kmemcheck: custom queue size and overflow detection, Vegard Nossum, (Thu May 8, 11:56 am)