linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm <linux-mm@kvack.org>, Balbir Singh <balbir@in.ibm.com>
Subject: Re: [PATCH 2/2] memcg: free unused swapcache at the end of page migration
Date: Tue, 21 Apr 2009 15:53:45 +0900	[thread overview]
Message-ID: <20090421155345.9530d24e.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090421142931.2c02811a.nishimura@mxp.nes.nec.co.jp>

On Tue, 21 Apr 2009 14:29:31 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> Reading the comments, mem_cgroup_end_migration assumes that "newpage" is under lock_page.
> 
> And at the end of mem_cgroup_end_migration, mem_cgroup_uncharge_page cannot
> uncharge the "target" if it's SwapCache even if the owner process has already
> called zap_pte_range -> free_swap_and_cache.
> try_to_free_swap does all necessary checks(it checks page_swapcount).
> 
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>

Nishimura-san, I'd like to handle this issue by my own handle-stale-swapcache patch.
(I'll post it today.)

So, could you wait this patch for a while ?

Thanks,
-Kame

> ---
>  mm/memcontrol.c |    7 +++++--
>  mm/migrate.c    |    9 +++++++--
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 619b0c1..f41433c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1611,10 +1611,13 @@ void mem_cgroup_end_migration(struct mem_cgroup *mem,
>  	 * There is a case for !page_mapped(). At the start of
>  	 * migration, oldpage was mapped. But now, it's zapped.
>  	 * But we know *target* page is not freed/reused under us.
> -	 * mem_cgroup_uncharge_page() does all necessary checks.
> +	 * mem_cgroup_uncharge_page() cannot free SwapCache, so we call
> +	 * try_to_free_swap(), which does all necessary checks.
>  	 */
> -	if (ctype == MEM_CGROUP_CHARGE_TYPE_MAPPED)
> +	if (ctype == MEM_CGROUP_CHARGE_TYPE_MAPPED && !page_mapped(target)) {
>  		mem_cgroup_uncharge_page(target);
> +		try_to_free_swap(target);
> +	}
>  }
>  
>  /*
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 068655d..364edf7 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -580,7 +580,7 @@ static int move_to_new_page(struct page *newpage, struct page *page)
>  	} else
>  		newpage->mapping = NULL;
>  
> -	unlock_page(newpage);
> +	/* keep lock on newpage because mem_cgroup_end_migration assumes it */
>  
>  	return rc;
>  }
> @@ -595,6 +595,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
>  	int rc = 0;
>  	int *result = NULL;
>  	struct page *newpage = get_new_page(page, private, &result);
> +	int newpage_locked = 0;
>  	int rcu_locked = 0;
>  	int charge = 0;
>  	struct mem_cgroup *mem;
> @@ -671,8 +672,10 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
>  	/* Establish migration ptes or remove ptes */
>  	try_to_unmap(page, 1);
>  
> -	if (!page_mapped(page))
> +	if (!page_mapped(page)) {
>  		rc = move_to_new_page(newpage, page);
> +		newpage_locked = 1;
> +	}
>  
>  	if (rc)
>  		remove_migration_ptes(page, page);
> @@ -683,6 +686,8 @@ uncharge:
>  	if (!charge)
>  		mem_cgroup_end_migration(mem, page, newpage);
>  unlock:
> +	if (newpage_locked)
> +		unlock_page(newpage);
>  	unlock_page(page);
>  
>  	if (rc != -EAGAIN) {
> 

--
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:[~2009-04-21  6:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-21  5:26 [PATCH 0/2] memcg: some fixes for -rc Daisuke Nishimura
2009-04-21  5:29 ` [PATCH 1/2] memcg: fix shrink_usage Daisuke Nishimura
2009-04-21  6:54   ` KAMEZAWA Hiroyuki
2009-04-21  5:29 ` [PATCH 2/2] memcg: free unused swapcache at the end of page migration Daisuke Nishimura
2009-04-21  6:53   ` KAMEZAWA Hiroyuki [this message]

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=20090421155345.9530d24e.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@in.ibm.com \
    --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