Re: Re: Re: [Oops] i386 mm/slab.c (cache_flusharray)

From: Linus Torvalds
Date: Mon Dec 01 2003 - 18:48:21 EST




On Thu, 27 Nov 2003 pinotj@xxxxxxxxxxxxxxxx wrote:
>
> Here is the result of test of 2.6.0-test10 with the printk patch in
> slab.c and this new patch for fork.c from Linus :

The fork.c change can really only affect threaded programs using the new
threading, and even then is likely to hit only in very unlikely
circumstances. Certainly not a kernel compile.

I'm wondering if the slab debugging code is just broken somehow. If you
have lots of memory, it should even work for you.

NOTE! For this patch to make sense, you have to enable the page allocator
debugging thing (CONFIG_DEBUG_PAGEALLOC), and you have to live with the
fact that it wastes a _lot_ of memory.

There's another problem with this patch: if the bug is actually in the
slab code itself, this will obviously not find it, since it disables that
code entirely.

Linus

----
===== mm/slab.c 1.110 vs edited =====
--- 1.110/mm/slab.c Tue Oct 21 22:10:10 2003
+++ edited/mm/slab.c Mon Dec 1 15:29:06 2003
@@ -1906,6 +1906,21 @@

static inline void * __cache_alloc (kmem_cache_t *cachep, int flags)
{
+#if 1
+ void *ptr = (void*)__get_free_pages(flags, cachep->gfporder);
+ if (ptr) {
+ struct page *page = virt_to_page(ptr);
+ SET_PAGE_CACHE(page, cachep);
+ SET_PAGE_SLAB(page, 0x01020304);
+ if (cachep->ctor) {
+ unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR;
+ if (!(flags & __GFP_WAIT))
+ ctor_flags |= SLAB_CTOR_ATOMIC;
+ cachep->ctor(ptr, cachep, ctor_flags);
+ }
+ }
+ return ptr;
+#else
unsigned long save_flags;
void* objp;
struct array_cache *ac;
@@ -1925,6 +1940,7 @@
local_irq_restore(save_flags);
objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0));
return objp;
+#endif
}

/*
@@ -2042,6 +2058,15 @@
*/
static inline void __cache_free (kmem_cache_t *cachep, void* objp)
{
+#if 1
+ {
+ struct page *page = virt_to_page(objp);
+ int order = cachep->gfporder;
+ if (cachep->dtor)
+ cachep->dtor(objp, cachep, 0);
+ __free_pages(page, order);
+ }
+#else
struct array_cache *ac = ac_data(cachep);

check_irq_off();
@@ -2056,6 +2081,7 @@
cache_flusharray(cachep, ac);
ac_entry(ac)[ac->avail++] = objp;
}
+#endif
}

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