All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang\, Ying" <ying.huang@intel.com>
To: Andrea Righi <andrea.righi@canonical.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Minchan Kim <minchan@kernel.org>,
	 Anchal Agarwal <anchalag@amazon.com>,  <linux-mm@kvack.org>,
	 <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mm: swap: use fixed-size readahead during swapoff
Date: Thu, 16 Apr 2020 08:44:28 +0800	[thread overview]
Message-ID: <87wo6gxnrn.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20200415091948.GH810380@xps-13> (Andrea Righi's message of "Wed, 15 Apr 2020 11:19:48 +0200")

Andrea Righi <andrea.righi@canonical.com> writes:

> On Wed, Apr 15, 2020 at 03:44:08PM +0800, Huang, Ying wrote:
>> Andrea Righi <andrea.righi@canonical.com> 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


  reply	other threads:[~2020-04-16  0:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 11:18 [PATCH v2] mm: swap: use fixed-size readahead during swapoff Andrea Righi
2020-04-13 13:00 ` Huang, Ying
2020-04-13 13:31   ` Andrea Righi
2020-04-14  1:31     ` Huang, Ying
2020-04-14 13:05       ` Andrea Righi
2020-04-15  2:37         ` Huang, Ying
2020-04-15  7:32           ` Andrea Righi
2020-04-15  7:44             ` Huang, Ying
2020-04-15  9:19               ` Andrea Righi
2020-04-16  0:44                 ` Huang, Ying [this message]
2020-04-15 12:00             ` Andrea Righi
2020-04-16  0:41               ` Huang, Ying
2020-04-16 17:21                 ` Andrea Righi
2020-04-13 13:13 ` Huang, Ying
2020-04-13 13:26   ` Andrea Righi
2020-04-14  1:45     ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wo6gxnrn.fsf@yhuang-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=anchalag@amazon.com \
    --cc=andrea.righi@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.