mm : kill combined_idx
Subsystems (2)
PATCH 1/1 mm : kill combined_idx
In more then half of all the cases, `page' is head of the buddy pair {page, buddy} in __free_one_page. That is because the allocation logic always picks the head of a chunk, and puts the rest back to the buddy system.
So calculating the combined page is not needed but waste some cycles in more then half of all the cases.Just do the calculation when page' is bigger then the buddy'.
--- mm/page_alloc.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
mm/page_alloc.c +4 -4
@@ -464,7 +464,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);
@@ -475,9 +474,10 @@ static inline void __free_one_page(struct page *page,list_del (&buddy->lru); zone->free_area[order].nr_free--;rmv_page_order (buddy); - combined_idx =__find_combined_index (page_idx, order); - page = page + (combined_idx - page_idx); - page_idx = combined_idx; +if (page > buddy) {/* keep `page' the head of the buddy pair */ + page = buddy; + page_idx =__find_combined_index (page_idx, order); + } order++; }set_page_order (page, order);
Signature · 7 lines
1.6.0.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · On Mon, 21 Dec 2009 11:32:27 +0800 Huang Shijie <[email protected]> wrote:
In more then half of all the cases, `page' is head of the buddy pair {page, buddy} in
__free_one_page. That is because the allocation logic always picks the head of a chunk, and puts the rest back to the buddy system.So calculating the combined page is not needed but waste some cycles in more then half of all the cases.Just do the calculation when
page' is bigger then thebuddy'.Signed-off-by Huang Shijie <[email protected]>
Hmm...As far as I remember, this code design was for avoiding "if". Is this compare+jump is better than add+xor ?
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · KAMEZAWA Hiroyuki
Quoted 4 lines · On Mon, 21 Dec 2009 11:32:27 +0800 Huang Shijie <[email protected]> wrote:
In more then half of all the cases, `page' is head of the buddy pair {page, buddy} in
__free_one_page. That is because the allocation logic always picks the head of a chunk, and puts the rest back to the buddy system.
Quoted 9 lines
Quoted 5 lines
So calculating the combined page is not needed but waste some cycles in more then half of all the cases.Just do the calculation when
page' is bigger then thebuddy'.Signed-off-by Huang Shijie <[email protected]>Hmm...As far as I remember, this code design was for avoiding "if". Is this compare+jump is better than add+xor ?
Agreed. It's not clear that a compare+jump is cheaper than the add+xor. How often it's the case that the page is the higher or lower half of the buddy would depend heavily on the allocation/free pattern making it hard, if not possible, to predict which is the more common case.
Signature · 9 lines
Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines
Quoted 5 lines
Hmm...As far as I remember, this code design was for avoiding "if". Is this compare+jump is better than add+xor ?
Quoted 6 lines
Agreed. It's not clear that a compare+jump is cheaper than the add+xor. How often it's the case that the page is the higher or lower half of the buddy would depend heavily on the allocation/free pattern making it hard, if not possible, to predict which is the more common case.
ok. thanks a lot.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>