[PATCH] Poison slabs with constructors

From: willy@thepuffingroup.com
Date: Fri Jun 09 2000 - 09:45:27 EST


The current slab code refuses to poison slabs which have constructors.
This is a limitation not found in Bonwick's paper and it is useful for
debugging. I consider this a bugfix, not a feature patch.

--- linux-ac8/mm/slab.c Mon May 15 19:41:33 2000
+++ linux-ac8+slab/mm/slab.c Fri Jun 9 01:28:58 2000
@@ -728,11 +728,6 @@
                 flags &= ~SLAB_DEBUG_INITIAL;
         }
 
- if ((flags & SLAB_POISON) && ctor) {
- /* request for poisoning, but we can't do that with a constructor */
- printk("%sPoisoning requested, but con given - %s\n", func_nm, name);
- flags &= ~SLAB_POISON;
- }
 #if 0
         if ((flags & SLAB_HIGH_PACK) && ctor) {
                 printk("%sHigh pack requested, but con given - %s\n", func_nm, name);
@@ -1169,20 +1164,23 @@
                         objp += BYTES_PER_WORD;
                         *((unsigned long*)(objp+cachep->c_org_size)) = SLAB_RED_MAGIC1;
                 }
-#endif /* SLAB_DEBUG_SUPPORT */
 
                 /* Constructors are not allowed to allocate memory from the same cache
                  * which they are a constructor for. Otherwise, deadlock.
                  * They must also be threaded.
                  */
- if (cachep->c_ctor)
- cachep->c_ctor(objp, cachep, ctor_flags);
-#if SLAB_DEBUG_SUPPORT
- else if (cachep->c_flags & SLAB_POISON) {
- /* need to poison the objs */
+ if (cachep->c_flags & SLAB_POISON) {
                         kmem_poison_obj(cachep, objp);
+ } else if (cachep->c_ctor) {
+ cachep->c_ctor(objp, cachep, ctor_flags);
                 }
+#else
+ if (cachep->c_ctor) {
+ cachep->c_ctor(objp, cachep, ctor_flags);
+ }
+#endif
 
+#if SLAB_DEBUG_SUPPORT
                 if (cachep->c_flags & SLAB_RED_ZONE) {
                         if (*((unsigned long*)(objp+cachep->c_org_size)) !=
                             SLAB_RED_MAGIC1) {
@@ -1469,8 +1467,13 @@
                         if (cachep->c_flags & SLAB_RED_ZONE)
                                 goto red_zone;
 ret_red:
- if ((cachep->c_flags & SLAB_POISON) && kmem_check_poison_obj(cachep, objp))
- kmem_report_alloc_err("Bad poison", cachep);
+ if (cachep->c_flags & SLAB_POISON) {
+ if (kmem_check_poison_obj(cachep, objp))
+ kmem_report_alloc_err("Bad poison", cachep);
+ if (cachep->c_ctor)
+ cachep->c_ctor(objp, cachep,
+ SLAB_CTOR_CONSTRUCTOR);
+ }
 #endif /* SLAB_DEBUG_SUPPORT */
                         return objp;
                 }

-- 
The Sex Pistols were revolutionaries.  The Bay City Rollers weren't.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:18 EST