Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230818
b: refs/heads/master
c: 43506fa
h: refs/heads/master
v: v3
  • Loading branch information
KyongHo Cho authored and Linus Torvalds committed Jan 14, 2011
1 parent d7c5946 commit fbcb100
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 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: 5520e89485252c759ee60d313e9422447659947b
refs/heads/master: 43506fad21ca3d8dc59e768ff458f7c5e5c01086
25 changes: 10 additions & 15 deletions trunk/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,10 @@ static inline void rmv_page_order(struct page *page)
*
* Assumption: *_mem_map is contiguous at least up to MAX_ORDER
*/
static inline struct page *
__page_find_buddy(struct page *page, unsigned long page_idx, unsigned int order)
{
unsigned long buddy_idx = page_idx ^ (1 << order);

return page + (buddy_idx - page_idx);
}

static inline unsigned long
__find_combined_index(unsigned long page_idx, unsigned int order)
__find_buddy_index(unsigned long page_idx, unsigned int order)
{
return (page_idx & ~(1 << order));
return page_idx ^ (1 << order);
}

/*
Expand Down Expand Up @@ -500,6 +492,7 @@ static inline void __free_one_page(struct page *page,
{
unsigned long page_idx;
unsigned long combined_idx;
unsigned long uninitialized_var(buddy_idx);
struct page *buddy;

if (unlikely(PageCompound(page)))
Expand All @@ -514,15 +507,16 @@ static inline void __free_one_page(struct page *page,
VM_BUG_ON(bad_range(zone, page));

while (order < MAX_ORDER-1) {
buddy = __page_find_buddy(page, page_idx, order);
buddy_idx = __find_buddy_index(page_idx, order);
buddy = page + (buddy_idx - page_idx);
if (!page_is_buddy(page, buddy, order))
break;

/* Our buddy is free, merge with it and move up one order. */
list_del(&buddy->lru);
zone->free_area[order].nr_free--;
rmv_page_order(buddy);
combined_idx = __find_combined_index(page_idx, order);
combined_idx = buddy_idx & page_idx;
page = page + (combined_idx - page_idx);
page_idx = combined_idx;
order++;
Expand All @@ -539,9 +533,10 @@ static inline void __free_one_page(struct page *page,
*/
if ((order < MAX_ORDER-2) && 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);
combined_idx = buddy_idx & page_idx;
higher_page = page + (combined_idx - page_idx);
buddy_idx = __find_buddy_index(combined_idx, order + 1);
higher_buddy = page + (buddy_idx - combined_idx);
if (page_is_buddy(higher_page, higher_buddy, order + 1)) {
list_add_tail(&page->lru,
&zone->free_area[order].free_list[migratetype]);
Expand Down

0 comments on commit fbcb100

Please sign in to comment.