Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbWJWGNv (ORCPT ); Mon, 23 Oct 2006 02:13:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751577AbWJWGNv (ORCPT ); Mon, 23 Oct 2006 02:13:51 -0400 Received: from lmcgw.cs.sunysb.edu ([130.245.128.4]:33739 "EHLO smtp.lmc.cs.stonybrook.edu") by vger.kernel.org with ESMTP id S1751573AbWJWGNu (ORCPT ); Mon, 23 Oct 2006 02:13:50 -0400 Date: Mon, 23 Oct 2006 02:13:48 -0400 From: Giridhar Pemmasani To: linux-kernel@vger.kernel.org Subject: __vmalloc with GFP_ATOMIC causes 'sleeping from invalid context' Cc: pgiri@yahoo.com User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 MULE XEmacs/21.4 (patch 19) (Constant Variable) (i386-debian-linux) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20061023061348.AC97DEF086@wolfe.lmc.cs.stonybrook.edu> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3537 Lines: 98 This is follow up of earlier patch: http://marc.theaimsgroup.com/?l=linux-kernel&m=114833505625992&w=2 Apparently the patch has not been merged (yet), so resending it. The patch is against 2.6.19-rc2. Synopsis of patch: If __vmalloc is called to allocate memory with GFP_ATOMIC in atomic context, the chain of calls results in __get_vm_area_node allocating memory for vm_struct with GFP_KERNEL, causing the 'sleeping from invalid context' warning. This patch fixes it by passing the gfp flags along so __get_vm_area_node allocates memory for vm_struct with the same flags. Thanks, Giri diff -Naur linux-2.6.19-rc2.orig/include/linux/vmalloc.h linux-2.6.19-rc2/include/linux/vmalloc.h --- linux-2.6.19-rc2.orig/include/linux/vmalloc.h 2006-10-23 01:43:35.000000000 -0400 +++ linux-2.6.19-rc2/include/linux/vmalloc.h 2006-10-23 01:45:24.000000000 -0400 @@ -60,7 +60,8 @@ 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); + unsigned long flags, int node, + gfp_t gfp_mask); extern struct vm_struct *remove_vm_area(void *addr); extern int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages); diff -Naur linux-2.6.19-rc2.orig/mm/vmalloc.c linux-2.6.19-rc2/mm/vmalloc.c --- linux-2.6.19-rc2.orig/mm/vmalloc.c 2006-10-23 01:43:55.000000000 -0400 +++ linux-2.6.19-rc2/mm/vmalloc.c 2006-10-23 01:45:24.000000000 -0400 @@ -160,13 +160,15 @@ 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; unsigned long addr; + BUG_ON(in_interrupt()); if (flags & VM_IOREMAP) { int bit = fls(size); @@ -180,7 +182,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; @@ -236,7 +238,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); } /** @@ -253,9 +255,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(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 */ @@ -484,7 +488,7 @@ if (!size || (size >> PAGE_SHIFT) > num_physpages) return NULL; - area = get_vm_area_node(size, VM_ALLOC, node); + area = get_vm_area_node(size, VM_ALLOC, node, gfp_mask); if (!area) return NULL; - 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/