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:31:24 +0800 [thread overview]
Message-ID: <87wo6i6efn.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <20200413133150.GA810380@xps-13> (Andrea Righi's message of "Mon, 13 Apr 2020 15:31:50 +0200")
Andrea Righi <andrea.righi@canonical.com> writes:
> On Mon, Apr 13, 2020 at 09:00:34PM +0800, Huang, Ying wrote:
>> Andrea Righi <andrea.righi@canonical.com> writes:
>>
>> [snip]
>>
>> > diff --git a/mm/swap_state.c b/mm/swap_state.c
>> > index ebed37bbf7a3..c71abc8df304 100644
>> > --- a/mm/swap_state.c
>> > +++ b/mm/swap_state.c
>> > @@ -20,6 +20,7 @@
>> > #include <linux/migrate.h>
>> > #include <linux/vmalloc.h>
>> > #include <linux/swap_slots.h>
>> > +#include <linux/oom.h>
>> > #include <linux/huge_mm.h>
>> >
>> > #include <asm/pgtable.h>
>> > @@ -507,6 +508,14 @@ static unsigned long swapin_nr_pages(unsigned long offset)
>> > max_pages = 1 << READ_ONCE(page_cluster);
>> > if (max_pages <= 1)
>> > return 1;
>> > + /*
>> > + * If current task is using too much memory or swapoff is running
>> > + * simply use the max readahead size. Since we likely want to load a
>> > + * lot of pages back into memory, using a fixed-size max readhaead can
>> > + * give better performance in this case.
>> > + */
>> > + if (oom_task_origin(current))
>> > + return max_pages;
>> >
>> > hits = atomic_xchg(&swapin_readahead_hits, 0);
>> > pages = __swapin_nr_pages(prev_offset, offset, hits, max_pages,
>>
>> Thinks this again. If my understanding were correct, the accessing
>> pattern during swapoff is sequential, why swap readahead doesn't work?
>> If so, can you root cause that firstly?
>
> Theoretically if the pattern is sequential the current heuristic should
> already select a big readahead size, but apparently it's not doing that.
>
> I'll repeat my tests tracing the readahead size during swapoff to see
> exactly what's going on here.
I haven't verify it. It may be helpful to call lookup_swap_cache()
before swapin_readahead() in unuse_pte_range(). The theory behind it is
to update the swap readahead statistics via lookup_swap_cache().
Best Regards,
Huang, Ying
next prev parent reply other threads:[~2020-04-14 1:31 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 [this message]
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
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=87wo6i6efn.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).