Skip to contentSkip to conversation

mm: Add unlikely for current_order test

PATCH In review Zhang Yanfei 3 participants 5 messages Jun 15, 2013 – Jun 17, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Add unlikely for current_order test

From: Zhang Yanfei <[email protected]>

Since we have an unlikely for the "current_order >= pageblock_order / 2" test above, adding an unlikely for this "current_order >= pageblock_order" test seems more appropriate.

---
 mm/page_alloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/page_alloc.c +1 -1
index c3edb62..1b6d7de 100644
@@ -1071,7 +1071,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
 			rmv_page_order(page);
 
 			/* Take ownership for orders >= pageblock_order */
-			if (current_order >= pageblock_order &&
+			if (unlikely(current_order >= pageblock_order) &&
 			    !is_migrate_cma(migratetype))
 				change_pageblock_range(page, current_order,
 							start_migratetype);
Signature · 7 lines
1.7.1

--
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>
#1 lore raw
Quoted 6 lines · Zhang Yanfei

From: Zhang Yanfei <[email protected]>

Since we have an unlikely for the "current_order >= pageblock_order / 2" test above, adding an unlikely for this "current_order >= pageblock_order" test seems more appropriate.

I don't understand the justification at all, current_order being unlikely greater than or equal to pageblock_order / 2 doesn't imply at all that it's unlikely that current_order is greater than or equal to pageblock_order.

Quoted 10 lines
---
 mm/page_alloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/page_alloc.c +0 -0
index c3edb62..1b6d7de 100644

mm/page_alloc.c __rmqueue_fallback(struct zone *zone, int order, int start_migratetype) · line 1077

Quoted 8 lines
mm/page_alloc.c +1 -1
@@ -1071,7 +1071,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype)
 			rmv_page_order(page);
 
 			/* Take ownership for orders >= pageblock_order */
-			if (current_order >= pageblock_order &&
+			if (unlikely(current_order >= pageblock_order) &&
 			    !is_migrate_cma(migratetype))
 				change_pageblock_range(page, current_order,
 							start_migratetype);

--
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>

#2 lore raw

Hi David,

Quoted 9 lines · David Rientjes
Quoted 6 lines · Zhang Yanfei

From: Zhang Yanfei <[email protected]>

Since we have an unlikely for the "current_order >= pageblock_order / 2" test above, adding an unlikely for this "current_order >= pageblock_order" test seems more appropriate.

Quoted 5 lines

I don't understand the justification at all, current_order being unlikely greater than or equal to pageblock_order / 2 doesn't imply at all that it's unlikely that current_order is greater than or equal to pageblock_order.

hmmm... I am confused. Since current_order is >= pageblock_order / 2 is unlikely, why current_order is >= pageblock_order isn't unlikely. Or there are other tips?

Actually, I am also a little confused about why current_order should be unlikely greater than or equal to pageblock_order / 2. When borrowing pages with other migrate_type, we always search from MAX_ORDER-1, which is greater or equal to pageblock_order.

Signature · 8 lines
Thanks.
Zhang Yanfei

--
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>
#3 lore raw
Quoted 6 lines · Zhang Yanfei
Quoted 5 lines

I don't understand the justification at all, current_order being unlikely greater than or equal to pageblock_order / 2 doesn't imply at all that it's unlikely that current_order is greater than or equal to pageblock_order.

Quoted 9 lines

hmmm... I am confused. Since current_order is >= pageblock_order / 2 is unlikely, why current_order is >= pageblock_order isn't unlikely. Or there are other tips?

Actually, I am also a little confused about why current_order should be unlikely greater than or equal to pageblock_order / 2. When borrowing pages with other migrate_type, we always search from MAX_ORDER-1, which is greater or equal to pageblock_order.

Look at what is being done in the function: current_order loops down from MAX_ORDER-1 to the order passed. It is not at all "unlikely" that current_order is greater than pageblock_order, or pageblock_order / 2.

MAX_ORDER is typically 11 and pageblock_order is typically 9 on x86. Integer division truncates, so pageblock_order / 2 is 4. For the first eight iterations, it's guaranteed that current_order >= pageblock_order / 2 if it even gets that far!

So just remove the unlikely() entirely, it's completely bogus.

--
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>

#4 lore raw
Quoted 22 lines · David Rientjes
Quoted 6 lines · Zhang Yanfei
Quoted 5 lines

I don't understand the justification at all, current_order being unlikely greater than or equal to pageblock_order / 2 doesn't imply at all that it's unlikely that current_order is greater than or equal to pageblock_order.

Quoted 9 lines

hmmm... I am confused. Since current_order is >= pageblock_order / 2 is unlikely, why current_order is >= pageblock_order isn't unlikely. Or there are other tips?

Actually, I am also a little confused about why current_order should be unlikely greater than or equal to pageblock_order / 2. When borrowing pages with other migrate_type, we always search from MAX_ORDER-1, which is greater or equal to pageblock_order.

Look at what is being done in the function: current_order loops down from MAX_ORDER-1 to the order passed. It is not at all "unlikely" that current_order is greater than pageblock_order, or pageblock_order / 2.

Quoted 6 lines

MAX_ORDER is typically 11 and pageblock_order is typically 9 on x86. Integer division truncates, so pageblock_order / 2 is 4. For the first eight iterations, it's guaranteed that current_order >= pageblock_order / 2 if it even gets that far!

So just remove the unlikely() entirely, it's completely bogus.

I see. Thanks!

I will send another patch.

Signature · 8 lines
Thanks.
Zhang Yanfei

--
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>