From: Eric Dumazet <eric.dumazet@gmail.com>
To: Avi Kivity <avi@redhat.com>, Changli Gao <xiaosuo@gmail.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
jslaby@suse.cz, akpm@linux-foundation.org,
paulmck@linux.vnet.ibm.com, adobriyan@gmail.com, mingo@elte.hu,
peterz@infradead.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: use kmalloc() to allocate fdmem if possible
Date: Mon, 03 May 2010 11:13:52 +0200 [thread overview]
Message-ID: <1272878032.2226.27.camel@edumazet-laptop> (raw)
In-Reply-To: <4BDE8E24.5050200@redhat.com>
Le lundi 03 mai 2010 à 11:49 +0300, Avi Kivity a écrit :
> A kmalloc()ed page is virtually contiguous, satisfying your requirement.
>
Still, a different function pair is needed, at least for documentation
reasons.
Changli, _many_ patches like yours were suggested and refused in the
past for the reason it should be generic. Maybe its time...
So first introduce a pair of funtions, then we can use them.
At free time we can use is_vmalloc_addr() so that no extra bit is needed
to tell if a zone was vmalloced() or kmalloced()
One remark :
+ data = kmalloc(size, GFP_KERNEL);
If allocation fails (because of fragmentation), we would have a kernel
log.
Still, vmalloc() might be OK.
So you should add a __GFP_NOWARN flag.
/*
* Warning: if size is not a power of two, kmalloc() might
* waste memory because of its requirements.
*/
void *kvmalloc(size_t size)
{
void *ptr = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
if (ptr)
return ptr;
return vmalloc(size);
}
void kvfree(void *ptr)
{
BUG_ON(in_interrupt());
if (is_vmalloc_addr(ptr))
vfree(ptr);
else
kfree(ptr);
}
next prev parent reply other threads:[~2010-05-03 9:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Alexander Viro <viro@zeniv.linux.org.uk>
2010-05-02 16:46 ` Changli Gao
2010-05-02 17:31 ` Avi Kivity
2010-05-03 0:15 ` Tetsuo Handa
2010-05-03 6:06 ` Avi Kivity
2010-05-03 7:05 ` Changli Gao
2010-05-03 7:42 ` Avi Kivity
2010-05-03 7:52 ` Changli Gao
2010-05-03 8:49 ` Avi Kivity
2010-05-03 9:03 ` Jiri Slaby
2010-05-03 9:18 ` Avi Kivity
2010-05-03 9:22 ` Jiri Slaby
2010-05-03 9:25 ` Jiri Slaby
2010-05-03 9:28 ` Avi Kivity
2010-05-03 9:13 ` Eric Dumazet [this message]
2010-05-03 9:19 ` Jiri Slaby
2010-05-03 9:29 ` Eric Dumazet
2010-05-04 4:20 ` Changli Gao
2010-05-04 5:33 ` Eric Dumazet
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=1272878032.2226.27.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=jslaby@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=peterz@infradead.org \
--cc=xiaosuo@gmail.com \
/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
all inboxes | Powered by JetHome®