From 33ad55e72b213b14b5659ecb3f69e9a2a47fdfb4 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Wed, 25 Oct 2017 13:18:05 +0900 Subject: [PATCH] kmalloc_cache_prealloc(): specify nr_elems as argument --- kernel/include/kmalloc.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/include/kmalloc.h b/kernel/include/kmalloc.h index f0eceb89..f614ced2 100644 --- a/kernel/include/kmalloc.h +++ b/kernel/include/kmalloc.h @@ -77,7 +77,7 @@ retry: } static inline void kmalloc_cache_prealloc(struct kmalloc_cache_header *cache, - size_t size) + size_t size, int nr_elem) { struct kmalloc_cache_header *elem; int i; @@ -85,10 +85,7 @@ static inline void kmalloc_cache_prealloc(struct kmalloc_cache_header *cache, if (unlikely(cache->next)) return; - kprintf("%s: pre-allocating for 0x%lx...\n", - __FUNCTION__, cache); - - for (i = 0; i < 512; ++i) { + for (i = 0; i < nr_elem; ++i) { struct kmalloc_header *header; elem = (struct kmalloc_cache_header *) @@ -126,7 +123,15 @@ retry: } } else { - kmalloc_cache_prealloc(cache, size); + //kprintf("%s: calling pre-alloc for 0x%lx...\n", + // __FUNCTION__, cache); + kprintf("%s: calling pre-alloc for 0x%lx (offs: %lu)...\n", + __FUNCTION__, cache, + ((unsigned long)cache - + (unsigned long)&cpu_local_var(txreq_cache)) / + sizeof(struct kmalloc_cache_header)); + + kmalloc_cache_prealloc(cache, size, 512); goto retry; }