Re: [Ext2-devel] [RFC][PATCH] Manage jbd allocations from its ownslabs

From: Dave Kleikamp
Date: Thu Aug 24 2006 - 08:38:26 EST


On Wed, 2006-08-23 at 16:34 -0700, Andrew Morton wrote:
> On Wed, 23 Aug 2006 16:08:15 -0700
> Badari Pulavarty <pbadari@xxxxxxxxxx> wrote:

> > /*
> > + * jbd slab management: create 1k, 2k, 4k, 8k slabs and allocate
> > + * frozen and commit buffers from these slabs.
> > + *
> > + * Reason for doing this is to avoid, SLAB_DEBUG - since it could
> > + * cause bh to cross page boundary.
> > + */
> > +
> > +static kmem_cache_t *jbd_slab[4];
> > +static const char *jbd_slab_names[4] = {
> > + "jbd_1k",
> > + "jbd_2k",
> > + "jbd_4k",
> > + "jbd_8k",
> > +};
> > +
> > +static void journal_destroy_jbd_slabs(void)
> > +{
> > + int i;
> > +
> > + for (i=0; i<4; i++) {
> > + if (jbd_slab[i])
> > + kmem_cache_destroy(jbd_slab[i]);
> > + jbd_slab[i] = NULL;
> > + }
> > +}
> > +
> > +static int journal_init_jbd_slabs(void)
> > +{
> > + int i = 0;
> > + int retval = 0;
> > +
> > + for (i=0; i<4; i++) {
> > + unsigned long slab_size = 1024 << i;
> > + jbd_slab[i] = kmem_cache_create(jbd_slab_names[i],
> > + slab_size, slab_size,
> > + 0, NULL, NULL);
>
> OK, passing align=slab_size fixes the bug.

The comments above don't mention the alignment of the slabs, so a
comment here may help explain that the alignment is the key to avoiding
the page-straddling. Or you could elaborate above.

Shaggy
--
David Kleikamp
IBM Linux Technology Center

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