From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939647AbdAFIAf (ORCPT ); Fri, 6 Jan 2017 03:00:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:58852 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938114AbdAFIA0 (ORCPT ); Fri, 6 Jan 2017 03:00:26 -0500 Subject: Re: mm, page_alloc: Swap likely to unlikely as code logic is different for next_zones_zonelist() To: Steven Rostedt , LKML References: <20170105200102.77989567@gandalf.local.home> Cc: Mel Gorman , Andrew Morton , Linus Torvalds , Dirk Hohndel , Jesper Dangaard Brouer From: Vlastimil Babka Message-ID: <4414cca4-1a09-ebda-c92b-fa98df1c8e31@suse.cz> Date: Fri, 6 Jan 2017 09:00:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170105200102.77989567@gandalf.local.home> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/06/2017 02:01 AM, Steven Rostedt wrote: > 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)) Your profiling stats posted online suggested even this one was wrong: function.file.line correct incorrect percent next_zones_zonelist.mmzone.h.965 216840653 25415261543 %0.85 Was it bogus then, or is there other explanation? I have speculated that this might be due to multiple cpusets configured in the system. > 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) Anyway this makes sense. Acked-by: Vlastimil Babka > --- > 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 >