From: "KAMEZAWA Hiroyuki" <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
Hugh Dickins <hugh@veritas.com>
Subject: Re: [BUGFIX][PATCH mmotm] memcg fix swap accounting leak
Date: Fri, 12 Dec 2008 20:16:05 +0900 (JST) [thread overview]
Message-ID: <46730.10.75.179.61.1229080565.squirrel@webmail-b.css.fujitsu.com> (raw)
In-Reply-To: <20081212184341.b62903a7.nishimura@mxp.nes.nec.co.jp>
Daisuke Nishimura said:
>
> /*
> * The page isn't present yet, go ahead with the fault.
> *
> * Be careful about the sequence of operations here.
> * To get its accounting right, reuse_swap_page() must be called
> * while the page is counted on swap but not yet in mapcount i.e.
> * before page_add_anon_rmap() and swap_free(); try_to_free_swap()
> * must be called after the swap_free(), or it will never succeed.
> * And mem_cgroup_commit_charge_swapin(), which uses the swp_entry
> * in page->private, must be called before reuse_swap_page(),
> * which may delete_from_swap_cache().
> */
>
> Hmm.. should we save page->private before calling reuse_swap_page and pass
> it
> to mem_cgroup_commit_charge_swapin(I think it cannot be changed because
> the page
> is locked)?
>
seems not necessary (see below). I'll fix comment if I uses my pc tomorrow..
Considering 2 cases,
A. the SwapCache is already chareged before try_charge_swapin()
B. the SwapCache is very new and not charged before try_charge_swapin()
Case A.
0. We have charge of PAGE_SIZE to this page before reach here.
1. try_charge_swapin() is called and charge += PAGE_SIZE
2. reuse_swap_page() is called.
when delete_from_swap_cache() is called..
2-a. if already mapped, no change in charges.
2-b. if not mapped, charge-=PAGE_SIZE. PCG_USED bit is cleared.
and charge-record is written into swap_cgroup
not called.
2-c. no changes in charge.
3. commit_charge is called.
3-a. PCG_USED bit is set, so charge -= PAGE_SIZE.
3-b. PCG_USED bit is cleared and so we set PCG_USED bit and no
changes in charge.
3-c. no changes in charge.
4-b. swap_free() will clear record in swap_cgroup.
Then, finally we have PAGE_SIZE of charge to this page.
Case B.
0. We have no charges to this page.
1. try_charge_swapin() is called and charge += PAGE_SIZE.
2. reuse_swap_page() is called.
2-a if delete_from_swap_cache() is called.
the page is not mapped. but PCG_USED bit is not set.
so, no change in charges finally. (just recorded in swap_cgroup)
2-b. not called ... no changes in charge.
3. commit_charge() is called and set PCG_USED bit. no changes in charnge.
4. swap_free() is called and clear record in swap_cgroup.
Then, finally we have PAGE_SIZE of charge to this page.
Thanks,
-Kame
next prev parent reply other threads:[~2008-12-12 11:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-12 8:29 KAMEZAWA Hiroyuki
2008-12-12 9:43 ` Daisuke Nishimura
2008-12-12 11:16 ` KAMEZAWA Hiroyuki [this message]
2008-12-13 7:03 ` [BUGFIX][PATCH mmotm] memcg fix swap accounting leak (v2) KAMEZAWA Hiroyuki
2008-12-13 9:49 ` Hugh Dickins
2008-12-13 10:27 ` KAMEZAWA Hiroyuki
2008-12-15 7:07 ` [BUGFIX][PATCH mmotm] memcg fix swap accounting leak (v3) KAMEZAWA Hiroyuki
2008-12-15 8:37 ` Balbir Singh
2008-12-15 8:40 ` KAMEZAWA Hiroyuki
2008-12-15 10:34 ` Hugh Dickins
2008-12-16 4:02 ` [PATCH mmotm] memcg: fix for documentation (Re: [BUGFIX][PATCH mmotm] memcg fix swap accounting leak (v3)) Daisuke Nishimura
2008-12-16 4:53 ` KAMEZAWA Hiroyuki
2008-12-13 10:38 ` [BUGFIX][PATCH mmotm] memcg fix swap accounting leak (v2) KAMEZAWA Hiroyuki
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=46730.10.75.179.61.1229080565.squirrel@webmail-b.css.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nishimura@mxp.nes.nec.co.jp \
/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