Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817AbbD0HVv (ORCPT ); Mon, 27 Apr 2015 03:21:51 -0400 Received: from lgeamrelo04.lge.com ([156.147.1.127]:64949 "EHLO lgeamrelo04.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbbD0HVo (ORCPT ); Mon, 27 Apr 2015 03:21:44 -0400 X-Original-SENDERIP: 10.177.220.157 X-Original-MAILFROM: iamjoonsoo.kim@lge.com From: Joonsoo Kim To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka , Mel Gorman , Johannes Weiner , Rik van Riel , Joonsoo Kim Subject: [PATCH 2/3] mm/page_alloc: stop fallback allocation if we already get some freepage Date: Mon, 27 Apr 2015 16:23:40 +0900 Message-Id: <1430119421-13536-2-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430119421-13536-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1430119421-13536-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2909 Lines: 89 Sometimes we try to get more freepages from buddy list than how much we really need, in order to refill pcp list. This may speed up following allocation request, but, there is a possibility to increase fragmentation if we steal freepages from other migratetype buddy list excessively. This patch changes this behaviour to stop fallback allocation in order to reduce fragmentation if we already get some freepages. CPU: 8 RAM: 512 MB with zram swap WORKLOAD: kernel build with -j12 OPTION: page owner is enabled to measure fragmentation After finishing the build, check fragmentation by 'cat /proc/pagetypeinfo' * Before Number of blocks type (movable) DMA32: 208.4 Number of mixed blocks (movable) DMA32: 139 Mixed blocks means that there is one or more allocated page for unmovable/reclaimable allocation in movable pageblock. Results shows that more than half of movable pageblock is tainted by other migratetype allocation. * After Number of blocks type (movable) DMA32: 207 Number of mixed blocks (movable) DMA32: 111.2 This result shows that non-mixed block increase by 38% in this case. Signed-off-by: Joonsoo Kim --- mm/page_alloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 044f16c..fbe2211 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1292,7 +1292,7 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype) * Call me with the zone->lock already held. */ static struct page *__rmqueue(struct zone *zone, unsigned int order, - int migratetype) + int migratetype, int index) { struct page *page; bool steal_fallback; @@ -1301,6 +1301,10 @@ retry: page = __rmqueue_smallest(zone, order, migratetype); if (unlikely(!page) && migratetype != MIGRATE_RESERVE) { + /* We already get some freepages so don't do agressive steal */ + if (index != 0) + goto out; + if (migratetype == MIGRATE_MOVABLE) page = __rmqueue_cma_fallback(zone, order); @@ -1338,7 +1342,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, spin_lock(&zone->lock); for (i = 0; i < count; ++i) { - struct page *page = __rmqueue(zone, order, migratetype); + struct page *page = __rmqueue(zone, order, migratetype, i); if (unlikely(page == NULL)) break; @@ -1749,7 +1753,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone, WARN_ON_ONCE(order > 1); } spin_lock_irqsave(&zone->lock, flags); - page = __rmqueue(zone, order, migratetype); + page = __rmqueue(zone, order, migratetype, 0); spin_unlock(&zone->lock); if (!page) goto failed; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/