From: Konstantin Khlebnikov <khlebnikov@openvz.org>
To: Rik van Riel <riel@redhat.com>
Cc: Shaohua Li <shli@kernel.org>, Minchan Kim <minchan@kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"fengguang.wu@intel.com" <fengguang.wu@intel.com>
Subject: Re: [patch v4]swap: add a simple random read swapin detection
Date: Tue, 04 Sep 2012 11:34:44 +0400 [thread overview]
Message-ID: <5045AF14.7040309@openvz.org> (raw)
In-Reply-To: <5044FF89.5090400@redhat.com>
Rik van Riel wrote:
> On 09/03/2012 03:02 PM, Konstantin Khlebnikov wrote:
>> Shaohua Li wrote:
>>> On Mon, Sep 03, 2012 at 05:32:45PM +0900, Minchan Kim wrote:
>>> Subject: swap: add a simple random read swapin detection
>>>
>>> The swapin readahead does a blind readahead regardless if the swapin is
>>> sequential. This is ok for harddisk and random read, because read big
>>> size has
>>> no penality in harddisk, and if the readahead pages are garbage, they
>>> can be
>>> reclaimed fastly. But for SSD, big size read is more expensive than
>>> small size
>>> read. If readahead pages are garbage, such readahead only has overhead.
>>>
>>> This patch addes a simple random read detection like what file mmap
>>> readahead
>>> does. If random read is detected, swapin readahead will be skipped. This
>>> improves a lot for a swap workload with random IO in a fast SSD.
>>>
>>> I run anonymous mmap write micro benchmark, which will triger
>>> swapin/swapout.
>>> runtime changes with path
>>> randwrite harddisk -38.7%
>>> seqwrite harddisk -1.1%
>>> randwrite SSD -46.9%
>>> seqwrite SSD +0.3%
>>>
>>> For both harddisk and SSD, the randwrite swap workload run time is
>>> reduced
>>> significant. sequential write swap workload hasn't chanage.
>>>
>>> Interesting is the randwrite harddisk test is improved too. This might be
>>> because swapin readahead need allocate extra memory, which further tights
>>> memory pressure, so more swapout/swapin.
>>
>> Generally speaking swapin readahread isn't usable while system is under
>> memory
>> pressure. Cache hit isn't very probable, because reclaimer allocates swap
>> entries in page-LRU order.
>>
>> But swapin readahead is very useful if system recovers from memory
>> pressure,
>> it helps to read whole swap back to memory (a sort of desktop scenario).
>>
>> So, I think we can simply disable swapin readahead while system is under
>> memory
>> pressure. For example in time-based manner -- enable it only after grace
>> period
>> after last swap_writepage().
>
> Determining "under memory pressure" is pretty hard to do.
Indeed. But swapin readahead is mostly useless if system hasn't free memory.
So condition can be simply time-based (above) or nr_free_pages()-based,
or can provide some hints from reclaimer/page-allocator.
[readahead also useful in swapoff, but it doesn't use it for now]
>
> However, Shaohua's patch provides an easy way to see whether swap
> readahead is helping (we are getting pages from the swap cache),
> or whether it is not (pages got evicted before someone faulted on
> them).
>
[
BTW we can use readahead bit in page-flags: mark readahead pages with
SetPageReadahead() and gather these marks in do_swap_page()
if (TestClearReadahead(page))
swap_headahead_hit(vma);
]
> In short, Shaohua's patch not only does roughly what you want, it
> does it in a simple way.
>
It disables reahahead if it is ineffective in one particular VMA,
but in recovering-case this does not important -- we really want to read
whole swap back, no matter which VMA around pages belongs to.
[BTW this case was mentioned in you patch which added skipping-over-holes]
And its metric is strange, looks like it just disables headahead for all VMAs
after hundred swapins and never enables it back. Why we cannot disable it from
the beginning and turn it on when needed? This ways is even more simple.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-09-04 7:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-27 4:00 [patch v2]swap: add a simple random read swapin detection Shaohua Li
2012-08-27 12:57 ` Rik van Riel
2012-08-27 14:52 ` Konstantin Khlebnikov
2012-08-30 10:36 ` [patch v3]swap: " Shaohua Li
2012-08-30 16:03 ` Rik van Riel
2012-08-30 17:42 ` Minchan Kim
2012-09-03 7:21 ` [patch v4]swap: " Shaohua Li
2012-09-03 8:32 ` Minchan Kim
2012-09-03 11:46 ` Shaohua Li
2012-09-03 19:02 ` Konstantin Khlebnikov
2012-09-03 19:05 ` Rik van Riel
2012-09-04 7:34 ` Konstantin Khlebnikov [this message]
2012-09-04 14:15 ` Rik van Riel
2012-09-06 11:08 ` [PATCH RFC] mm/swap: automatic tuning for swapin readahead Konstantin Khlebnikov
2012-10-01 23:00 ` Hugh Dickins
2012-10-02 8:58 ` Konstantin Khlebnikov
2012-10-03 21:07 ` Hugh Dickins
2012-10-04 16:23 ` Konstantin Khlebnikov
2012-10-08 22:09 ` Hugh Dickins
2012-10-08 22:16 ` Andrew Morton
2012-10-09 7:53 ` Konstantin Khlebnikov
2012-10-16 0:50 ` Shaohua Li
2012-10-22 7:36 ` Shaohua Li
2012-10-23 5:16 ` Hugh Dickins
2012-10-23 5:51 ` Shaohua Li
2012-10-23 13:41 ` Rik van Riel
2012-10-24 1:13 ` Shaohua Li
2012-11-06 5:36 ` Shaohua Li
2012-11-14 9:48 ` Hugh Dickins
2012-11-19 2:33 ` Shaohua Li
2012-09-03 22:03 ` [patch v4]swap: add a simple random read swapin detection Minchan Kim
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=5045AF14.7040309@openvz.org \
--to=khlebnikov@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=shli@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).