From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719AbdEBFfa (ORCPT ); Tue, 2 May 2017 01:35:30 -0400 Received: from mga02.intel.com ([134.134.136.20]:3157 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750792AbdEBFf1 (ORCPT ); Tue, 2 May 2017 01:35:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,403,1488873600"; d="scan'208";a="96129446" From: "Huang\, Ying" To: Minchan Kim Cc: "Huang\, Ying" , Andrew Morton , , , Hugh Dickins , Shaohua Li , Rik van Riel Subject: Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free References: <87tw5idjv9.fsf@yhuang-dev.intel.com> <20170424045213.GA11287@bbox> <87y3un2vdp.fsf@yhuang-dev.intel.com> <20170427043545.GA1726@bbox> <87r30dz6am.fsf@yhuang-dev.intel.com> <20170428074257.GA19510@bbox> <871ssdvtx5.fsf@yhuang-dev.intel.com> <20170428090049.GA26460@bbox> <87h918vjlr.fsf@yhuang-dev.intel.com> <878tmkvemu.fsf@yhuang-dev.intel.com> <20170502050228.GA27176@bbox> Date: Tue, 02 May 2017 13:35:24 +0800 In-Reply-To: <20170502050228.GA27176@bbox> (Minchan Kim's message of "Tue, 2 May 2017 14:02:28 +0900") Message-ID: <87fugng6sj.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Minchan, Minchan Kim writes: > On Fri, Apr 28, 2017 at 09:35:37PM +0800, Huang, Ying wrote: >> In fact, during the test, I found the overhead of sort() is comparable >> with the performance difference of adding likely()/unlikely() to the >> "if" in the function. > > Huang, > > This discussion is started from your optimization code: > > if (nr_swapfiles > 1) > sort(); > > I don't have such fast machine so cannot test it. However, you added > such optimization code in there so I guess it's *worth* to review so > with spending my time, I pointed out what you are missing and > suggested a idea to find a compromise. Sorry for wasting your time and Thanks a lot for your review and suggestion! When I started talking this with you, I found there is some measurable overhead of sort(). But later when I done more tests, I found the measurable overhead is at the same level of likely()/unlikely() compiler notation. So you help me to find that, Thanks again! > Now you are saying sort is so fast so no worth to add more logics > to avoid the overhead? > Then, please just drop that if condition part and instead, sort > it unconditionally. Now, because we found the overhead of sort() is low, I suggest to put minimal effort to avoid it. Like the original implementation, if (nr_swapfiles > 1) sort(); Or, we can make nr_swapfiles more correct as Tim suggested (tracking the number of the swap devices during swap on/off). Best Regards, Huang, Ying From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 0F4DB6B033C for ; Tue, 2 May 2017 01:35:28 -0400 (EDT) Received: by mail-pg0-f71.google.com with SMTP id m13so52896633pgd.12 for ; Mon, 01 May 2017 22:35:28 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id 71si16281303pfk.131.2017.05.01.22.35.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 May 2017 22:35:27 -0700 (PDT) From: "Huang\, Ying" Subject: Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free References: <87tw5idjv9.fsf@yhuang-dev.intel.com> <20170424045213.GA11287@bbox> <87y3un2vdp.fsf@yhuang-dev.intel.com> <20170427043545.GA1726@bbox> <87r30dz6am.fsf@yhuang-dev.intel.com> <20170428074257.GA19510@bbox> <871ssdvtx5.fsf@yhuang-dev.intel.com> <20170428090049.GA26460@bbox> <87h918vjlr.fsf@yhuang-dev.intel.com> <878tmkvemu.fsf@yhuang-dev.intel.com> <20170502050228.GA27176@bbox> Date: Tue, 02 May 2017 13:35:24 +0800 In-Reply-To: <20170502050228.GA27176@bbox> (Minchan Kim's message of "Tue, 2 May 2017 14:02:28 +0900") Message-ID: <87fugng6sj.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim Cc: "Huang, Ying" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Shaohua Li , Rik van Riel Hi, Minchan, Minchan Kim writes: > On Fri, Apr 28, 2017 at 09:35:37PM +0800, Huang, Ying wrote: >> In fact, during the test, I found the overhead of sort() is comparable >> with the performance difference of adding likely()/unlikely() to the >> "if" in the function. > > Huang, > > This discussion is started from your optimization code: > > if (nr_swapfiles > 1) > sort(); > > I don't have such fast machine so cannot test it. However, you added > such optimization code in there so I guess it's *worth* to review so > with spending my time, I pointed out what you are missing and > suggested a idea to find a compromise. Sorry for wasting your time and Thanks a lot for your review and suggestion! When I started talking this with you, I found there is some measurable overhead of sort(). But later when I done more tests, I found the measurable overhead is at the same level of likely()/unlikely() compiler notation. So you help me to find that, Thanks again! > Now you are saying sort is so fast so no worth to add more logics > to avoid the overhead? > Then, please just drop that if condition part and instead, sort > it unconditionally. Now, because we found the overhead of sort() is low, I suggest to put minimal effort to avoid it. Like the original implementation, if (nr_swapfiles > 1) sort(); Or, we can make nr_swapfiles more correct as Tim suggested (tracking the number of the swap devices during swap on/off). Best Regards, Huang, Ying -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org