LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	"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>,
	hugh@veritas.com, taka@valinux.co.jp
Subject: Re: [RFC][PATCH 2/5] memcg : handle swap cache
Date: Wed, 5 Nov 2008 11:03:29 +0900	[thread overview]
Message-ID: <20081105110329.a66d4679.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20081105090749.a8756b03.kamezawa.hiroyu@jp.fujitsu.com>

On Wed, 5 Nov 2008 09:07:49 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:

> On Tue, 4 Nov 2008 19:28:22 +0900
> Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> 
> > On Tue, 4 Nov 2008 18:04:29 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > > On Tue, 4 Nov 2008 17:42:01 +0900
> > > Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> > > 
> > > > > +#ifdef CONFIG_SWAP
> > > > > +int mem_cgroup_cache_charge_swapin(struct page *page,
> > > > > +			struct mm_struct *mm, gfp_t mask)
> > > > > +{
> > > > > +	int ret = 0;
> > > > > +
> > > > > +	if (mem_cgroup_subsys.disabled)
> > > > > +		return 0;
> > > > > +	if (unlikely(!mm))
> > > > > +		mm = &init_mm;
> > > > > +
> > > > > +	ret = mem_cgroup_charge_common(page, mm, mask,
> > > > > +			MEM_CGROUP_CHARGE_TYPE_SHMEM, NULL);
> > > > > +	/*
> > > > > +	 * The page may be dropped from SwapCache because we don't have
> > > > > +	 * lock_page().This may cause charge-after-uncharge trouble.
> > > > > +	 * Fix it up here. (the caller have refcnt to this page and
> > > > > +	 * page itself is guaranteed not to be freed.)
> > > > > +	 */
> > > > > +	if (ret && !PageSwapCache(page))
> > > > > +		mem_cgroup_uncharge_swapcache(page);
> > > > > +
> > > > Hmm.. after [5/5], mem_cgroup_cache_charge_swapin has 'locked' parameter,
> > > > calls lock_page(if !locked), and checks PageSwapCache under page lock.
> > > > 
> > > > Why not doing it in this patch?
> > > > 
> > > 
> > > My intention is to guard swap_cgroup by lock_page() against SwapCache.
> > > In Mem+Swap controller. we get "memcg" from information in page->private.
> > > I think we need lock_page(), there. 
> > > 
> > > But here, we don't refer page->private information. 
> > > I think we don't need lock_page() because there is no inofrmation we depends on.
> > > 
> > I just thought it would be simpler to check PageSwapCache after holding
> > page lock rather than to handle the case that the page might be removed from
> > swap cache.
> > 
> > And to be honest, I can't understand the "charge-after-uncharge trouble".
> > Could you explain more?
> > 

I'll add lock_page() here to make this simple.

Thanks,
-Kame


> Maybe typical case is following.
> __delete_from_swapcache can happen while the page is unlocked.
> ==
>                                                   some other thread.
>    page = shmem_swapin()
>    	swapin_readahead();
>    # page is SwapCache here.
>    # but this page is not locked.
>                                                   ___delete_from_swapcache(page)
>    # This is not SwapCache.                                 => uncharge swapcache.
>    mem_cgroup_charge_cache_swapin();
>    {
>        charge();  # charged this page but we don't know this is still swapcache.
>        if (!PageSwapCache(page)) {
> 		# Oh we should unroll this.
>        }
>    }
> =
> 
> Thanks,
> -Kame
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 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>
> 


  reply	other threads:[~2008-11-05  2:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31  2:50 [RFC][PATCH 0/5] memcg : some patches related to swap KAMEZAWA Hiroyuki
2008-10-31  2:52 ` [RFC][PATCH 1/5] memcg : force_empty to do move account KAMEZAWA Hiroyuki
2008-10-31  9:25   ` Daisuke Nishimura
2008-11-04  6:15   ` Paul Menage
2008-11-04  6:17     ` KAMEZAWA Hiroyuki
2008-11-04  6:23       ` Paul Menage
2008-11-04  6:25         ` KAMEZAWA Hiroyuki
2008-10-31  2:54 ` [RFC][PATCH 2/5] memcg : handle swap cache KAMEZAWA Hiroyuki
2008-11-04  8:42   ` Daisuke Nishimura
2008-11-04  9:04     ` KAMEZAWA Hiroyuki
2008-11-04 10:28       ` Daisuke Nishimura
2008-11-05  0:07         ` KAMEZAWA Hiroyuki
2008-11-05  2:03           ` KAMEZAWA Hiroyuki [this message]
2008-10-31  2:55 ` [RFC][PATCH 3/5] memcg : mem+swap controller kconfig KAMEZAWA Hiroyuki
2008-11-04  8:54   ` Daisuke Nishimura
2008-11-04  9:13     ` KAMEZAWA Hiroyuki
2008-10-31  2:58 ` [RFC][PATCH 4/5] memcg : add swap_cgroup KAMEZAWA Hiroyuki
2008-10-31  2:59 ` [RFC][PATCH 5/5] memcg : mem+swap controller KAMEZAWA Hiroyuki
2008-11-02  6:43 ` [RFC][PATCH 6/5] memcg : synchronous LRU 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=20081105110329.a66d4679.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --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 \
    --cc=taka@valinux.co.jp \
    --subject='Re: [RFC][PATCH 2/5] memcg : handle swap cache' \
    /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

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).