Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198217
b: refs/heads/master
c: 6dda9d5
h: refs/heads/master
i:
  198215: 7c5fc2d
v: v3
  • Loading branch information
Corrado Zoccolo authored and Linus Torvalds committed May 25, 2010
1 parent 9108461 commit aebb3b1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e9d6c157385e4efa61cb8293e425c9d8beba70d3
refs/heads/master: 6dda9d55bf545013597724bf0cd79d01bd2bd944
30 changes: 25 additions & 5 deletions trunk/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ static inline void __free_one_page(struct page *page,
int migratetype)
{
unsigned long page_idx;
unsigned long combined_idx;
struct page *buddy;

if (unlikely(PageCompound(page)))
if (unlikely(destroy_compound_page(page, order)))
Expand All @@ -488,9 +490,6 @@ static inline void __free_one_page(struct page *page,
VM_BUG_ON(bad_range(zone, page));

while (order < MAX_ORDER-1) {
unsigned long combined_idx;
struct page *buddy;

buddy = __page_find_buddy(page, page_idx, order);
if (!page_is_buddy(page, buddy, order))
break;
Expand All @@ -505,8 +504,29 @@ static inline void __free_one_page(struct page *page,
order++;
}
set_page_order(page, order);
list_add(&page->lru,
&zone->free_area[order].free_list[migratetype]);

/*
* If this is not the largest possible page, check if the buddy
* of the next-highest order is free. If it is, it's possible
* that pages are being freed that will coalesce soon. In case,
* that is happening, add the free page to the tail of the list
* so it's less likely to be used soon and more likely to be merged
* as a higher order page
*/
if ((order < MAX_ORDER-1) && pfn_valid_within(page_to_pfn(buddy))) {
struct page *higher_page, *higher_buddy;
combined_idx = __find_combined_index(page_idx, order);
higher_page = page + combined_idx - page_idx;
higher_buddy = __page_find_buddy(higher_page, combined_idx, order + 1);
if (page_is_buddy(higher_page, higher_buddy, order + 1)) {
list_add_tail(&page->lru,
&zone->free_area[order].free_list[migratetype]);
goto out;
}
}

list_add(&page->lru, &zone->free_area[order].free_list[migratetype]);
out:
zone->free_area[order].nr_free++;
}

Expand Down

0 comments on commit aebb3b1

Please sign in to comment.