From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbdK1Jk3 (ORCPT ); Tue, 28 Nov 2017 04:40:29 -0500 Received: from outbound-smtp01.blacknight.com ([81.17.249.7]:40121 "EHLO outbound-smtp01.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbdK1Jk1 (ORCPT ); Tue, 28 Nov 2017 04:40:27 -0500 Date: Tue, 28 Nov 2017 09:40:25 +0000 From: Mel Gorman To: Jiang Biao Cc: akpm@linux-foundation.org, mhocko@suse.com, hannes@cmpxchg.org, hillf.zj@alibaba-inc.com, minchan@kernel.org, ying.huang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn Subject: Re: [PATCH] mm/vmscan: try to optimize branch procedures. Message-ID: <20171128094025.fcnsmafbsp7cjkf6@techsingularity.net> References: <1511833785-55392-1-git-send-email-jiang.biao2@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1511833785-55392-1-git-send-email-jiang.biao2@zte.com.cn> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 28, 2017 at 09:49:45AM +0800, Jiang Biao wrote: > 1. Use unlikely to try to improve branch prediction. The > *total_scan < 0* branch is unlikely to reach, so use unlikely. > > 2. Optimize *next_deferred >= scanned* condition. > *next_deferred >= scanned* condition could be optimized into > *next_deferred > scanned*, because when *next_deferred == scanned*, > next_deferred shoud be 0, which is covered by the else branch. > > 3. Merge two branch blocks into one. The *next_deferred > 0* branch > could be merged into *next_deferred > scanned* to simplify the code. > > Signed-off-by: Jiang Biao These are slow paths. Do you have perf data indicating the branches are frequently mispredicted? Do you have data showing this improves performance? -- Mel Gorman SUSE Labs