linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mm/vmalloc: don't set area->caller twice
@ 2013-09-02 12:35 Wanpeng Li
  2013-09-02 12:35 ` [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice Wanpeng Li
  2013-09-02 12:35 ` [PATCH 3/3] mm/vmalloc: move VM_UNINITIALIZED just before show_numa_info Wanpeng Li
  0 siblings, 2 replies; 4+ messages in thread
From: Wanpeng Li @ 2013-09-02 12:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joonsoo Kim, David Rientjes, KOSAKI Motohiro, linux-mm,
	linux-kernel, Wanpeng Li

The caller address has already been set in set_vmalloc_vm(), there's no need 
to set it again in __vmalloc_area_node.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/vmalloc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1074543..d78d117 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1566,7 +1566,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                pages = kmalloc_node(array_size, nested_gfp, node);
        }
        area->pages = pages;
-       area->caller = caller;
        if (!area->pages) {
                remove_vm_area(area->addr);
                kfree(area);
--
1.8.1.2


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice
  2013-09-02 12:35 [PATCH 1/3] mm/vmalloc: don't set area->caller twice Wanpeng Li
@ 2013-09-02 12:35 ` Wanpeng Li
  2013-09-17 20:11   ` Andrew Morton
  2013-09-02 12:35 ` [PATCH 3/3] mm/vmalloc: move VM_UNINITIALIZED just before show_numa_info Wanpeng Li
  1 sibling, 1 reply; 4+ messages in thread
From: Wanpeng Li @ 2013-09-02 12:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joonsoo Kim, David Rientjes, KOSAKI Motohiro, linux-mm,
	linux-kernel, Wanpeng Li

Don't warning twice in __vmalloc_area_node and __vmalloc_node_range if 
__vmalloc_area_node allocation failure.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ee41cc6..e324d38 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1635,7 +1635,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
 
 	addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller);
 	if (!addr)
-		goto fail;
+		return NULL;
 
 	/*
 	 * In this function, newly allocated vm_struct has VM_UNINITIALIZED
-- 
1.8.1.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] mm/vmalloc: move VM_UNINITIALIZED just before show_numa_info
  2013-09-02 12:35 [PATCH 1/3] mm/vmalloc: don't set area->caller twice Wanpeng Li
  2013-09-02 12:35 ` [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice Wanpeng Li
@ 2013-09-02 12:35 ` Wanpeng Li
  1 sibling, 0 replies; 4+ messages in thread
From: Wanpeng Li @ 2013-09-02 12:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Joonsoo Kim, David Rientjes, KOSAKI Motohiro, linux-mm,
	linux-kernel, Wanpeng Li

The VM_UNINITIALIZED/VM_UNLIST flag introduced by commit f5252e00(mm: avoid 
null pointer access in vm_struct via /proc/vmallocinfo) is used to avoid 
accessing the pages field with unallocated page when show_numa_info() is 
called. This patch move the check just before show_numa_info in order that 
some messages still can be dumped via /proc/vmallocinfo.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/vmalloc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index e3ec8b4..c4720cd 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2590,11 +2590,6 @@ static int s_show(struct seq_file *m, void *p)
 
 	v = va->vm;
 
-	/* Pair with smp_wmb() in clear_vm_uninitialized_flag() */
-	smp_rmb();
-	if (v->flags & VM_UNINITIALIZED)
-		return 0;
-
 	seq_printf(m, "0x%pK-0x%pK %7ld",
 		v->addr, v->addr + v->size, v->size);
 
@@ -2622,6 +2617,11 @@ static int s_show(struct seq_file *m, void *p)
 	if (v->flags & VM_VPAGES)
 		seq_printf(m, " vpages");
 
+	/* Pair with smp_wmb() in clear_vm_uninitialized_flag() */
+	smp_rmb();
+	if (v->flags & VM_UNINITIALIZED)
+		return;
+
 	show_numa_info(m, v);
 	seq_putc(m, '\n');
 	return 0;
-- 
1.8.1.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice
  2013-09-02 12:35 ` [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice Wanpeng Li
@ 2013-09-17 20:11   ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2013-09-17 20:11 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Joonsoo Kim, David Rientjes, KOSAKI Motohiro, linux-mm,
	linux-kernel

On Mon,  2 Sep 2013 20:35:44 +0800 Wanpeng Li <liwanp@linux.vnet.ibm.com> wrote:

> Don't warning twice in __vmalloc_area_node and __vmalloc_node_range if 
> __vmalloc_area_node allocation failure.
> 
> Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
> ---
>  mm/vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index ee41cc6..e324d38 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1635,7 +1635,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
>  
>  	addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller);
>  	if (!addr)
> -		goto fail;
> +		return NULL;
>  
>  	/*
>  	 * In this function, newly allocated vm_struct has VM_UNINITIALIZED

Putting a `return' in the middle of a function is often a bad thing -
functions which have multiple return points often lead to resource and
locking leaks.

It's particularly bad to have that return *after* a bunch of "goto
fail" statements - the result is utter spaghetti.

Fix:

--- a/mm/vmalloc.c~mm-vmalloc-dont-warn-about-vmalloc-allocation-failure-twice-fix
+++ a/mm/vmalloc.c
@@ -1626,16 +1626,16 @@ void *__vmalloc_node_range(unsigned long
 
 	size = PAGE_ALIGN(size);
 	if (!size || (size >> PAGE_SHIFT) > totalram_pages)
-		goto fail;
+		goto warn;
 
 	area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
 				  start, end, node, gfp_mask, caller);
 	if (!area)
-		goto fail;
+		goto warn;
 
 	addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller);
 	if (!addr)
-		return NULL;
+		goto fail;
 
 	/*
 	 * In this function, newly allocated vm_struct has VM_UNINITIALIZED
@@ -1653,10 +1653,11 @@ void *__vmalloc_node_range(unsigned long
 
 	return addr;
 
-fail:
+warn:
 	warn_alloc_failed(gfp_mask, 0,
 			  "vmalloc: allocation failure: %lu bytes\n",
 			  real_size);
+fail:
 	return NULL;
 }
 
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-17 20:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-02 12:35 [PATCH 1/3] mm/vmalloc: don't set area->caller twice Wanpeng Li
2013-09-02 12:35 ` [PATCH 2/3] mm/vmalloc: don't warning vmalloc allocation failure twice Wanpeng Li
2013-09-17 20:11   ` Andrew Morton
2013-09-02 12:35 ` [PATCH 3/3] mm/vmalloc: move VM_UNINITIALIZED just before show_numa_info Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).