__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 <[email protected]>
---
 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


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

Reply via email to