From: Pintu Kumar <pintu@codeaurora.org>
To: xenomai@xenomai.org, rpm@xenomai.org, sunshilong369@gmail.com,
pintu@codeaurora.org, jan.kiszka@siemens.com
Cc: pintu.ping@gmail.com
Subject: [PATCH v2] kernel:cobalt:heap: replace kzalloc with vmalloc
Date: Sat, 15 Aug 2020 15:59:29 +0530 [thread overview]
Message-ID: <1597487369-20838-1-git-send-email-pintu@codeaurora.org> (raw)
In-Reply-To: <1596218699-15537-1-git-send-email-pintu@codeaurora.org>
In-Reply-To: <1596218699-15537-1-git-send-email-pintu@codeaurora.org>
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 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: Pintu Kumar <pintu@codeaurora.org>
Signed-off-by: sunshilong <sunshilong369@gmail.com>
Tested-by: sunshilong <sunshilong369@gmail.com>
---
kernel/cobalt/heap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/cobalt/heap.c b/kernel/cobalt/heap.c
index d01a2e0..17b392b 100644
--- a/kernel/cobalt/heap.c
+++ b/kernel/cobalt/heap.c
@@ -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 = vmalloc(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);
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2020-08-15 10:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Pintu Kumar [this message]
2020-08-18 5:44 ` [PATCH v2] kernel:cobalt:heap: replace kzalloc with vmalloc 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=1597487369-20838-1-git-send-email-pintu@codeaurora.org \
--to=pintu@codeaurora.org \
--cc=jan.kiszka@siemens.com \
--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.