From 8b97b620f41696f83375a250735268249ce8069a Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 3 Oct 2007 20:42:44 -0700 Subject: vcompound: Debugging aid Virtualized Compound Pages are rare in practice and thus subtle bugs may creep in if we do not test the kernel with Virtualized Compounds. CONFIG_VFALLBACK_ALWAYS results in virtualizable compound allocation requests always result in virtualized compounds. Signed-off-by: Christoph Lameter --- lib/Kconfig.debug | 12 ++++++++++++ mm/vmalloc.c | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) Index: linux-2.6.25-mm1/lib/Kconfig.debug =================================================================== --- linux-2.6.25-mm1.orig/lib/Kconfig.debug 2008-04-25 23:17:40.341140277 -0700 +++ linux-2.6.25-mm1/lib/Kconfig.debug 2008-04-25 23:37:21.039899502 -0700 @@ -158,6 +158,18 @@ config DETECT_SOFTLOCKUP can be detected via the NMI-watchdog, on platforms that support it.) +config VIRTUALIZE_COMPOUNDS_ALWAYS + bool "Always fall back to virtualzed compound pages" + default y + help + Virtualized compound pages are only allocated if there is no linear + memory available. They are a fallback and potential issues created by + the use of virtual mappings instead of physically linear memory may + not surface because of the infrequent need to create them. Enabling + this option makes every allocation that allows a fallback to a + virtual mapping use the virtual mapping. May have a significant + performance impact. + config SCHED_DEBUG bool "Collect scheduler debugging info" depends on DEBUG_KERNEL && PROC_FS Index: linux-2.6.25-mm1/mm/vmalloc.c =================================================================== --- linux-2.6.25-mm1.orig/mm/vmalloc.c 2008-04-25 23:28:50.922390376 -0700 +++ linux-2.6.25-mm1/mm/vmalloc.c 2008-04-26 00:58:56.420418839 -0700 @@ -496,7 +496,6 @@ static void *__vmalloc_area_node(struct unsigned int nr_pages, array_size, i; nr_pages = (area->size - PAGE_SIZE) >> PAGE_SHIFT; - r array_size = (nr_pages * sizeof(struct page *)); area->nr_pages = nr_pages; @@ -1177,7 +1176,13 @@ struct page *alloc_vcompound(gfp_t flags struct vm_struct *vm; struct page *page; - page = alloc_pages(flags | __GFP_NORETRY | __GFP_NOWARN, order); +#ifdef CONFIG_VFALLBACK_ALWAYS + if (system_state == SYSTEM_RUNNING && order) + page = NULL; + else +#endif + page = alloc_pages(flags | __GFP_NORETRY | __GFP_NOWARN, + order); if (page || !order) return page; @@ -1194,8 +1199,14 @@ void *__alloc_vcompound(gfp_t flags, int struct vm_struct *vm; void *addr; - addr = (void *)__get_free_pages(flags | __GFP_NORETRY | __GFP_NOWARN, - order); +#ifdef CONFIG_VFALLBACK_ALWAYS + if (system_state == SYSTEM_RUNNING && order) + addr = NULL; + else +#endif + addr = (void *)__get_free_pages( + flags | __GFP_NORETRY | __GFP_NOWARN, order); + if (addr || !order) return addr;