Re: [Bug #13319] Page allocation failures with b43 and p54usb

Pekka Enberg
2009-06-10T16:16:51Z

On Wed, 2009-06-10 at 18:49 +0300, Pekka Enberg wrote:
> > On Wed, 2009-06-10 at 18:44 +0300, Pekka Enberg wrote:
> >
> > > Aha, SLUB thinks the minimum order for 4096 is 1. I guess you have
> > > CONFIG_SLUB_DEBUG enabled? If yes, something like to following should
> > > help. Christoph, are you okay with this patch?

On Wed, 2009-06-10 at 17:52 +0200, Johannes Berg wrote:
> > + if ((size + MAX_DEBUG_SIZE) >= PAGE_SIZE)
>
> && size <= PAGE_SIZE
>
> ? Or is this a path that only happens for small allocations?
>
> > + s->flags &= ~(SLAB_POISON|SLAB_RED_ZONE|SLAB_STORE_USER);
> > +
> > if (!calculate_sizes(s, -1))
> > goto error;

Although something like this would probably be even nicer.

Pekka

diff --git a/mm/slub.c b/mm/slub.c
index 65ffda5..a4206ef 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2334,6 +2334,16 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)

}

+#define MAX_DEBUG_SIZE (3 * sizeof(void *) + 2 * sizeof(struct track))
+
+static bool must_disable_debug(size_t size)
+{
+ /*
+ * Disable debugging if it increases the minimum page order.
+ */
+ return get_order(size + MAX_DEBUG_SIZE) > get_order(size);
+}
+
static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
const char *name, size_t size,
size_t align, unsigned long flags,
@@ -2346,6 +2356,9 @@ static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
s->align = align;
s->flags = kmem_cache_flags(size, flags, name, ctor);

+ if (must_disable_debug(size))
+ s->flags &= ~(SLAB_POISON|SLAB_RED_ZONE|SLAB_STORE_USER);
+
if (!calculate_sizes(s, -1))
goto error;