From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Cc: Rik van Riel <riel@redhat.com>,
akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com,
linux-kernel@vger.kernel.org, Hugh Dickins <hugh@veritas.com>
Subject: Re: [PATCH -mm 05/15] free swap space on swap-in/activation
Date: Tue, 13 May 2008 21:39:30 +0900 [thread overview]
Message-ID: <48298C02.2080303@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <1210600296.7300.23.camel@lts-notebook>
On 2008/05/12 22:51 +0900, Lee Schermerhorn wrote:
> On Mon, 2008-05-12 at 20:21 +0900, Daisuke Nishimura wrote:
>> Hi.
>>
>> I have a question about the intention of this patch.
>>
>> I think all the remove_exclusive_swap_page() you have added
>> are called while the _count of the page is incremented by
>> __isolate_lru_page().
>>
>> So, IMHO, swap caches that will be freed by this patch should have
>> page counts from __isolate_lru_page() and the swap cache itself.
>>
>> They are different from, for example, those are freed by do_swap_page()
>> -> remove_exclusive_swap_page(), that is, swap caches
>> that have been just mapped and have page counts from
>> the process(only user of the page) and the swap cache itself.
>>
>> So, the intention of this patch is
>> not to free a swap space of swap cache that has already swapped in
>> and only used one process as do_swap_page() does,
>> but to free a swap space that is only used as a swap cache
>> (not used by any processes), right?
>
> I agree. I had noticed this when I wanted to use
> remove_exclusive_swap_page() when a page in the swap cache became
> mlocked, but I hadn't got to ask about it yet. As you note, we hold an
> extra reference in that case. Further more, an anonymous page, in the
> swap cache, can be shared, read-only by multiple tasks--ancestors and
> descendants. So, I think the check could be changed to something like:
>
> (page_count(page) - page_mapcount(page) - extra_ref) == 1 to remove, or
> '!= 1' to reject removal.
>
> "extra_ref" would be a new argument to remove_exclusive_swap_page() that
> would be passed as 0 in do_swap_page() and, I think, free_swap_cache()
> and swap_writepage()--current callers. In Rik's patch and when mlocking
> a page, we'd pass extra_ref as 1 or 2 because we hold the extra ref from
> isolate_lru_page and maybe one from get_user_pages() in the mlock case.
>
> Thoughts?
>
I agree that the check in remove_excusive_swap_page() should be changed,
and your new check seems rational for me.
But I have one comment.
I think swap_writepage(), which is one of the current caller, should not
call remove_exclusive_swap_page() with extra_ref=0, because swap_writepage()
can be called via shrink_page_list() -> pageout(), that is, while the
page count is incremented by page isolation.
If there is a swap cache page that would be freed in current shrink_page_list()
-> pageout() -> swap_writepage() -> remove_exclusive_swap_page() sequence,
the page count of the page is 2(page isolation and swap cache).
But if you modify remove_exclusive_swap_page() and call it with extra_ref=0,
the condition isn't met.
I don't know wether swap_writepage() would be called via other sequence or not,
but it should not call remove_exclusive_swap_page() simply with extra_ref=0.
Thanks,
Daisuke Nishimura.
next prev parent reply other threads:[~2008-05-13 12:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-28 18:18 [PATCH -mm 00/15] VM pageout scalability improvements (V6) Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 01/15] FYI: vmstats are "off-by-one" Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 02/15] move isolate_lru_page() to vmscan.c Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 03/15] Use an indexed array for LRU variables Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 04/15] use an array for the LRU pagevecs Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 05/15] free swap space on swap-in/activation Rik van Riel
2008-05-12 11:21 ` Daisuke Nishimura
2008-05-12 13:33 ` Rik van Riel
2008-05-13 13:00 ` Daisuke Nishimura
2008-05-13 13:11 ` Rik van Riel
2008-05-13 16:04 ` [PATCH] take pageout refcount into account for remove_exclusive_swap_page Rik van Riel
2008-05-13 17:43 ` Lee Schermerhorn
2008-05-13 18:09 ` Rik van Riel
2008-05-13 19:02 ` Lee Schermerhorn
2008-05-15 2:15 ` Daisuke Nishimura
2008-05-15 17:55 ` Lee Schermerhorn
[not found] ` <1210600296.7300.23.camel@lts-notebook>
2008-05-13 12:39 ` Daisuke Nishimura [this message]
2008-04-28 18:18 ` [PATCH -mm 06/15] define page_file_cache() function Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 07/15] split LRU lists into anon & file sets Rik van Riel
2008-05-10 7:50 ` MinChan Kim
2008-04-28 18:18 ` [PATCH -mm 08/15] SEQ replacement for anonymous pages Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 09/15] add some sanity checks to get_scan_ratio Rik van Riel
2008-05-15 6:34 ` MinChan Kim
2008-05-15 13:12 ` Rik van Riel
2008-05-16 6:42 ` MinChan Kim
2008-05-16 16:47 ` Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 10/15] add newly swapped in pages to the inactive list Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 11/15] more aggressively use lumpy reclaim Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 12/15] No Reclaim LRU Infrastructure Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 13/15] Non-reclaimable page statistics Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 14/15] ramfs pages are non-reclaimable Rik van Riel
2008-04-28 18:18 ` [PATCH -mm 15/15] SHM_LOCKED pages are nonreclaimable Rik van Riel
2008-04-28 19:55 ` [PATCH -mm 00/15] VM pageout scalability improvements (V6) Rik van Riel
2008-05-08 4:54 ` Rik van Riel
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=48298C02.2080303@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=Lee.Schermerhorn@hp.com \
--cc=akpm@linux-foundation.org \
--cc=hugh@veritas.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=riel@redhat.com \
/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
all inboxes | Powered by JetHome®