linux-mm.kvack.org archive mirror
 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: Tue, 14 Apr 2020 09:45:39 +0800	[thread overview]
Message-ID: <87sgh66drw.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20200413132658.GB801367@xps-13> (Andrea Righi's message of "Mon, 13 Apr 2020 15:26:58 +0200")

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

> On Mon, Apr 13, 2020 at 09:13:33PM +0800, Huang, Ying wrote:
>> Andrea Righi <andrea.righi@canonical.com> writes:
>> 
>> > The global swap-in readahead policy takes in account the previous access
>> > patterns, using a scaling heuristic to determine the optimal readahead
>> > chunk dynamically.
>> >
>> > This works pretty well in most cases, but like any heuristic there are
>> > specific cases when this approach is not ideal, for example the swapoff
>> > scenario.
>> >
>> > During swapoff we just want to load back into memory all the swapped-out
>> > pages and for this specific use case a fixed-size readahead is more
>> > efficient.
>> >
>> > The specific use case this patch is addressing is to improve swapoff
>> > performance when a VM has been hibernated, resumed and all memory needs
>> > to be forced back to RAM by disabling swap (see the test case below).
>> 
>> Why do you need to swapoff after resuming?  The swap device isn't used
>> except hibernation?  I guess the process is,
>> 
>> 1) add swap device to VM
>> 2) hibernate
>> 3) resume
>> 4) swapoff
>
> Correct, the swap device is used only for hibernation, when the system
> is resumed the swap is disabled (swapoff).
>
>> 
>> Some pages are swapped out in step 2?  If os, can we just set
>> /proc/sys/vm/swappiness to 0 to avoid swapping in step 2?
>
> Sorry, can you elaborate more on this? All anonymous pages are swapped
> out during step 2, it doesn't matter if we set swappiness to 0, they are
> swapped out anyway, because we need save them somewhere in order to
> hibernate, shutting down the system.

All pages will be written to the swap device in step 2.  But the normal
swapout path isn't used.  So these pages will be restored in step 3
instead of step 4.  But at the beginning of step 2, system may try to
reclaim some pages, the reclaimed anonymous pages will be restored in
step 4.  This may be avoided via setting /proc/sys/vm/swappiness to 0
before step 2.

Best Regards,
Huang, Ying

> Thanks,
> -Andrea


      reply	other threads:[~2020-04-14  1:45 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
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 [this message]

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=87sgh66drw.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).