aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorMatthew Dobson <colpatch@us.ibm.com>2006-02-01 06:05:46 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-01 11:53:17 -0500
commit12dd36faec5d3bd96da84fa8f76efecc632930ab (patch)
tree069ec58bf797166824e92b363720bef041aef712 /mm/slab.c
parentfbaccacff1f17c65ae0972085368a7ec75be6062 (diff)
[PATCH] slab: extract slab_destroy_objs()
Create a helper function, slab_destroy_objs() which called from slab_destroy(). This makes slab_destroy() smaller and more readable, and moves ifdefs outside the function body. Signed-off-by: Matthew Dobson <colpatch@us.ibm.com> Acked-by: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/mm/slab.c b/mm/slab.c
index e869400ea731..85adf0992011 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1459,15 +1459,13 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp)
1459} 1459}
1460#endif 1460#endif
1461 1461
1462/* Destroy all the objs in a slab, and release the mem back to the system. 1462#if DEBUG
1463 * Before calling the slab must have been unlinked from the cache. 1463/**
1464 * The cache-lock is not held/needed. 1464 * slab_destroy_objs - call the registered destructor for each object in
1465 * a slab that is to be destroyed.
1465 */ 1466 */
1466static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp) 1467static void slab_destroy_objs(kmem_cache_t *cachep, struct slab *slabp)
1467{ 1468{
1468 void *addr = slabp->s_mem - slabp->colouroff;
1469
1470#if DEBUG
1471 int i; 1469 int i;
1472 for (i = 0; i < cachep->num; i++) { 1470 for (i = 0; i < cachep->num; i++) {
1473 void *objp = slabp->s_mem + cachep->buffer_size * i; 1471 void *objp = slabp->s_mem + cachep->buffer_size * i;
@@ -1496,7 +1494,10 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
1496 if (cachep->dtor && !(cachep->flags & SLAB_POISON)) 1494 if (cachep->dtor && !(cachep->flags & SLAB_POISON))
1497 (cachep->dtor) (objp + obj_offset(cachep), cachep, 0); 1495 (cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
1498 } 1496 }
1497}
1499#else 1498#else
1499static void slab_destroy_objs(kmem_cache_t *cachep, struct slab *slabp)
1500{
1500 if (cachep->dtor) { 1501 if (cachep->dtor) {
1501 int i; 1502 int i;
1502 for (i = 0; i < cachep->num; i++) { 1503 for (i = 0; i < cachep->num; i++) {
@@ -1504,8 +1505,19 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
1504 (cachep->dtor) (objp, cachep, 0); 1505 (cachep->dtor) (objp, cachep, 0);
1505 } 1506 }
1506 } 1507 }
1508}
1507#endif 1509#endif
1508 1510
1511/**
1512 * Destroy all the objs in a slab, and release the mem back to the system.
1513 * Before calling the slab must have been unlinked from the cache.
1514 * The cache-lock is not held/needed.
1515 */
1516static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
1517{
1518 void *addr = slabp->s_mem - slabp->colouroff;
1519
1520 slab_destroy_objs(cachep, slabp);
1509 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) { 1521 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
1510 struct slab_rcu *slab_rcu; 1522 struct slab_rcu *slab_rcu;
1511 1523