kmalloc_cache_prealloc(): specify nr_elems as argument

This commit is contained in:
Balazs Gerofi
2017-10-25 13:18:05 +09:00
parent 6848c2ecf7
commit 33ad55e72b

View File

@@ -77,7 +77,7 @@ retry:
} }
static inline void kmalloc_cache_prealloc(struct kmalloc_cache_header *cache, 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; struct kmalloc_cache_header *elem;
int i; int i;
@@ -85,10 +85,7 @@ static inline void kmalloc_cache_prealloc(struct kmalloc_cache_header *cache,
if (unlikely(cache->next)) if (unlikely(cache->next))
return; return;
kprintf("%s: pre-allocating for 0x%lx...\n", for (i = 0; i < nr_elem; ++i) {
__FUNCTION__, cache);
for (i = 0; i < 512; ++i) {
struct kmalloc_header *header; struct kmalloc_header *header;
elem = (struct kmalloc_cache_header *) elem = (struct kmalloc_cache_header *)
@@ -126,7 +123,15 @@ retry:
} }
} }
else { 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; goto retry;
} }