diff options
-rw-r--r-- | mm/slab.c | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -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 | */ |
1466 | static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp) | 1467 | static 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 |
1499 | static 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 | */ | ||
1516 | static 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 | ||