[RFC 3/4] Add checks to current destructor uses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

Index: linux-2.6.17-rc6-mm2/arch/i386/mm/pgtable.c
===================================================================
--- linux-2.6.17-rc6-mm2.orig/arch/i386/mm/pgtable.c	2006-06-16 11:48:44.229756909 -0700
+++ linux-2.6.17-rc6-mm2/arch/i386/mm/pgtable.c	2006-06-19 10:02:05.008801502 -0700
@@ -224,15 +224,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-rc6-mm2/include/linux/slab.h
===================================================================
--- linux-2.6.17-rc6-mm2.orig/include/linux/slab.h	2006-06-16 11:48:52.272227349 -0700
+++ linux-2.6.17-rc6-mm2/include/linux/slab.h	2006-06-19 10:00:33.951924377 -0700
@@ -52,6 +52,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-rc6-mm2/arch/frv/mm/pgalloc.c
===================================================================
--- linux-2.6.17-rc6-mm2.orig/arch/frv/mm/pgalloc.c	2006-06-05 17:57:02.000000000 -0700
+++ linux-2.6.17-rc6-mm2/arch/frv/mm/pgalloc.c	2006-06-19 10:03:11.301582635 -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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux