From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB7DAC2BA19 for ; Thu, 16 Apr 2020 00:44:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7879C206A2 for ; Thu, 16 Apr 2020 00:44:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7879C206A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 153738E005D; Wed, 15 Apr 2020 20:44:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 105B38E0001; Wed, 15 Apr 2020 20:44:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F35778E005D; Wed, 15 Apr 2020 20:44:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id DE8B08E0001 for ; Wed, 15 Apr 2020 20:44:33 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A6289181AEF2A for ; Thu, 16 Apr 2020 00:44:33 +0000 (UTC) X-FDA: 76711872426.09.sense64_7f079a08be72c X-HE-Tag: sense64_7f079a08be72c X-Filterd-Recvd-Size: 3981 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Apr 2020 00:44:32 +0000 (UTC) IronPort-SDR: M7mAPIglUQ8qXFnXs7965d6o0CFvSWHFs1c3XRX1ve8Ftrs3YsXDZNHOg+W6ZUTxG1OKUUHGB3 qb0YqYLfX0XQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2020 17:44:31 -0700 IronPort-SDR: LP1ZX19PIRLq3IQP8QvX+QBzgBj0twgbyBMruwkfFconOhZcQs0SRky7gY3uTsjQUgnVwPt8ky 2pLK6B6D2yuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,388,1580803200"; d="scan'208";a="427636809" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga005.jf.intel.com with ESMTP; 15 Apr 2020 17:44:29 -0700 From: "Huang\, Ying" To: Andrea Righi Cc: Andrew Morton , Minchan Kim , Anchal Agarwal , , Subject: Re: [PATCH v2] mm: swap: use fixed-size readahead during swapoff References: <20200413111810.GA801367@xps-13> <87a73f7d71.fsf@yhuang-dev.intel.com> <20200413133150.GA810380@xps-13> <87wo6i6efn.fsf@yhuang-dev.intel.com> <20200414130520.GF810380@xps-13> <87v9m1zd83.fsf@yhuang-dev.intel.com> <20200415073239.GG810380@xps-13> <87imi1yz07.fsf@yhuang-dev.intel.com> <20200415091948.GH810380@xps-13> Date: Thu, 16 Apr 2020 08:44:28 +0800 In-Reply-To: <20200415091948.GH810380@xps-13> (Andrea Righi's message of "Wed, 15 Apr 2020 11:19:48 +0200") Message-ID: <87wo6gxnrn.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Andrea Righi writes: > On Wed, Apr 15, 2020 at 03:44:08PM +0800, Huang, Ying wrote: >> Andrea Righi writes: >> >> > mm/swapfile.c | 4 +++- >> > 1 file changed, 3 insertions(+), 1 deletion(-) >> > >> > diff --git a/mm/swapfile.c b/mm/swapfile.c >> > index 9fd47e6f7a86..cb9eb517178d 100644 >> > --- a/mm/swapfile.c >> > +++ b/mm/swapfile.c >> > @@ -1944,7 +1944,9 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, >> > vmf.pmd = pmd; >> > last_ra = atomic_read(&last_readahead_pages); >> > atomic_set(&swapin_readahead_hits, last_ra); >> >> You need to remove the above 2 lines firstly. > > Meh... too much enthusiasm, and I definitely need more coffee this > morning. Here's the right patch applied: > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 5871a2aa86a5..8b38441b66fa 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1940,7 +1940,9 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, > vmf.vma = vma; > vmf.address = addr; > vmf.pmd = pmd; > - page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, &vmf); > + page = lookup_swap_cache(entry, vma, addr); > + if (!page) > + page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, &vmf); The vmf assignment can be moved inside "if" block. Otherwise the patch looks good to me. > if (!page) { > if (*swap_map == 0 || *swap_map == SWAP_MAP_BAD) > goto try_next; > > And following the right results: > > r::swapin_nr_pages(unsigned long offset):unsigned long:$retval > COUNT EVENT > 1618 $retval = 1 > 4960 $retval = 2 > 41315 $retval = 4 > 103521 $retval = 8 > > swapoff time: 12.19s > > So, not as good as the fixed-size readahead, but it's definitely an > improvement, considering that the swapoff time is ~22s without this > patch applied. > > I think this change can be a simple and reasonable compromise. Yes. I think so too. Best Regards, Huang, Ying > Thanks again and sorry for the noise, > -Andrea