All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <xa1tk3tgjn8n.fsf@mina86.com>

diff --git a/a/1.txt b/N1/1.txt
index 14d91a0..8ce74b5 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -14,3 +14,141 @@ Would it make sense to *always* use MIGRATE_CMA for movable allocations
 before MIGRATE_MOVABLE?  Ie. how about this patch (not tested):
 
 ------------------------- >8 -------------------------------------------------
+>From 790a3b5743414f2770e413e5e8866679de2920b4 Mon Sep 17 00:00:00 2001
+Message-Id: <790a3b5743414f2770e413e5e8866679de2920b4.1353425911.git.mina86@mina86.com>
+From: Michal Nazarewicz <mina86@mina86.com>
+Date: Tue, 20 Nov 2012 16:37:50 +0100
+Subject: [PATCH] mm: cma: on movable allocations try MIGRATE_CMA first
+
+It has been observed that system tends to keep a lot of CMA free pages
+even in very high memory pressure use cases.  The CMA fallback for
+movable pages is used very rarely, only when system is completely
+pruned from MOVABLE pages.  This means that the out-of-memory is
+triggered for unmovable allocations even when there are many CMA pages
+available.  This problem was not observed previously since movable
+pages were used as a fallback for unmovable allocations.
+
+To avoid such situation this commit changes the allocation order so
+that on movable allocations the MIGRATE_CMA pageblocks are used first.
+
+This change means that the MIGRATE_CMA can be removed from fallback
+path of the MIGRATE_MOVABLE type.  This means that the
+__rmqueue_fallback() function will never deal with CMA pages and thus
+all the checks around MIGRATE_CMA can be removed from that function.
+
+Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
+Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
+Cc: Kyungmin Park <kyungmin.park@samsung.com>
+---
+ mm/page_alloc.c |   55 +++++++++++++++++++++++++------------------------------
+ 1 files changed, 25 insertions(+), 30 deletions(-)
+
+diff --git a/mm/page_alloc.c b/mm/page_alloc.c
+index bb90971..b60bd75 100644
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -893,14 +893,12 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,
+  * This array describes the order lists are fallen back to when
+  * the free lists for the desirable migrate type are depleted
+  */
+-static int fallbacks[MIGRATE_TYPES][4] = {
++static int fallbacks[MIGRATE_TYPES][3] = {
+ 	[MIGRATE_UNMOVABLE]   = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE,     MIGRATE_RESERVE },
+ 	[MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE,     MIGRATE_RESERVE },
++	[MIGRATE_MOVABLE]     = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE,   MIGRATE_RESERVE },
+ #ifdef CONFIG_CMA
+-	[MIGRATE_MOVABLE]     = { MIGRATE_CMA,         MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_RESERVE },
+ 	[MIGRATE_CMA]         = { MIGRATE_RESERVE }, /* Never used */
+-#else
+-	[MIGRATE_MOVABLE]     = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE,   MIGRATE_RESERVE },
+ #endif
+ 	[MIGRATE_RESERVE]     = { MIGRATE_RESERVE }, /* Never used */
+ 	[MIGRATE_ISOLATE]     = { MIGRATE_RESERVE }, /* Never used */
+@@ -1019,17 +1017,10 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
+ 			 * pages to the preferred allocation list. If falling
+ 			 * back for a reclaimable kernel allocation, be more
+ 			 * aggressive about taking ownership of free pages
+-			 *
+-			 * On the other hand, never change migration
+-			 * type of MIGRATE_CMA pageblocks nor move CMA
+-			 * pages on different free lists. We don't
+-			 * want unmovable pages to be allocated from
+-			 * MIGRATE_CMA areas.
+ 			 */
+-			if (!is_migrate_cma(migratetype) &&
+-			    (unlikely(current_order >= pageblock_order / 2) ||
+-			     start_migratetype == MIGRATE_RECLAIMABLE ||
+-			     page_group_by_mobility_disabled)) {
++			if (unlikely(current_order >= pageblock_order / 2) ||
++			    start_migratetype == MIGRATE_RECLAIMABLE ||
++			    page_group_by_mobility_disabled) {
+ 				int pages;
+ 				pages = move_freepages_block(zone, page,
+ 								start_migratetype);
+@@ -1048,14 +1039,12 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
+ 			rmv_page_order(page);
+ 
+ 			/* Take ownership for orders >= pageblock_order */
+-			if (current_order >= pageblock_order &&
+-			    !is_migrate_cma(migratetype))
++			if (current_order >= pageblock_order)
+ 				change_pageblock_range(page, current_order,
+ 							start_migratetype);
+ 
+ 			expand(zone, page, order, current_order, area,
+-			       is_migrate_cma(migratetype)
+-			     ? migratetype : start_migratetype);
++			       start_migratetype);
+ 
+ 			trace_mm_page_alloc_extfrag(page, order, current_order,
+ 				start_migratetype, migratetype);
+@@ -1076,21 +1065,27 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,
+ {
+ 	struct page *page;
+ 
+-retry_reserve:
+-	page = __rmqueue_smallest(zone, order, migratetype);
++#ifdef CONFIG_CMA
++	if (migratetype == MIGRATE_MOVABLE)
++		migratetype = MIGRATE_CMA;
++#endif
+ 
+-	if (unlikely(!page) && migratetype != MIGRATE_RESERVE) {
+-		page = __rmqueue_fallback(zone, order, migratetype);
++	for(;;) {
++		page = __rmqueue_smallest(zone, order, migratetype);
++		if (likely(page) || migratetype == MIGRATE_RESERVE)
++			break;
+ 
+-		/*
+-		 * Use MIGRATE_RESERVE rather than fail an allocation. goto
+-		 * is used because __rmqueue_smallest is an inline function
+-		 * and we want just one call site
+-		 */
+-		if (!page) {
+-			migratetype = MIGRATE_RESERVE;
+-			goto retry_reserve;
++		if (is_migrate_cma(migratetype)) {
++			migratetype = MIGRATE_MOVABLE;
++			continue;
+ 		}
++
++		page = __rmqueue_fallback(zone, order, migratetype);
++		if (page)
++			break;
++
++		/* Use MIGRATE_RESERVE rather than fail an allocation. */
++		migratetype = MIGRATE_RESERVE;
+ 	}
+ 
+ 	trace_mm_page_alloc_zone_locked(page, order, migratetype);
+-- 
+1.7.7.3
+
+------------------------- >8 -------------------------------------------------
+
+-- 
+Best regards,                                         _     _
+.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
+..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
+ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
diff --git a/N1/2.1.hdr b/N1/2.1.hdr
new file mode 100644
index 0000000..a1f9e38
--- /dev/null
+++ b/N1/2.1.hdr
@@ -0,0 +1 @@
+Content-Type: text/plain
diff --git a/N1/2.1.txt b/N1/2.1.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/N1/2.1.txt
@@ -0,0 +1 @@
+
diff --git a/N1/2.2.bin b/N1/2.2.bin
new file mode 100644
index 0000000..4b4e08b
--- /dev/null
+++ b/N1/2.2.bin
@@ -0,0 +1,17 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.11 (GNU/Linux)
+
+iQIcBAEBAgAGBQJQq6SYAAoJECBgQBJQdR/0e4EP/ivO9Y56YDT4AKitaF0+AbgC
+v7oYMVCxc817TESwJ7wpIeHfUshVSqNw9EsLr16zSZoL+P2Ktqvou8Nm+Td7OhcI
+j+us23pWZf2uUvqYID5399n5aW/yhmKXUgP97pyIPf9EfNbZKJz052ZrOfBnborT
+k861b/Iz75YdcJssEgm3TNXUy28nIw5ZWcOt7XAA+xvTE1xtzJ2aNDvsEEfwYi/q
+w/mr6tRjsOcEjP/vchqAOj8sXONyPvhOjRBcHZ8uZjP+73DXjDcRSigAgDLB0nje
+vhlOy60PayMfLc1jbMOnAfUDo97nKj0w3SLNvgNNse7CtluwuR+TVEw2G+Z2yoVg
+yWWULNMER5IwcBnjg963t0b6ldK8udI+EQvYYnzDtw6RjOQkN1514+sK71z6FNam
+Hqhgot+Fww9RU8YhWrVZS9NgctlZIedty/hFGH+V1WwUGdmhzIBlLxYw1YMG4Z1M
+7Yht19iOYNXZCq2VipgWhbpclmPhAm19UuDL9CThEhz5hzStfyFB0sWGg2g1MN7y
+P5sTG4TrL6Vtr+F3uu3WODQrBKU/q0999h83rwLDBJl5GPEZeweSvxLTFlYO42zC
+ir8iAhjycb7Sfn4gQbdoKBO6yCTN218F3wAXOVN4rLhMGN+DjFwFc30xmJJXrD6Y
+cUwPqwU6pFT7tQKubXfA
+=98nZ
+-----END PGP SIGNATURE-----
diff --git a/N1/2.2.hdr b/N1/2.2.hdr
new file mode 100644
index 0000000..a09cc95
--- /dev/null
+++ b/N1/2.2.hdr
@@ -0,0 +1 @@
+Content-Type: application/pgp-signature
diff --git a/a/content_digest b/N1/content_digest
index 7846b10..a15e9d3 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -30,6 +30,165 @@
  "Would it make sense to *always* use MIGRATE_CMA for movable allocations\n"
  "before MIGRATE_MOVABLE?  Ie. how about this patch (not tested):\n"
  "\n"
- ------------------------- >8 -------------------------------------------------
+ "------------------------- >8 -------------------------------------------------\n"
+ ">From 790a3b5743414f2770e413e5e8866679de2920b4 Mon Sep 17 00:00:00 2001\n"
+ "Message-Id: <790a3b5743414f2770e413e5e8866679de2920b4.1353425911.git.mina86@mina86.com>\n"
+ "From: Michal Nazarewicz <mina86@mina86.com>\n"
+ "Date: Tue, 20 Nov 2012 16:37:50 +0100\n"
+ "Subject: [PATCH] mm: cma: on movable allocations try MIGRATE_CMA first\n"
+ "\n"
+ "It has been observed that system tends to keep a lot of CMA free pages\n"
+ "even in very high memory pressure use cases.  The CMA fallback for\n"
+ "movable pages is used very rarely, only when system is completely\n"
+ "pruned from MOVABLE pages.  This means that the out-of-memory is\n"
+ "triggered for unmovable allocations even when there are many CMA pages\n"
+ "available.  This problem was not observed previously since movable\n"
+ "pages were used as a fallback for unmovable allocations.\n"
+ "\n"
+ "To avoid such situation this commit changes the allocation order so\n"
+ "that on movable allocations the MIGRATE_CMA pageblocks are used first.\n"
+ "\n"
+ "This change means that the MIGRATE_CMA can be removed from fallback\n"
+ "path of the MIGRATE_MOVABLE type.  This means that the\n"
+ "__rmqueue_fallback() function will never deal with CMA pages and thus\n"
+ "all the checks around MIGRATE_CMA can be removed from that function.\n"
+ "\n"
+ "Signed-off-by: Michal Nazarewicz <mina86@mina86.com>\n"
+ "Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>\n"
+ "Cc: Kyungmin Park <kyungmin.park@samsung.com>\n"
+ "---\n"
+ " mm/page_alloc.c |   55 +++++++++++++++++++++++++------------------------------\n"
+ " 1 files changed, 25 insertions(+), 30 deletions(-)\n"
+ "\n"
+ "diff --git a/mm/page_alloc.c b/mm/page_alloc.c\n"
+ "index bb90971..b60bd75 100644\n"
+ "--- a/mm/page_alloc.c\n"
+ "+++ b/mm/page_alloc.c\n"
+ "@@ -893,14 +893,12 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order,\n"
+ "  * This array describes the order lists are fallen back to when\n"
+ "  * the free lists for the desirable migrate type are depleted\n"
+ "  */\n"
+ "-static int fallbacks[MIGRATE_TYPES][4] = {\n"
+ "+static int fallbacks[MIGRATE_TYPES][3] = {\n"
+ " \t[MIGRATE_UNMOVABLE]   = { MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE,     MIGRATE_RESERVE },\n"
+ " \t[MIGRATE_RECLAIMABLE] = { MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE,     MIGRATE_RESERVE },\n"
+ "+\t[MIGRATE_MOVABLE]     = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE,   MIGRATE_RESERVE },\n"
+ " #ifdef CONFIG_CMA\n"
+ "-\t[MIGRATE_MOVABLE]     = { MIGRATE_CMA,         MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_RESERVE },\n"
+ " \t[MIGRATE_CMA]         = { MIGRATE_RESERVE }, /* Never used */\n"
+ "-#else\n"
+ "-\t[MIGRATE_MOVABLE]     = { MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE,   MIGRATE_RESERVE },\n"
+ " #endif\n"
+ " \t[MIGRATE_RESERVE]     = { MIGRATE_RESERVE }, /* Never used */\n"
+ " \t[MIGRATE_ISOLATE]     = { MIGRATE_RESERVE }, /* Never used */\n"
+ "@@ -1019,17 +1017,10 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)\n"
+ " \t\t\t * pages to the preferred allocation list. If falling\n"
+ " \t\t\t * back for a reclaimable kernel allocation, be more\n"
+ " \t\t\t * aggressive about taking ownership of free pages\n"
+ "-\t\t\t *\n"
+ "-\t\t\t * On the other hand, never change migration\n"
+ "-\t\t\t * type of MIGRATE_CMA pageblocks nor move CMA\n"
+ "-\t\t\t * pages on different free lists. We don't\n"
+ "-\t\t\t * want unmovable pages to be allocated from\n"
+ "-\t\t\t * MIGRATE_CMA areas.\n"
+ " \t\t\t */\n"
+ "-\t\t\tif (!is_migrate_cma(migratetype) &&\n"
+ "-\t\t\t    (unlikely(current_order >= pageblock_order / 2) ||\n"
+ "-\t\t\t     start_migratetype == MIGRATE_RECLAIMABLE ||\n"
+ "-\t\t\t     page_group_by_mobility_disabled)) {\n"
+ "+\t\t\tif (unlikely(current_order >= pageblock_order / 2) ||\n"
+ "+\t\t\t    start_migratetype == MIGRATE_RECLAIMABLE ||\n"
+ "+\t\t\t    page_group_by_mobility_disabled) {\n"
+ " \t\t\t\tint pages;\n"
+ " \t\t\t\tpages = move_freepages_block(zone, page,\n"
+ " \t\t\t\t\t\t\t\tstart_migratetype);\n"
+ "@@ -1048,14 +1039,12 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)\n"
+ " \t\t\trmv_page_order(page);\n"
+ " \n"
+ " \t\t\t/* Take ownership for orders >= pageblock_order */\n"
+ "-\t\t\tif (current_order >= pageblock_order &&\n"
+ "-\t\t\t    !is_migrate_cma(migratetype))\n"
+ "+\t\t\tif (current_order >= pageblock_order)\n"
+ " \t\t\t\tchange_pageblock_range(page, current_order,\n"
+ " \t\t\t\t\t\t\tstart_migratetype);\n"
+ " \n"
+ " \t\t\texpand(zone, page, order, current_order, area,\n"
+ "-\t\t\t       is_migrate_cma(migratetype)\n"
+ "-\t\t\t     ? migratetype : start_migratetype);\n"
+ "+\t\t\t       start_migratetype);\n"
+ " \n"
+ " \t\t\ttrace_mm_page_alloc_extfrag(page, order, current_order,\n"
+ " \t\t\t\tstart_migratetype, migratetype);\n"
+ "@@ -1076,21 +1065,27 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,\n"
+ " {\n"
+ " \tstruct page *page;\n"
+ " \n"
+ "-retry_reserve:\n"
+ "-\tpage = __rmqueue_smallest(zone, order, migratetype);\n"
+ "+#ifdef CONFIG_CMA\n"
+ "+\tif (migratetype == MIGRATE_MOVABLE)\n"
+ "+\t\tmigratetype = MIGRATE_CMA;\n"
+ "+#endif\n"
+ " \n"
+ "-\tif (unlikely(!page) && migratetype != MIGRATE_RESERVE) {\n"
+ "-\t\tpage = __rmqueue_fallback(zone, order, migratetype);\n"
+ "+\tfor(;;) {\n"
+ "+\t\tpage = __rmqueue_smallest(zone, order, migratetype);\n"
+ "+\t\tif (likely(page) || migratetype == MIGRATE_RESERVE)\n"
+ "+\t\t\tbreak;\n"
+ " \n"
+ "-\t\t/*\n"
+ "-\t\t * Use MIGRATE_RESERVE rather than fail an allocation. goto\n"
+ "-\t\t * is used because __rmqueue_smallest is an inline function\n"
+ "-\t\t * and we want just one call site\n"
+ "-\t\t */\n"
+ "-\t\tif (!page) {\n"
+ "-\t\t\tmigratetype = MIGRATE_RESERVE;\n"
+ "-\t\t\tgoto retry_reserve;\n"
+ "+\t\tif (is_migrate_cma(migratetype)) {\n"
+ "+\t\t\tmigratetype = MIGRATE_MOVABLE;\n"
+ "+\t\t\tcontinue;\n"
+ " \t\t}\n"
+ "+\n"
+ "+\t\tpage = __rmqueue_fallback(zone, order, migratetype);\n"
+ "+\t\tif (page)\n"
+ "+\t\t\tbreak;\n"
+ "+\n"
+ "+\t\t/* Use MIGRATE_RESERVE rather than fail an allocation. */\n"
+ "+\t\tmigratetype = MIGRATE_RESERVE;\n"
+ " \t}\n"
+ " \n"
+ " \ttrace_mm_page_alloc_zone_locked(page, order, migratetype);\n"
+ "-- \n"
+ "1.7.7.3\n"
+ "\n"
+ "------------------------- >8 -------------------------------------------------\n"
+ "\n"
+ "-- \n"
+ "Best regards,                                         _     _\n"
+ ".o. | Liege of Serenely Enlightened Majesty of      o' \\,=./ `o\n"
+ "..o | Computer Science,  Micha\305\202 \342\200\234mina86\342\200\235 Nazarewicz    (o o)\n"
+ ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
+ "\02:2.1\0"
+ "b\0"
+ "\02:2.2\0"
+ "b\0"
+ "-----BEGIN PGP SIGNATURE-----\n"
+ "Version: GnuPG v1.4.11 (GNU/Linux)\n"
+ "\n"
+ "iQIcBAEBAgAGBQJQq6SYAAoJECBgQBJQdR/0e4EP/ivO9Y56YDT4AKitaF0+AbgC\n"
+ "v7oYMVCxc817TESwJ7wpIeHfUshVSqNw9EsLr16zSZoL+P2Ktqvou8Nm+Td7OhcI\n"
+ "j+us23pWZf2uUvqYID5399n5aW/yhmKXUgP97pyIPf9EfNbZKJz052ZrOfBnborT\n"
+ "k861b/Iz75YdcJssEgm3TNXUy28nIw5ZWcOt7XAA+xvTE1xtzJ2aNDvsEEfwYi/q\n"
+ "w/mr6tRjsOcEjP/vchqAOj8sXONyPvhOjRBcHZ8uZjP+73DXjDcRSigAgDLB0nje\n"
+ "vhlOy60PayMfLc1jbMOnAfUDo97nKj0w3SLNvgNNse7CtluwuR+TVEw2G+Z2yoVg\n"
+ "yWWULNMER5IwcBnjg963t0b6ldK8udI+EQvYYnzDtw6RjOQkN1514+sK71z6FNam\n"
+ "Hqhgot+Fww9RU8YhWrVZS9NgctlZIedty/hFGH+V1WwUGdmhzIBlLxYw1YMG4Z1M\n"
+ "7Yht19iOYNXZCq2VipgWhbpclmPhAm19UuDL9CThEhz5hzStfyFB0sWGg2g1MN7y\n"
+ "P5sTG4TrL6Vtr+F3uu3WODQrBKU/q0999h83rwLDBJl5GPEZeweSvxLTFlYO42zC\n"
+ "ir8iAhjycb7Sfn4gQbdoKBO6yCTN218F3wAXOVN4rLhMGN+DjFwFc30xmJJXrD6Y\n"
+ "cUwPqwU6pFT7tQKubXfA\n"
+ "=98nZ\n"
+ -----END PGP SIGNATURE-----
 
-dd87851cbaf109a0f9719064c65e84d80200c0fce407ce1e0cb16409121d0334
+2325328dba96e169b2a33b63ba51a0daa51e4e2887c191249c7aedb6a4472856

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.