Commit c984901a authored by Pintu Kumar's avatar Pintu Kumar Committed by Jan Kiszka

kernel:cobalt:heap: replace kzalloc with vzalloc

With CONFIG_XENO_OPT_PRIVATE_HEAPSZ, user can request any heap size
based on their needs. For some application needs, this can grow as large
as 4MB that is, 2^10 order pages, which is unlikely to succeed with
kzalloc. Even the default (256KB) may fail on highly fragmented system.

Moreover, for this heap allocation, we don't need physical contiguous
memory. Thus vmalloc/vzalloc may be sufficient here.

Note, we may also use kvzalloc/kvmalloc, but unfortunately these are not
available in all kernel versions. Thus for backward compatibility we stick
to vmalloc at least till we support 4.x kernel.
Signed-off-by: default avatarPintu Kumar <pintu@codeaurora.org>
Signed-off-by: default avatarsunshilong <sunshilong369@gmail.com>
Tested-by: default avatarsunshilong <sunshilong369@gmail.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 0bcfce8f
......@@ -749,8 +749,7 @@ int xnheap_init(struct xnheap *heap, void *membase, size_t size)
xnlock_init(&heap->lock);
nrpages = size >> XNHEAP_PAGE_SHIFT;
heap->pagemap = kzalloc(sizeof(struct xnheap_pgentry) * nrpages,
GFP_KERNEL);
heap->pagemap = vzalloc(sizeof(struct xnheap_pgentry) * nrpages);
if (heap->pagemap == NULL)
return -ENOMEM;
......@@ -804,7 +803,7 @@ void xnheap_destroy(struct xnheap *heap)
nrheaps--;
xnvfile_touch_tag(&vfile_tag);
xnlock_put_irqrestore(&nklock, s);
kfree(heap->pagemap);
vfree(heap->pagemap);
}
EXPORT_SYMBOL_GPL(xnheap_destroy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment