All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel:cobalt:heap: replace kzalloc with kvzalloc
@ 2020-07-31 18:04 Pintu Kumar
  2020-08-07  4:56 ` pintu
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Pintu Kumar @ 2020-07-31 18:04 UTC (permalink / raw)
  To: xenomai, rpm, sunshilong369, pintu; +Cc: pintu.ping

With CONFIG_XENO_OPT_PRIVATE_HEAPSZ, user that 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.
Further without COMPACTION enabled, the situation can be worse.

Moreover, for this heap allocation, we don't need physical contiguous
memory. Thus vmalloc may be sufficient here.
But for performance benefit we may like to stick to kmalloc.

Thus, it is better to replace kzalloc with kvzalloc which will first try
to use kmalloc and if fails, fallback to vmalloc.

Signed-off-by: Pintu Kumar <pintu@codeaurora.org>
Signed-off-by: sunshilong <sunshilong369@gmail.com>
Tested-by: sunshilong <sunshilong369@gmail.com>
---
 kernel/cobalt/heap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/heap.c b/kernel/cobalt/heap.c
index d01a2e0..312b41f 100644
--- a/kernel/cobalt/heap.c
+++ b/kernel/cobalt/heap.c
@@ -749,7 +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,
+	heap->pagemap = kvzalloc(sizeof(struct xnheap_pgentry) * nrpages,
 				GFP_KERNEL);
 	if (heap->pagemap == NULL)
 		return -ENOMEM;
@@ -804,7 +804,7 @@ void xnheap_destroy(struct xnheap *heap)
 	nrheaps--;
 	xnvfile_touch_tag(&vfile_tag);
 	xnlock_put_irqrestore(&nklock, s);
-	kfree(heap->pagemap);
+	kvfree(heap->pagemap);
 }
 EXPORT_SYMBOL_GPL(xnheap_destroy);
 
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.



^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-08-19  6:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-31 18:04 [PATCH] kernel:cobalt:heap: replace kzalloc with kvzalloc Pintu Kumar
2020-08-07  4:56 ` pintu
2020-08-10  7:09   ` pintu
2020-08-10  8:41     ` Philippe Gerum
2020-08-11  7:11 ` Jan Kiszka
2020-08-11  8:10   ` Jan Kiszka
2020-08-11  8:48     ` 孙世龙 sunshilong
2020-08-11  8:51       ` Jan Kiszka
2020-08-11  9:17         ` 孙世龙 sunshilong
     [not found]           ` <CAOuPNLhPejZsUwCrjOWm=kT_JLJipcV7WXt6TgiAA6UDXpOmvg@mail.gmail.com>
2020-08-12 15:51             ` Jan Kiszka
     [not found]               ` <CAOuPNLixxP7+RkW716PZ97mq1dNNdzsMMdX_LAZ4+_DYkmREUw@mail.gmail.com>
2020-08-13 10:31                 ` Jan Kiszka
     [not found]                   ` <CAOuPNLjozRbNL_S8d8qNR9feSjcbiT+vbhLVM4K+AMAhrJy=TQ@mail.gmail.com>
2020-08-14  0:52                     ` 孙世龙 sunshilong
2020-08-14  7:06                     ` Jan Kiszka
     [not found]                       ` <CAOuPNLjMBjWEQ7KiZd=d6ySMJ=zz_OMWZZ6A2VoHRgcEvp=MnA@mail.gmail.com>
2020-08-14  9:54                         ` 孙世龙 sunshilong
2020-08-14 10:08                           ` Jan Kiszka
2020-08-15 10:29 ` [PATCH v2] kernel:cobalt:heap: replace kzalloc with vmalloc Pintu Kumar
2020-08-18  5:44   ` Jan Kiszka
2020-08-18  5:51     ` Jan Kiszka
2020-08-18  7:40     ` 孙世龙 sunshilong
2020-08-18 17:56   ` [PATCH v3] kernel:cobalt:heap: replace kzalloc with vzalloc Pintu Kumar
2020-08-19  6:31     ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.