From: Andrew Morton <akpm@osdl.org>
To: Giridhar Pemmasani <giri@lmc.cs.sunysb.edu>
Cc: nickpiggin@yahoo.com.au, linux-kernel@vger.kernel.org
Subject: Re: __vmalloc with GFP_ATOMIC causes 'sleeping from invalid context'
Date: Mon, 22 May 2006 14:56:35 -0700 [thread overview]
Message-ID: <20060522145635.252c71d4.akpm@osdl.org> (raw)
In-Reply-To: <20060522065649.5C3E7EE9EE@wolfe.lmc.cs.sunysb.edu>
Giridhar Pemmasani <giri@lmc.cs.sunysb.edu> wrote:
>
> diff -Naur linux.orig/include/linux/vmalloc.h linux/include/linux/vmalloc.h
> --- linux.orig/include/linux/vmalloc.h 2006-05-22 02:45:23.000000000 -0400
> +++ linux/include/linux/vmalloc.h 2006-05-22 02:45:38.000000000 -0400
> @@ -3,6 +3,7 @@
>
> #include <linux/spinlock.h>
> #include <asm/page.h> /* pgprot_t */
> +#include <linux/gfp.h>
>
> /* bits in vm_struct->flags */
> #define VM_IOREMAP 0x00000001 /* ioremap() and friends */
> @@ -52,8 +53,15 @@
> extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
> extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
> unsigned long start, unsigned long end);
> -extern struct vm_struct *get_vm_area_node(unsigned long size,
> - unsigned long flags, int node);
> +extern struct vm_struct *get_vm_area_node_mask(unsigned long size,
> + unsigned long flags, int node,
> + gfp_t gfp_mask);
> +static inline struct vm_struct *get_vm_area_node(unsigned long size,
> + unsigned long flags, int node)
> +{
> + return get_vm_area_node_mask(size, flags, node, GFP_KERNEL);
> +}
> +
> extern struct vm_struct *remove_vm_area(void *addr);
> extern struct vm_struct *__remove_vm_area(void *addr);
> extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
> diff -Naur linux.orig/mm/vmalloc.c linux/mm/vmalloc.c
> --- linux.orig/mm/vmalloc.c 2006-05-19 01:22:00.000000000 -0400
> +++ linux/mm/vmalloc.c 2006-05-22 02:45:49.000000000 -0400
> @@ -157,8 +157,9 @@
> return err;
> }
>
> -struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
> - unsigned long start, unsigned long end, int node)
> +static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
> + unsigned long start, unsigned long end,
> + int node, gfp_t gfp_mask)
> {
> struct vm_struct **p, *tmp, *area;
> unsigned long align = 1;
> @@ -177,7 +178,7 @@
> addr = ALIGN(start, align);
> size = PAGE_ALIGN(size);
>
> - area = kmalloc_node(sizeof(*area), GFP_KERNEL, node);
> + area = kmalloc_node(sizeof(*area), gfp_mask, node);
> if (unlikely(!area))
> return NULL;
>
> @@ -233,7 +234,7 @@
> struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
> unsigned long start, unsigned long end)
> {
> - return __get_vm_area_node(size, flags, start, end, -1);
> + return __get_vm_area_node(size, flags, start, end, -1, GFP_KERNEL);
> }
>
> /**
> @@ -251,9 +252,11 @@
> return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END);
> }
>
> -struct vm_struct *get_vm_area_node(unsigned long size, unsigned long flags, int node)
> +struct vm_struct *get_vm_area_node_mask(unsigned long size, unsigned long flags,
> + int node, gfp_t gfp_mask)
> {
> - return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node);
> + return __get_vm_area_node(size, flags, VMALLOC_START, VMALLOC_END, node,
> + gfp_mask);
> }
>
> /* Caller must hold vmlist_lock */
> @@ -471,7 +474,7 @@
> if (!size || (size >> PAGE_SHIFT) > num_physpages)
> return NULL;
>
> - area = get_vm_area_node(size, VM_ALLOC, node);
> + area = get_vm_area_node_mask(size, VM_ALLOC, node, gfp_mask);
> if (!area)
> return NULL;
>
It was wrong for get_vm_area_node() to have assumed that it could use
GFP_KERNEL.
Please just change the top-level API of get_vm_area_node() to take a gfp_t
and don't worry about the get_vm_area_node_mask() thing.
The only callers of get_vm_area_node() are in vmalloc.c anyway. We could
in fact make it static, but I guess exposing it as an API call makes sense.
next prev parent reply other threads:[~2006-05-22 21:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-22 1:36 Giridhar Pemmasani
2006-05-22 1:51 ` Arjan van de Ven
2006-05-22 6:01 ` Giridhar Pemmasani
2006-05-22 1:53 ` Nick Piggin
2006-05-22 5:58 ` Giridhar Pemmasani
2006-05-22 6:07 ` Nick Piggin
2006-05-22 6:10 ` Nick Piggin
2006-05-22 6:14 ` Nick Piggin
2006-05-22 7:08 ` Giridhar Pemmasani
2006-05-22 7:34 ` Nick Piggin
2006-05-22 14:55 ` Giridhar Pemmasani
2006-05-22 6:56 ` Giridhar Pemmasani
2006-05-22 21:56 ` Andrew Morton [this message]
2006-05-22 22:59 ` Giridhar Pemmasani
2006-05-22 11:18 ` Andi Kleen
2006-05-22 15:12 ` Giridhar Pemmasani
2006-05-22 11:47 ` Alan Cox
2006-10-23 6:13 Giridhar Pemmasani
2006-10-23 10:38 ` Alan Cox
2006-10-23 11:11 ` Giridhar Pemmasani
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=20060522145635.252c71d4.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=giri@lmc.cs.sunysb.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
/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®