linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hughd@google.com (Hugh Dickins)
To: linux-arm-kernel@lists.infradead.org
Subject: Should a swapped out page be deleted from swap cache?
Date: Tue, 19 Feb 2013 10:49:40 -0800 (PST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1302191040010.2248@eggly.anvils> (raw)
In-Reply-To: <CAFj3OHXredBPjjLMaqnAq0tYKbLXaO0DOfs8zGYzV4ntsXvi6A@mail.gmail.com>

On Tue, 19 Feb 2013, Sha Zhengju wrote:
> On Tue, Feb 19, 2013 at 2:53 PM, Li Haifeng <omycle@gmail.com> wrote:
> > 2013/2/19 Will Huck <will.huckk@gmail.com>:
> >> On 02/19/2013 10:04 AM, Li Haifeng wrote:
> >>>
> >>> If a anonymous page is swapped out and  comes to be reclaimable,
> >>> shrink_page_list() will call __remove_mapping() to delete the page
> >>> swapped out from swap cache. Corresponding code lists as below.

Correct.

> >>
> >>
> >> I'm not sure if
> >> if (PageAnon(page) && !PageSwapCache(page)) {
> >>  .................
> >> }
> >> will add the page to swap cache again.

No, it's already in the swap cache.  Of course, the original pageframe
may be removed from swap cache, freed, data later read back from swap into
a new swap cache pageframe, that be mapped into user memory, removed from
swap cache and swap freed, then later arrive here in page reclaim at the
PageAnon(page) && !PageSwapCache(page) to be added to swap again.

> >>
> >
> > Adding the page to swap cache is the first stage of memory reclaiming.
> >
> > When an anonymous page will be reclaimed, it should be swapped out. If
> > it's not in the swap cache, it will insert into swap cache first and
> > set the bit of PG_swapcache on page->flags. Then, it will be swapped
> > out by try_to_unmap(). After it's swapped out, and no processes swap

Almost correct...

> 
> Swapout(writing to swap disk) is not done by try_to_unmap() which only
> tries to remove all page table mappings to a page. Before unmapping,
> add_to_swap() will set the swap cache page dirty and it will be
> written out by pageout()->swap_writepage().

... but yes, try_to_unmap() is not the one that writes out to swap.

Hugh

  reply	other threads:[~2013-02-19 18:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 10:48 Should a swapped out page be deleted from swap cache? Li Haifeng
2013-02-18 18:06 ` Hugh Dickins
2013-02-19  0:39   ` Will Huck
2013-02-19 19:06     ` Hugh Dickins
2013-02-20  0:43       ` Will Huck
2013-02-19  2:04   ` Li Haifeng
2013-02-19  2:38     ` Will Huck
2013-02-19  6:53       ` Li Haifeng
2013-02-19  9:38         ` Sha Zhengju
2013-02-19 18:49           ` Hugh Dickins [this message]
2013-02-19  8:32   ` Ric Mason
2013-02-19 18:56     ` Hugh Dickins
2013-02-20  0:40       ` Ric Mason
2013-03-06  5:34         ` Li Haifeng
2013-03-06 11:04           ` Ric Mason
2013-03-06 11:10             ` Ric Mason

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=alpine.LNX.2.00.1302191040010.2248@eggly.anvils \
    --to=hughd@google.com \
    --cc=linux-arm-kernel@lists.infradead.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).