linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] mm, rmap: do easy-job first in anon_vma_fork
@ 2013-08-06  8:43 Joonsoo Kim
  2013-08-06  8:43 ` [PATCH 2/4] mm, rmap: allocate anon_vma_chain before starting to link anon_vma_chain Joonsoo Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Joonsoo Kim @ 2013-08-06  8:43 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Joonsoo Kim, Minchan Kim, Johannes Weiner,
	Mel Gorman, Rik van Riel, Michel Lespinasse, Joonsoo Kim

If we fail due to some errorous situation, it is better to quit
without doing heavy work. So changing order of execution.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/mm/rmap.c b/mm/rmap.c
index a149e3a..c2f51cb 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -278,19 +278,19 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
 	if (!pvma->anon_vma)
 		return 0;
 
+	/* First, allocate required objects */
+	avc = anon_vma_chain_alloc(GFP_KERNEL);
+	if (!avc)
+		goto out_error;
+	anon_vma = anon_vma_alloc();
+	if (!anon_vma)
+		goto out_error_free_avc;
+
 	/*
-	 * First, attach the new VMA to the parent VMA's anon_vmas,
+	 * Then attach the new VMA to the parent VMA's anon_vmas,
 	 * so rmap can find non-COWed pages in child processes.
 	 */
 	if (anon_vma_clone(vma, pvma))
-		return -ENOMEM;
-
-	/* Then add our own anon_vma. */
-	anon_vma = anon_vma_alloc();
-	if (!anon_vma)
-		goto out_error;
-	avc = anon_vma_chain_alloc(GFP_KERNEL);
-	if (!avc)
 		goto out_error_free_anon_vma;
 
 	/*
@@ -312,10 +312,11 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
 
 	return 0;
 
- out_error_free_anon_vma:
+out_error_free_anon_vma:
 	put_anon_vma(anon_vma);
- out_error:
-	unlink_anon_vmas(vma);
+out_error_free_avc:
+	anon_vma_chain_free(avc);
+out_error:
 	return -ENOMEM;
 }
 
-- 
1.7.9.5

--
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] 11+ messages in thread

end of thread, other threads:[~2013-08-07  7:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-06  8:43 [PATCH 1/4] mm, rmap: do easy-job first in anon_vma_fork Joonsoo Kim
2013-08-06  8:43 ` [PATCH 2/4] mm, rmap: allocate anon_vma_chain before starting to link anon_vma_chain Joonsoo Kim
2013-08-07  6:08   ` Johannes Weiner
2013-08-07  7:17     ` Joonsoo Kim
2013-08-06  8:43 ` [PATCH 3/4] mm, rmap: minimize lock hold when unlink_anon_vmas Joonsoo Kim
2013-08-07  6:11   ` Johannes Weiner
2013-08-07  7:18     ` Joonsoo Kim
2013-08-06  8:43 ` [PATCH 4/4] mm, page_alloc: optimize batch count in free_pcppages_bulk() Joonsoo Kim
2013-08-06  8:48   ` Joonsoo Kim
2013-08-06 12:58 ` [PATCH 1/4] mm, rmap: do easy-job first in anon_vma_fork Johannes Weiner
2013-08-07  7:16   ` Joonsoo Kim

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).