mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-31 11:34:32 +00:00
[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>
This commit is contained in:
parent
fbaccacff1
commit
12dd36faec
1 changed files with 20 additions and 8 deletions
28
mm/slab.c
28
mm/slab.c
|
@ -1459,15 +1459,13 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Destroy all the objs in a slab, and release the mem back to the system.
|
|
||||||
* Before calling the slab must have been unlinked from the cache.
|
|
||||||
* The cache-lock is not held/needed.
|
|
||||||
*/
|
|
||||||
static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
|
|
||||||
{
|
|
||||||
void *addr = slabp->s_mem - slabp->colouroff;
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
/**
|
||||||
|
* slab_destroy_objs - call the registered destructor for each object in
|
||||||
|
* a slab that is to be destroyed.
|
||||||
|
*/
|
||||||
|
static void slab_destroy_objs(kmem_cache_t *cachep, struct slab *slabp)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < cachep->num; i++) {
|
for (i = 0; i < cachep->num; i++) {
|
||||||
void *objp = slabp->s_mem + cachep->buffer_size * i;
|
void *objp = slabp->s_mem + cachep->buffer_size * i;
|
||||||
|
@ -1496,7 +1494,10 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
|
||||||
if (cachep->dtor && !(cachep->flags & SLAB_POISON))
|
if (cachep->dtor && !(cachep->flags & SLAB_POISON))
|
||||||
(cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
|
(cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
static void slab_destroy_objs(kmem_cache_t *cachep, struct slab *slabp)
|
||||||
|
{
|
||||||
if (cachep->dtor) {
|
if (cachep->dtor) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < cachep->num; i++) {
|
for (i = 0; i < cachep->num; i++) {
|
||||||
|
@ -1504,8 +1505,19 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
|
||||||
(cachep->dtor) (objp, cachep, 0);
|
(cachep->dtor) (objp, cachep, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy all the objs in a slab, and release the mem back to the system.
|
||||||
|
* Before calling the slab must have been unlinked from the cache.
|
||||||
|
* The cache-lock is not held/needed.
|
||||||
|
*/
|
||||||
|
static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
|
||||||
|
{
|
||||||
|
void *addr = slabp->s_mem - slabp->colouroff;
|
||||||
|
|
||||||
|
slab_destroy_objs(cachep, slabp);
|
||||||
if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
|
if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
|
||||||
struct slab_rcu *slab_rcu;
|
struct slab_rcu *slab_rcu;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue