From: Takashi Iwai <tiwai@suse.de>
To: "Wang, Yalin" <Yalin.Wang@sonymobile.com>
Cc: "'alsa-devel@alsa-project.org'" <alsa-devel@alsa-project.org>,
"'broonie@opensource.wolfsonmicro.com'"
<broonie@opensource.wolfsonmicro.com>,
"'fweisbec@gmail.com'" <fweisbec@gmail.com>,
"'dmitry.torokhov@gmail.com'" <dmitry.torokhov@gmail.com>,
"'coreteam@netfilter.org'" <coreteam@netfilter.org>,
"'linux-input@vger.kernel.org'" <linux-input@vger.kernel.org>,
"'rydberg@euromail.se'" <rydberg@euromail.se>,
"'lrg@ti.com'" <lrg@ti.com>,
"'pablo@netfilter.org'" <pablo@netfilter.org>,
"'linux-arm-msm@vger.kernel.org'" <linux-arm-msm@vger.kernel.org>,
"'rostedt@goodmis.org'" <rostedt@goodmis.org>,
"'netfilter@vger.kernel.org'" <netfilter@vger.kernel.org>,
"'mingo@redhat.com'" <mingo@redhat.com>,
"'linux-arm-kernel@lists.infradead.org'"
<linux-arm-kernel@lists.infradead.org>,
"'gregkh@linuxfoundation.org'" <gregkh@linuxfoundation.org>,
"'linux-usb@vger.kernel.org'" <linux-us
Subject: Re: change kmalloc into vmalloc for large memory allocations
Date: Fri, 28 Feb 2014 15:19:43 +0100 [thread overview]
Message-ID: <s5hlhwvb9q8.wl%tiwai@suse.de> (raw)
In-Reply-To: <35FD53F367049845BC99AC72306C23D102844605F38C@CNBJMBX05.corpusers.net>
At Fri, 28 Feb 2014 16:15:23 +0800,
Wang, Yalin wrote:
>
> Hi
>
>
> I find there is some drivers use kmalloc to allocate large
> Memorys during module_init, some can be changed to use vmalloc
> To save some low mem, I add log in kernel to track ,
> And list them here:
>
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/drivers/usb/gadget/f_mass_storage.c?h=master#n2724
>
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/sound/soc/soc-core.c?h=master#n3772
At least the ASoC runtime case doesn't use the allocated memory as
buffer, and they are allocated only once per device, thus it shouldn't
be the problem you stated. If it really consumes so much memory, we
need to rethink, instead of allocating an array but allocate each
object, for example.
thanks,
Takashi
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/net/netfilter/nf_conntrack_ftp.c?h=master#n603
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/net/netfilter/nf_conntrack_h323_main.c?h=master#n1849
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/net/netfilter/nf_conntrack_irc.c?h=master#n247
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/net/netfilter/nf_conntrack_sane.c?h=master#n195
>
> https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/drivers/input/evdev.c?h=master#n403
>
>
> they allocate large memory from 10k~64K ,
> this will use lots of low mem, instead if we use
> vmalloc for these drivers , it will be good for some devices
> like smart phone, we often encounter some errors like kmalloc failed
> because there is not enough low mem , especially when the device has physical
> memory less than 1GB .
>
>
> could this module change the memory allocation into vmalloc ?
>
> I was thinking that if we can introduce a helper function in kmalloc.h like this :
>
> Kmalloc(size, flags)
> {
> If (size > PAGE_SIZE && flags&CAN_USE_VMALLOC_FLAG)
> return vmalloc(size);
> Else
> return real_kmalloc(size);
> }
>
> Kfree(ptr)
> {
> If (is_vmalloc_addr(ptr))
> Vfree(ptr);
> Else
> Kfree(ptr);
> }
>
>
> But we need add some flags to ensure always use kmalloc for
> Some special use (dma etc..)
>
> How do you think of it ?
>
> Thanks
>
>
>
next prev parent reply other threads:[~2014-02-28 14:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <35FD53F367049845BC99AC72306C23D102844605F38C@CNBJMBX05.corpusers.net>
2014-02-28 8:54 ` change kmalloc into vmalloc for large memory allocations Huang Shijie
2014-02-28 9:20 ` Wang, Yalin
2014-02-28 16:33 ` 'gregkh@linuxfoundation.org'
2014-03-03 2:51 ` Wang, Yalin
2014-03-03 3:08 ` 'gregkh@linuxfoundation.org'
2014-03-03 8:00 ` Wang, Yalin
2014-03-03 14:10 ` 'gregkh@linuxfoundation.org'
2014-03-04 7:30 ` [PATCH] netfilter:Change nf_conntrack modules to use vmalloc Wang, Yalin
2014-02-28 14:11 ` change kmalloc into vmalloc for large memory allocations Steven Rostedt
2014-02-28 14:19 ` Takashi Iwai [this message]
2014-03-03 1:55 ` Wang, Yalin
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=s5hlhwvb9q8.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=Yalin.Wang@sonymobile.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=coreteam@netfilter.org \
--cc=dmitry.torokhov@gmail.com \
--cc=fweisbec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=lrg@ti.com \
--cc=mingo@redhat.com \
--cc=netfilter@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=rostedt@goodmis.org \
--cc=rydberg@euromail.se \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).