From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756838AbcA2TZ6 (ORCPT ); Fri, 29 Jan 2016 14:25:58 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36447 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112AbcA2TZ4 (ORCPT ); Fri, 29 Jan 2016 14:25:56 -0500 Date: Sat, 30 Jan 2016 03:25:51 +0800 From: ChengYi He To: Andrew Morton Cc: Mel Gorman , Michal Hocko , Vlastimil Babka , David Rientjes , Joonsoo Kim , Yaowei Bai , Xishi Qiu , Alexander Duyck , "'Kirill A . Shutemov'" , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengyihetaipei@gmail.com Subject: [RFC PATCH 2/2] mm/page_alloc: avoid splitting pages of order 2 and 3 in migration fallback Message-ID: <46b854accad3f40e4178cf3bbd215a4648551763.1454094692.git.chengyihetaipei@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While buddy system fallbacks to allocate different migration type pages, it prefers the largest feasible pages and might split the chosen page into smalller ones. If the largest feasible pages are less than or equal to orde-3 and migration fallback happens frequently, then order-2 and order-3 pages can be exhausted easily. This patch aims to allocate the smallest feasible pages for the fallback mechanism under this condition. Signed-off-by: ChengYi He --- mm/page_alloc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 50c325a..3fcb653 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1802,9 +1802,22 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype) struct page *page; /* Find the largest possible block of pages in the other list */ - for (current_order = MAX_ORDER-1; - current_order >= order && current_order <= MAX_ORDER-1; - --current_order) { + for (current_order = MAX_ORDER - 1; + current_order >= max_t(unsigned int, PAGE_ALLOC_COSTLY_ORDER + 1, order); + --current_order) { + page = __rmqueue_fallback_order(zone, order, start_migratetype, + current_order); + + if (page) + return page; + } + + /* + * While current_order <= PAGE_ALLOC_COSTLY_ORDER, find the smallest + * feasible pages in the other list to avoid splitting high order pages + */ + for (current_order = order; current_order <= PAGE_ALLOC_COSTLY_ORDER; + ++current_order) { page = __rmqueue_fallback_order(zone, order, start_migratetype, current_order); -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by kanga.kvack.org (Postfix) with ESMTP id 45ED26B025C for ; Fri, 29 Jan 2016 14:25:57 -0500 (EST) Received: by mail-pf0-f171.google.com with SMTP id x125so47026417pfb.0 for ; Fri, 29 Jan 2016 11:25:57 -0800 (PST) Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com. [2607:f8b0:400e:c00::242]) by mx.google.com with ESMTPS id n63si25948660pfb.139.2016.01.29.11.25.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jan 2016 11:25:56 -0800 (PST) Received: by mail-pf0-x242.google.com with SMTP id n128so4158359pfn.3 for ; Fri, 29 Jan 2016 11:25:56 -0800 (PST) Date: Sat, 30 Jan 2016 03:25:51 +0800 From: ChengYi He Subject: [RFC PATCH 2/2] mm/page_alloc: avoid splitting pages of order 2 and 3 in migration fallback Message-ID: <46b854accad3f40e4178cf3bbd215a4648551763.1454094692.git.chengyihetaipei@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Mel Gorman , Michal Hocko , Vlastimil Babka , David Rientjes , Joonsoo Kim , Yaowei Bai , Xishi Qiu , Alexander Duyck , "'Kirill A . Shutemov'" , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengyihetaipei@gmail.com While buddy system fallbacks to allocate different migration type pages, it prefers the largest feasible pages and might split the chosen page into smalller ones. If the largest feasible pages are less than or equal to orde-3 and migration fallback happens frequently, then order-2 and order-3 pages can be exhausted easily. This patch aims to allocate the smallest feasible pages for the fallback mechanism under this condition. Signed-off-by: ChengYi He --- mm/page_alloc.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 50c325a..3fcb653 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1802,9 +1802,22 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype) struct page *page; /* Find the largest possible block of pages in the other list */ - for (current_order = MAX_ORDER-1; - current_order >= order && current_order <= MAX_ORDER-1; - --current_order) { + for (current_order = MAX_ORDER - 1; + current_order >= max_t(unsigned int, PAGE_ALLOC_COSTLY_ORDER + 1, order); + --current_order) { + page = __rmqueue_fallback_order(zone, order, start_migratetype, + current_order); + + if (page) + return page; + } + + /* + * While current_order <= PAGE_ALLOC_COSTLY_ORDER, find the smallest + * feasible pages in the other list to avoid splitting high order pages + */ + for (current_order = order; current_order <= PAGE_ALLOC_COSTLY_ORDER; + ++current_order) { page = __rmqueue_fallback_order(zone, order, start_migratetype, current_order); -- 1.9.1 -- 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: email@kvack.org