mm, page_alloc: add unlikely macro to help compiler optimization
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>
Wed, 11 Sep 2013 21:21:26 +0000 (14:21 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Sep 2013 22:57:29 +0000 (15:57 -0700)
We rarely allocate a page with ALLOC_NO_WATERMARKS and it is used in slow
path.  For helping compiler optimization, add unlikely macro to
ALLOC_NO_WATERMARKS checking.

This patch doesn't have any effect now, because gcc already optimize this
properly.  But we cannot assume that gcc always does right and nobody
re-evaluate if gcc do proper optimization with their change, for example,
it is not optimized properly on v3.10.  So adding compiler hint here is
reasonable.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/page_alloc.c

index 544d19d681a2bedb8f3476b26e08bce28a6c0ce8..42c59300bacdff2b75862a7df2bb31a7b9d32c63 100644 (file)
@@ -1909,7 +1909,7 @@ zonelist_scan:
                        !cpuset_zone_allowed_softwall(zone, gfp_mask))
                                continue;
                BUILD_BUG_ON(ALLOC_NO_WATERMARKS < NR_WMARK);
-               if (alloc_flags & ALLOC_NO_WATERMARKS)
+               if (unlikely(alloc_flags & ALLOC_NO_WATERMARKS))
                        goto try_this_zone;
                /*
                 * Distribute pages in proportion to the individual