From: "Pekka Enberg" <penberg@cs.helsinki.fi>
To: "Lai Jiangshan" <laijs@cn.fujitsu.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"David Miller" <davem@davemloft.net>,
"Dave Airlie" <airlied@gmail.com>,
"Paul Menage" <menage@google.com>,
kamezawa.hiroyu@jp.fujitsu.com,
"Balbir Singh" <balbir@linux.vnet.ibm.com>,
"Arjan van de Ven" <arjan@infradead.org>,
"Jan Kara" <jack@suse.cz>, "Jes Sorensen" <jes@sgi.com>,
"KOSAKI Motohiro" <kosaki.motohiro@jp.fujitsu.com>,
dada1@cosmosbay.com, "Alexey Dobriyan" <adobriyan@gmail.com>,
"Jens Axboe" <jens.axboe@oracle.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 1/1] mm: introduce kvmalloc()/kvfree()
Date: Tue, 18 Nov 2008 08:57:07 +0200 [thread overview]
Message-ID: <84144f020811172257k2c749bc3g98c3596ebb603cd2@mail.gmail.com> (raw)
In-Reply-To: <492162E4.9080902@cn.fujitsu.com>
On Mon, Nov 17, 2008 at 2:26 PM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
> @@ -163,6 +165,38 @@ char *strndup_user(const char __user *s, long n)
> }
> EXPORT_SYMBOL(strndup_user);
>
> +/**
> + * kvmalloc - allocate memory by kmalloc() or vmalloc()
> + *
> + * if @size <= PAGE_SIZE, memory is allocated by kmalloc(),
> + * otherwise by vmalloc().
> + *
> + * NOTICE: Generally, you should use kmalloc() or vmalloc() directly.
> + * kvmalloc() is provided for some special condition.
You might as well explicitly state what those special conditions are here.
> + */
> +void *kvmalloc(unsigned long size, gfp_t flags)
> +{
> + if (size <= PAGE_SIZE)
> + return kmalloc(size, flags & ~__GFP_HIGH);
> + else
> + return __vmalloc(size, flags | __GFP_HIGHMEM, PAGE_KERNEL);
> +}
> +EXPORT_SYMBOL(kvmalloc);
> +
> +/**
> + * kvfree - free the memory by kfree(), or vfree() if it is vmalloc addr
> + */
> +void kvfree(void *ptr)
> +{
> + BUG_ON(in_interrupt());
I wonder if this should be a WARN_ON() to let the machine limp along
for a while if it can. At least in the kfree() case people can catch
the oops trace more easily that way.
> +
> + if (is_vmalloc_addr(ptr))
> + vfree(ptr);
> + else
> + kfree(ptr);
> +}
> +EXPORT_SYMBOL(kvfree);
> +
> #ifndef HAVE_ARCH_PICK_MMAP_LAYOUT
> void arch_pick_mmap_layout(struct mm_struct *mm)
> {
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
prev parent reply other threads:[~2008-11-18 6:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-17 12:26 Lai Jiangshan
2008-11-17 13:14 ` Johannes Weiner
2008-11-18 0:28 ` Lai Jiangshan
2008-11-18 8:50 ` [PATCH V2 0/4] use kvmalloc()/kvfree() the second part, about RCU Lai Jiangshan
2008-11-18 8:51 ` [PATCH V2 1/4] vmalloc: introduce vfree_atomic() Lai Jiangshan
2008-11-18 9:19 ` Nick Piggin
2008-11-18 11:38 ` Lai Jiangshan
2008-11-18 12:05 ` Nick Piggin
2008-11-18 8:51 ` [PATCH V2 2/4] mm: introduce kvfree_atomic() Lai Jiangshan
2008-11-18 8:51 ` [PATCH V2 3/4] files: use kvmalloc()/kvfree()/kvfree_atomic() Lai Jiangshan
2008-11-18 8:51 ` [PATCH V2 4/4] sysipc: use kvmalloc()/kvfree_atomic() Lai Jiangshan
2008-11-18 6:57 ` Pekka Enberg [this message]
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=84144f020811172257k2c749bc3g98c3596ebb603cd2@mail.gmail.com \
--to=penberg@cs.helsinki.fi \
--cc=adobriyan@gmail.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=jack@suse.cz \
--cc=jens.axboe@oracle.com \
--cc=jes@sgi.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.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®