lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1341588521-17744-1-git-send-email-js1304@gmail.com>
Date:	Sat,  7 Jul 2012 00:28:41 +0900
From:	Joonsoo Kim <js1304@...il.com>
To:	akpm@...ux-foundation.org
Cc:	Pekka Enberg <penberg@...nel.org>,
	Christoph Lameter <cl@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Joonsoo Kim <js1304@...il.com>
Subject: [PATCH] mm: don't invoke __alloc_pages_direct_compact when order 0

__alloc_pages_direct_compact has many arguments so invoking it is very costly.
And in almost invoking case, order is 0, so return immediately.

Let's not invoke it when order 0

Signed-off-by: Joonsoo Kim <js1304@...il.com>

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6092f33..f4039aa 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2056,7 +2056,10 @@ out:
 }
 
 #ifdef CONFIG_COMPACTION
-/* Try memory compaction for high-order allocations before reclaim */
+/*
+ * Try memory compaction for high-order allocations before reclaim
+ * Must be called with order > 0
+ */
 static struct page *
 __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
 	struct zonelist *zonelist, enum zone_type high_zoneidx,
@@ -2067,8 +2070,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
 {
 	struct page *page;
 
-	if (!order)
-		return NULL;
+	BUG_ON(!order);
 
 	if (compaction_deferred(preferred_zone, order)) {
 		*deferred_compaction = true;
@@ -2363,15 +2365,17 @@ rebalance:
 	 * Try direct compaction. The first pass is asynchronous. Subsequent
 	 * attempts after direct reclaim are synchronous
 	 */
-	page = __alloc_pages_direct_compact(gfp_mask, order,
-					zonelist, high_zoneidx,
-					nodemask,
-					alloc_flags, preferred_zone,
-					migratetype, sync_migration,
-					&deferred_compaction,
-					&did_some_progress);
-	if (page)
-		goto got_pg;
+	if (unlikely(order)) {
+		page = __alloc_pages_direct_compact(gfp_mask, order,
+						zonelist, high_zoneidx,
+						nodemask,
+						alloc_flags, preferred_zone,
+						migratetype, sync_migration,
+						&deferred_compaction,
+						&did_some_progress);
+		if (page)
+			goto got_pg;
+	}
 	sync_migration = true;
 
 	/*
@@ -2446,15 +2450,17 @@ rebalance:
 		 * direct reclaim and reclaim/compaction depends on compaction
 		 * being called after reclaim so call directly if necessary
 		 */
-		page = __alloc_pages_direct_compact(gfp_mask, order,
-					zonelist, high_zoneidx,
-					nodemask,
-					alloc_flags, preferred_zone,
-					migratetype, sync_migration,
-					&deferred_compaction,
-					&did_some_progress);
-		if (page)
-			goto got_pg;
+		if (unlikely(order)) {
+			page = __alloc_pages_direct_compact(gfp_mask, order,
+						zonelist, high_zoneidx,
+						nodemask,
+						alloc_flags, preferred_zone,
+						migratetype, sync_migration,
+						&deferred_compaction,
+						&did_some_progress);
+			if (page)
+				goto got_pg;
+		}
 	}
 
 nopage:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ