[PATCH] kmemcheck: don't track pages allocated with interruptsdisabled

From: Vegard Nossum
Date: Sat Jun 07 2008 - 10:32:57 EST


Hi,

It seems that I was wrong regarding the set_memory_4k() approach. It seems
to only have worked because we were lucky. We may later reinstate the code
to disable PSE, but this time not unconditionally, perhaps with a config
option or boot-time option.

That a new page needs to be allocated with interrupts disabled is probably
rare enough that we can get away with this without losing too many pages
that could otherwise have been tracked.

Again, this is overall nicer than unconditionally disabling PSE, since
that incurs a much larger overhead in the case where kmemcheck is enabled
in the config but disabled by default. (Ingo, you previously indicated that
it would be nice if kernels could be configured in this way by default.)


Vegard


From: Vegard Nossum <vegardno@xxxxxxxxxxxxxx>
Date: Sat, 7 Jun 2008 16:18:29 +0200
Subject: [PATCH] kmemcheck: don't track pages allocated with interrupts disabled

Because large physical pages need to be split to 4k-sized pages after
the slab page has been allocated, and this needs to flush the page
tables, we cannot track any pages that were allocated while interrupts
were disabled.

This fixes a boot crash that seems to depend on timing to appear.

Signed-off-by: Vegard Nossum <vegardno@xxxxxxxxxxxxxx>
---
mm/kmemcheck.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/mm/kmemcheck.c b/mm/kmemcheck.c
index 4efdf1e..b337374 100644
--- a/mm/kmemcheck.c
+++ b/mm/kmemcheck.c
@@ -10,6 +10,14 @@ void kmemcheck_alloc_shadow(struct kmem_cache *s, gfp_t flags, int node,
int pages;
int i;

+ /*
+ * It's sad, but it's true. If interrupts are enabled while making
+ * this allocation, it means that we can't split the large page
+ * because it would require flushing the page tables.
+ */
+ if (irqs_disabled())
+ return;
+
pages = 1 << order;

/*
--
1.5.3.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/