Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp758228ybz; Wed, 15 Apr 2020 18:18:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJMv6s3c4TU7eCRW3Q/pYL1/yUvDx8+la9bnssdqVVGsQjiyNS8jCpMx/rpYnkNBymStKKw X-Received: by 2002:a05:6402:3076:: with SMTP id bs22mr19472965edb.112.1586999912862; Wed, 15 Apr 2020 18:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586999912; cv=none; d=google.com; s=arc-20160816; b=mGAebHB2bO+b4f+8I70bvfXeuPUry3umuw28PqLr2DorA3IeIpIKFEIcljDzvOkdSz 5BjzskLI8aZ14BF3W8oZWQ35STrppRRX5hF1OE1JRXAR8jyuc7PF131O1SFW1midXY2B cxzSrIHtb50BLwWMdzWACUM00xPOWh9I8vdwkxZ4wGcSgmxTf23CVJnDkZDdjK6P7dVC bZrT7cG/0PJ14QYP9AlVYyY/GcuBX9mQnR222jOSDs+IqweTi1gplAr8e9ChZ/MroyiB 3StvtXtzxyZa6rE9jcNrrXvJm8OvzXAk0CeMsLeA+NPtcBsqJtuDmaxuuKEsmlJe6CCY dvLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=nMjM2+9/V2DBtCPN2CtDCry8b6h/CfgRDEhT6ouQWfQ=; b=OVc7swKs0+P1k5G/8VQIF3qmMjH9VSd1ul+cGjTER2YV6ADZfsWYk4gvPmTy3D9bDH 2uvZVay0JR0l6hEYBEAo/O/I+xOz11gAUj2Ic4kZ/gVgpGzDnVorZm/9PlBU0CZsYDxw op2ndIVzpHPjQmISN1tOUoT4WCWbMmoyt7yhTOd5Y5heLgL6ZvYimmCeOYJu2qIJd0vv 5MJDK7Rmim7+PMeZcF/NKm5Pmp5KvqwP+e7uw6qxsjLdTMSZ3VnEWWflro1jtgiaExde aTJcy9EJ6x+wDMK/wizGWUbXrmJQ6ZCv6aR97NQc0nBy4LRZDw3Id00ofzTTwiORadQA x2ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si7124374edu.188.2020.04.15.18.18.09; Wed, 15 Apr 2020 18:18:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404816AbgDPAoi (ORCPT + 99 others); Wed, 15 Apr 2020 20:44:38 -0400 Received: from mga04.intel.com ([192.55.52.120]:6004 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404680AbgDPAoe (ORCPT ); Wed, 15 Apr 2020 20:44:34 -0400 IronPort-SDR: 5OWOdHQTfBj8JBjKbRtro52wXfjxIhjQ+gY/OR7nbZtlSycagzTRZ8NtBC3QL036Ujx03TUdfr AMWeCBIFeszQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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