From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
akpm@linux-foundation.org, minchan.kim@gmail.com,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Subject: Re: [PATCH] mm: add replace_page_cache_page() function
Date: Tue, 11 Jan 2011 12:53:30 +0900 [thread overview]
Message-ID: <20110111125330.e416cff5.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20110111112949.57fd6fd7.kamezawa.hiroyu@jp.fujitsu.com>
> What I recommend is below. (Please see the newest -mm because of a bug fix for
> mem cgroup) Considering page management on radix-tree, it can be considerd as
> a kind of page-migration, which replaces pages on radix-tree.
>
> ==
>
> > +int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
> > +{
> > + int error;
> > +
> > + VM_BUG_ON(!PageLocked(old));
> > + VM_BUG_ON(!PageLocked(new));
> > + VM_BUG_ON(new->mapping);
> > +
> struct mem_cgroup *memcg;
>
I think it should be initialized to NULL.
> error = mem_cgroup_prepare_migration(old, new, &memcg);
I want some comments like:
/*
* This is not page migration, but prepare_migration and end_migration
* does enough work for charge replacement.
*/
> #
> # This function will charge against "newpage". But this expects
> # the caller allows GFP_KERNEL gfp_mask.
> # After this, the newpage is in "charged" state.
> if (error)
> return -ENOMEM;
>
> > + error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
> > + if (!error) {
> > + struct address_space *mapping = old->mapping;
> > + pgoff_t offset = old->index;
> > +
> > + page_cache_get(new);
> > + new->mapping = mapping;
> > + new->index = offset;
> > +
> > + spin_lock_irq(&mapping->tree_lock);
> > + __remove_from_page_cache(old);
> > + error = radix_tree_insert(&mapping->page_tree, offset, new);
> > + BUG_ON(error);
> > + mapping->nrpages++;
> > + __inc_zone_page_state(new, NR_FILE_PAGES);
> > + if (PageSwapBacked(new))
> > + __inc_zone_page_state(new, NR_SHMEM);
> > + spin_unlock_irq(&mapping->tree_lock);
> > + radix_tree_preload_end();
>
> > + mem_cgroup_replace_cache_page(old, new); <== remove this.
>
> mem_cgroup_end_migraton(memcg, old, new, true);
>
> > + page_cache_release(old);
> > + }
> else
> mem_cgroup_end_migration(memcg, old, new, false);
>
> # Here, if the 4th argument is true, old page is uncharged.
> # if the 4th argument is false, the new page is uncharged.
> # Then, "charge" of the old page will be migrated onto the new page
> # if replacement is done.
>
>
>
> > +
> > + return error;
> > +}
> > +EXPORT_SYMBOL_GPL(replace_page_cache_page);
> > +
>
> ==
>
> I think this is enough simple and this covers all memory cgroup's racy
> problems.
>
I agree.
Thanks,
Daisuke Nishimura.
--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-01-11 3:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 18:22 Miklos Szeredi
2011-01-11 2:29 ` KAMEZAWA Hiroyuki
2011-01-11 3:53 ` Daisuke Nishimura [this message]
2011-01-11 9:38 ` Miklos Szeredi
2011-01-11 5:41 ` Minchan Kim
-- strict thread matches above, loose matches on Subject: below --
2010-12-15 15:49 Miklos Szeredi
2010-12-15 16:49 ` Rik van Riel
2010-12-15 23:22 ` Minchan Kim
2010-12-16 11:59 ` Miklos Szeredi
2010-12-16 22:04 ` Minchan Kim
2010-12-17 1:21 ` Hugh Dickins
2010-12-17 1:40 ` Minchan Kim
2010-12-17 2:10 ` Hugh Dickins
2010-12-17 4:37 ` Minchan Kim
2010-12-17 15:53 ` Miklos Szeredi
2010-12-16 1:07 ` KAMEZAWA Hiroyuki
2010-12-16 12:05 ` Miklos Szeredi
2010-12-17 0:01 ` KAMEZAWA Hiroyuki
2010-12-17 15:51 ` Miklos Szeredi
2010-12-19 23:54 ` 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=20110111125330.e416cff5.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=miklos@szeredi.hu \
--cc=minchan.kim@gmail.com \
/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