From: Pintu Kumar <pintu@codeaurora.org>
To: xenomai@xenomai.org, rpm@xenomai.org, sunshilong369@gmail.com,
pintu@codeaurora.org
Cc: pintu.ping@gmail.com
Subject: [PATCH] kernel:cobalt:heap: replace kzalloc with kvzalloc
Date: Fri, 31 Jul 2020 23:34:59 +0530 [thread overview]
Message-ID: <1596218699-15537-1-git-send-email-pintu@codeaurora.org> (raw)
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.
next reply other threads:[~2020-07-31 18:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 18:04 Pintu Kumar [this message]
2020-08-07 4:56 ` [PATCH] kernel:cobalt:heap: replace kzalloc with kvzalloc 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1596218699-15537-1-git-send-email-pintu@codeaurora.org \
--to=pintu@codeaurora.org \
--cc=pintu.ping@gmail.com \
--cc=rpm@xenomai.org \
--cc=sunshilong369@gmail.com \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.