[PATCH] kmemcheck: custom queue size and overflow detection

From: Vegard Nossum
Date: Thu May 01 2008 - 13:26:06 EST


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@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/