slab: too much allocated in bootstrap head arrays?
In mm/slab.c kmem_cache_init() at /* 4) Replace the bootstrap head arrays */ it kmallocs *ptr and memcpy's with sizeof(struct arraycache_init). Is this correct or should it maybe be with sizeof(struct arraycache) instead?
Please review, i.e. this change:
---
It appears we allocated and copied too much.
--- mm/slab.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
mm/slab.c +4 -4
@@ -1617,11 +1617,11 @@ void __init kmem_cache_init(void) {struct array_cache *ptr; - ptr =kmalloc (sizeof (struct arraycache_init ),GFP_NOWAIT ); + ptr =kmalloc (sizeof (struct arraycache ),GFP_NOWAIT );BUG_ON (cpu_cache_get (&cache_cache) != &initarray_cache.cache);memcpy (ptr,cpu_cache_get (&cache_cache), -sizeof (struct arraycache_init )); +sizeof (struct arraycache ));/* * Do not assume that spinlocks can be initialized via memcpy: */
@@ -1629,12 +1629,12 @@ void __init kmem_cache_init(void) cache_cache.array[smp_processor_id ()] = ptr; - ptr =kmalloc (sizeof (struct arraycache_init ),GFP_NOWAIT ); + ptr =kmalloc (sizeof (struct arraycache ),GFP_NOWAIT );BUG_ON (cpu_cache_get (malloc_sizes[INDEX_AC ].cs_cachep) != &initarray_generic.cache);memcpy (ptr,cpu_cache_get (malloc_sizes[INDEX_AC ].cs_cachep), -sizeof (struct arraycache_init )); +sizeof (struct arraycache ));/* * Do not assume that spinlocks can be initialized via memcpy: */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · roel
In
mm/slab.ckmem_cache_init()at /* 4) Replace the bootstrap head arrays */ it kmallocs *ptr and memcpy's withsizeof(struct arraycache_init). Is this correct or should it maybe be with sizeof(struct arraycache) instead?
Allocating with sizeof(struct arraycache) will only allocate the header of the array cache and not reserve space for the pointers that are part of it. It is always wrong.
Look at alloc_arraycache() for the proper way to use struct arraycache to calculate the number of bytes needed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>