lkml.org 
[lkml]   [2013]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Should a swapped out page be deleted from swap cache?
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


\
 
 \ /
  Last update: 2013-02-19 22:42    [W:0.873 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site