Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1552441

mm, page_alloc: Swap likely to unlikely as code logic is different for next_zones_zonelist()

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject mm, page_alloc: Swap likely to unlikely as code logic is different for next_zones_zonelist()
Date 2017-01-06 02:10 +0100
Message-ID <sWrcB-2BS-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Commit 682a3385e773 "mm, page_alloc: inline the fast path of the
zonelist iterator" changed how next_zones_zonelist() is called, by
adding a static inline function to do the fast path. This function adds:

       if (likely(!nodes && zonelist_zone_idx(z) <= highest_zoneidx))
               return z;
       return __next_zones_zonelist(z, highest_zoneidx, nodes);

Where __next_zones_zonelist() is only called when nodes is not NULL or
zonelist_zone_idx(z) is less than highest_zoneidx.

The original next_zone_zonelist() was converted to
__next_zones_zonelist() but it still maintained:

	if (likely(nodes == NULL))

Which is now actually a very unlikely, as it is only called with nodes
equal to NULL when zonelist_zone_idx(z) is greater than highest_zoneidx.

Before this commit, this if had this statistic:

 correct incorrect  %        Function                  File              Line
 ------- ---------  -        --------                  ----              ----
  837895   446078  34 next_zones_zonelist            mmzone.c             63

After this commit, it has:

 correct incorrect  %        Function                  File              Line
 ------- ---------  -        --------                  ----              ----
      10   173840  99 __next_zones_zonelist          mmzone.c             63

Thus, the if statement is now much more unlikely than it ever was as a
likely.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 5652be858e5e..a51c0a67ea3d 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -60,7 +60,7 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z,
 	 * Find the next suitable zone to use for the allocation.
 	 * Only filter based on nodemask if it's set
 	 */
-	if (likely(nodes == NULL))
+	if (unlikely(nodes == NULL))
 		while (zonelist_zone_idx(z) > highest_zoneidx)
 			z++;
 	else

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

mm, page_alloc: Swap likely to unlikely as code logic is different  for next_zones_zonelist() Steven Rostedt <rostedt@goodmis.org> - 2017-01-06 02:10 +0100
  Re: mm, page_alloc: Swap likely to unlikely as code logic is  different for next_zones_zonelist() Vlastimil Babka <vbabka@suse.cz> - 2017-01-06 09:10 +0100
    Re: mm, page_alloc: Swap likely to unlikely as code logic is  different for next_zones_zonelist() Steven Rostedt <rostedt@goodmis.org> - 2017-01-06 15:50 +0100
  Re: mm, page_alloc: Swap likely to unlikely as code logic is  different for next_zones_zonelist() Mel Gorman <mgorman@techsingularity.net> - 2017-01-06 11:30 +0100

csiph-web