Skip to contentSkip to conversation

Enable checking of reap of in-use slab

PATCH New James Bottomley 1 participant 1 message Dec 20, 2002 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable checking of reap of in-use slab

Hi Marcelo,

On older (2.4.9) kernels, we keep running into the occasional attempts to reap in-use slabs. The checks for this were compiled out on 2.4.10 and above in the name of efficiency.

I'd like to add the checks just for the in use parts back just to make assurances doubly sure that this bug is actually fixed, not just obscured. The changes use the BUG_ON macro, so the actual debugging stuff is in the unlikely branch which shouldn't impact the critical path too much.

Please consider applying for 2.4.22

Thanks,

James

===== mm/slab.c 1.21 vs edited =====

mm/slab.c +9 -12
@@ -928,10 +928,9 @@
 			break;
 
 		slabp = list_entry(cachep->slabs_free.prev, slab_t, list);
-#if DEBUG
-		if (slabp->inuse)
-			BUG();
-#endif
+
+		BUG_ON(slabp->inuse);
+
 		list_del(&slabp->list);
 
 		spin_unlock_irq(&cachep->spinlock);
@@ -1785,10 +1784,9 @@
 		p = searchp->slabs_free.next;
 		while (p != &searchp->slabs_free) {
 			slabp = list_entry(p, slab_t, list);
-#if DEBUG
-			if (slabp->inuse)
-				BUG();
-#endif
+
+			BUG_ON(slabp->inuse);
+
 			full_free++;
 			p = p->next;
 		}
@@ -1838,10 +1836,9 @@
 		if (p == &best_cachep->slabs_free)
 			break;
 		slabp = list_entry(p,slab_t,list);
-#if DEBUG
-		if (slabp->inuse)
-			BUG();
-#endif
+
+		BUG_ON(slabp->inuse);
+
 		list_del(&slabp->list);
 		STATS_INC_REAPED(best_cachep);