Skip to content

Commit deba048

Browse files
tehcastertorvalds
authored andcommitted
mm, page_alloc: use unlikely() in task_capc()
Hugh noted that task_capc() could use unlikely(), as most of the time there is no capture in progress and we are in page freeing hot path. Indeed adding unlikely() produces assembly that better matches the assumption and moves all the tests away from the hot path. I have also noticed that we don't need to test for cc->direct_compaction as the only place we set current->task_capture is compact_zone_order() which also always sets cc->direct_compaction true. Suggested-by: Hugh Dickins <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Hugh Dickins <hughd@googlecom> Acked-by: Mel Gorman <[email protected]> Cc: Alex Shi <[email protected]> Cc: Li Wang <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 51dcc81 commit deba048

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mm/page_alloc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,10 @@ static inline struct capture_control *task_capc(struct zone *zone)
813813
{
814814
struct capture_control *capc = current->capture_control;
815815

816-
return capc &&
816+
return unlikely(capc) &&
817817
!(current->flags & PF_KTHREAD) &&
818818
!capc->page &&
819-
capc->cc->zone == zone &&
820-
capc->cc->direct_compaction ? capc : NULL;
819+
capc->cc->zone == zone ? capc : NULL;
821820
}
822821

823822
static inline bool

0 commit comments

Comments
 (0)