Re: [RFC 3/4] Add checks to current destructor uses
From: Christoph Lameter
Date: Thu Jun 22 2006 - 15:39:48 EST
On Thu, 22 Jun 2006, Pekka J Enberg wrote:
> On Mon, 19 Jun 2006, Christoph Lameter wrote:
> > slab: Add checks to current destructor uses
> >
> > We will be adding new destructor options soon. So insure that all
> > existing destructors only react to SLAB_DTOR_DESTROY.
>
> Hmm, I don't see the slab allocator passing SLAB_DTOR_DESTROY anywhere in
> this patch? Please don't introduce changesets that break the kernel.
> It's bad for stuff like git bisect.
Correct. Thanks.
Fixed up patch:
slab: Add checks to current destructor uses
We will be adding new destructor options soon. So insure that all
existing destructors only react to SLAB_DTOR_DESTROY.
Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
Index: linux-2.6.17/arch/i386/mm/pgtable.c
===================================================================
--- linux-2.6.17.orig/arch/i386/mm/pgtable.c 2006-06-17 18:49:35.000000000 -0700
+++ linux-2.6.17/arch/i386/mm/pgtable.c 2006-06-22 12:38:29.179955802 -0700
@@ -226,15 +226,19 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
}
/* never called when PTRS_PER_PMD > 1 */
-void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long slab_flags)
{
unsigned long flags; /* can be called from interrupt context */
+ if (!(slab_flags & SLAB_DTOR_DESTROY))
+ return;
+
spin_lock_irqsave(&pgd_lock, flags);
pgd_list_del(pgd);
spin_unlock_irqrestore(&pgd_lock, flags);
}
+
pgd_t *pgd_alloc(struct mm_struct *mm)
{
int i;
Index: linux-2.6.17/include/linux/slab.h
===================================================================
--- linux-2.6.17.orig/include/linux/slab.h 2006-06-17 18:49:35.000000000 -0700
+++ linux-2.6.17/include/linux/slab.h 2006-06-22 12:38:29.180932304 -0700
@@ -53,6 +53,9 @@ typedef struct kmem_cache kmem_cache_t;
#define SLAB_CTOR_ATOMIC 0x002UL /* tell constructor it can't sleep */
#define SLAB_CTOR_VERIFY 0x004UL /* tell constructor it's a verify call */
+/* flags passed to a constructor func */
+#define SLAB_DTOR_DESTROY 0x1000UL /* Called during slab destruction */
+
#ifndef CONFIG_SLOB
/* prototypes */
Index: linux-2.6.17/arch/frv/mm/pgalloc.c
===================================================================
--- linux-2.6.17.orig/arch/frv/mm/pgalloc.c 2006-06-17 18:49:35.000000000 -0700
+++ linux-2.6.17/arch/frv/mm/pgalloc.c 2006-06-22 12:38:29.212180365 -0700
@@ -120,10 +120,13 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
}
/* never called when PTRS_PER_PMD > 1 */
-void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
+void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long slab_flags)
{
unsigned long flags; /* can be called from interrupt context */
+ if (!(slab_flags & SLAB_DTOR_DESTROY))
+ return;
+
spin_lock_irqsave(&pgd_lock, flags);
pgd_list_del(pgd);
spin_unlock_irqrestore(&pgd_lock, flags);
Index: linux-2.6.17/mm/slab.c
===================================================================
--- linux-2.6.17.orig/mm/slab.c 2006-06-22 12:35:58.685386714 -0700
+++ linux-2.6.17/mm/slab.c 2006-06-22 12:39:37.971586394 -0700
@@ -1689,7 +1689,8 @@ static void slab_destroy_objs(struct kme
"was overwritten");
}
if (cachep->dtor && !(cachep->flags & SLAB_POISON))
- (cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
+ (cachep->dtor) (objp + obj_offset(cachep), cachep,
+ SLAB_DTOR_DESTROY);
}
}
#else
@@ -1699,7 +1700,7 @@ static void slab_destroy_objs(struct kme
int i;
for (i = 0; i < cachep->num; i++) {
void *objp = index_to_obj(cachep, slabp, i);
- (cachep->dtor) (objp, cachep, 0);
+ (cachep->dtor) (objp, cachep, SLAB_DTOR_DESTROY);
}
}
}
@@ -2661,7 +2662,8 @@ static void *cache_free_debugcheck(struc
/* we want to cache poison the object,
* call the destruction callback
*/
- cachep->dtor(objp + obj_offset(cachep), cachep, 0);
+ cachep->dtor(objp + obj_offset(cachep), cachep,
+ SLAB_DTOR_DESTROY);
}
#ifdef CONFIG_DEBUG_SLAB_LEAK
slab_bufctl(slabp)[objnr] = BUFCTL_FREE;
-
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/