From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752814AbbGaJbL (ORCPT ); Fri, 31 Jul 2015 05:31:11 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:30234 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbbGaJbK (ORCPT ); Fri, 31 Jul 2015 05:31:10 -0400 Message-ID: <55BB4027.7080200@huawei.com> Date: Fri, 31 Jul 2015 17:30:15 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andrew Morton , Mel Gorman , Vlastimil Babka , Johannes Weiner , Michal Hocko , , , CC: Linux MM , LKML Subject: [PATCH] mm: add the block to the tail of the list in expand() Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.55BB4032.002E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9737e960d48d0b007c86f1fca1cb7c1b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __free_one_page() will judge whether the the next-highest order is free, then add the block to the tail or not. So when we split large order block, add the small block to the tail, it will reduce fragment. Signed-off-by: Xishi Qiu --- mm/page_alloc.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 506eac8..517a11c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1267,7 +1267,12 @@ static inline void expand(struct zone *zone, struct page *page, set_page_guard(zone, &page[size], high, migratetype); continue; } - list_add(&page[size].lru, &area->free_list[migratetype]); + /* + * Add the block to the tail of the list, so it's less likely + * to be used soon and more likely to be merged when the page + * is freed. + */ + list_add_tail(&page[size].lru, &area->free_list[migratetype]); area->nr_free++; set_page_order(&page[size], high); } -- 1.7.1