From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
xemul@openvz.org, "hugh@veritas.com" <hugh@veritas.com>
Subject: Re: [PATCH 4/7] memcg: page migration
Date: Tue, 18 Mar 2008 10:17:10 +0900 [thread overview]
Message-ID: <20080318101710.bd68c836.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <47DDD939.7050309@cn.fujitsu.com>
On Mon, 17 Mar 2008 11:36:41 +0900
Li Zefan <lizf@cn.fujitsu.com> wrote:
> > @@ -147,6 +147,8 @@ struct mem_cgroup {
> > * statistics.
> > */
> > struct mem_cgroup_stat stat;
> > + /* migration is under going ? */
>
> Please stick to this comment style:
> /*
> * ...
> */
>
ok.
> > + pc = get_page_cgroup(page, GFP_ATOMIC, false);
> > + spin_lock_irqsave(&pc->lock, flags);
> > + if (pc && pc->refcnt) {
>
> You check if (pc) after you deference it by &pc->lock, it's a bug
> here or the check is unneeded ?
>
Ah, BUG. Thanks.
> > + mem = pc->mem_cgroup;
> > + if (pc->flags & PAGE_CGROUP_FLAG_CACHE)
> > + type = MEM_CGROUP_CHARGE_TYPE_MIGRATION_CACHE;
> > + else
> > + type = MEM_CGROUP_CHARGE_TYPE_MIGRATION_MAPPED;
> > + }
> > + spin_unlock_irqrestore(&pc->lock, flags);
> >
> > -void mem_cgroup_end_migration(struct page *page)
> > -{
> > - mem_cgroup_uncharge_page(page);
> > + if (mem) {
> > + ret = mem_cgroup_charge_common(newpage, NULL, GFP_KERNEL,
> > + type, mem);
> > + }
> > + return ret;
> > }
> > -
> > /*
> > - * We know both *page* and *newpage* are now not-on-LRU and PG_locked.
> > - * And no race with uncharge() routines because page_cgroup for *page*
> > - * has extra one reference by mem_cgroup_prepare_migration.
> > + * At the end of migration, we'll push newpage to LRU and
> > + * drop one refcnt which added at prepare_migration.
> > */
> > -void mem_cgroup_page_migration(struct page *page, struct page *newpage)
> > +void mem_cgroup_end_migration(struct page *newpage)
> > {
> > struct page_cgroup *pc;
> > struct mem_cgroup_per_zone *mz;
> > + struct mem_cgroup *mem;
> > unsigned long flags;
> > + int moved = 0;
> >
> > - lock_page_cgroup(page);
> > - pc = page_get_page_cgroup(page);
> > - if (!pc) {
> > - unlock_page_cgroup(page);
> > + if (mem_cgroup_subsys.disabled)
> > return;
> > - }
> > -
> > - mz = page_cgroup_zoneinfo(pc);
> > - spin_lock_irqsave(&mz->lru_lock, flags);
> > - __mem_cgroup_remove_list(pc);
> > - spin_unlock_irqrestore(&mz->lru_lock, flags);
> > -
> > - page_assign_page_cgroup(page, NULL);
> > - unlock_page_cgroup(page);
> > -
> > - pc->page = newpage;
> > - lock_page_cgroup(newpage);
> > - page_assign_page_cgroup(newpage, pc);
> >
> > - mz = page_cgroup_zoneinfo(pc);
> > - spin_lock_irqsave(&mz->lru_lock, flags);
> > - __mem_cgroup_add_list(pc);
> > - spin_unlock_irqrestore(&mz->lru_lock, flags);
> > -
> > - unlock_page_cgroup(newpage);
> > + pc = get_page_cgroup(newpage, GFP_ATOMIC, false);
> > + if (!pc)
> > + return;
> > + spin_lock_irqsave(&pc->lock, flags);
> > + if (pc->flags & PAGE_CGROUP_FLAG_MIGRATION) {
> > + pc->flags &= ~PAGE_CGROUP_FLAG_MIGRATION;
> > + mem = pc->mem_cgroup;
> > + mz = page_cgroup_zoneinfo(pc);
> > + spin_lock(&mz->lru_lock);
> > + __mem_cgroup_add_list(pc);
> > + spin_unlock(&mz->lru_lock);
> > + moved = 1;
> > + }
> > + spin_unlock_irqrestore(&pc->lock, flags);
> > + if (!pc)
> > + return;
>
> redundant check ?
>
yes. will fix.
Thank you.
-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>
next prev parent reply other threads:[~2008-03-18 1:17 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-14 9:59 [PATCH 0/7] memcg: radix-tree page_cgroup KAMEZAWA Hiroyuki
2008-03-14 10:03 ` [PATCH 1/7] re-define page_cgroup KAMEZAWA Hiroyuki
2008-03-16 14:15 ` Balbir Singh
2008-03-18 1:10 ` KAMEZAWA Hiroyuki
2008-03-17 0:21 ` Li Zefan
2008-03-18 1:12 ` KAMEZAWA Hiroyuki
2008-03-17 2:07 ` Li Zefan
2008-03-18 1:11 ` KAMEZAWA Hiroyuki
2008-03-14 10:06 ` [PATCH 2/7] charge/uncharge KAMEZAWA Hiroyuki
2008-03-17 1:46 ` Balbir Singh
2008-03-18 1:14 ` KAMEZAWA Hiroyuki
2008-03-17 2:26 ` Li Zefan
2008-03-18 1:15 ` KAMEZAWA Hiroyuki
2008-03-14 10:07 ` [PATCH 3/7] memcg: move_lists KAMEZAWA Hiroyuki
2008-03-18 16:44 ` Balbir Singh
2008-03-19 2:34 ` KAMEZAWA Hiroyuki
2008-03-14 10:15 ` [PATCH 4/7] memcg: page migration KAMEZAWA Hiroyuki
2008-03-17 2:36 ` Li Zefan
2008-03-18 1:17 ` KAMEZAWA Hiroyuki [this message]
2008-03-18 18:11 ` Balbir Singh
2008-03-19 2:44 ` KAMEZAWA Hiroyuki
2008-03-14 10:17 ` [PATCH 5/7] radix-tree page cgroup KAMEZAWA Hiroyuki
2008-03-17 2:56 ` Li Zefan
2008-03-17 3:26 ` Li Zefan
2008-03-18 1:18 ` KAMEZAWA Hiroyuki
2008-03-18 1:23 ` KAMEZAWA Hiroyuki
2008-03-19 2:05 ` Balbir Singh
2008-03-19 2:51 ` KAMEZAWA Hiroyuki
2008-03-19 3:14 ` Balbir Singh
2008-03-19 3:24 ` KAMEZAWA Hiroyuki
2008-03-19 21:11 ` Peter Zijlstra
2008-03-20 4:45 ` KAMEZAWA Hiroyuki
2008-03-20 5:09 ` KAMEZAWA Hiroyuki
2008-03-14 10:18 ` [PATCH 6/7] memcg: speed up by percpu KAMEZAWA Hiroyuki
2008-03-17 3:03 ` Li Zefan
2008-03-18 1:25 ` KAMEZAWA Hiroyuki
2008-03-18 23:55 ` Li Zefan
2008-03-19 2:51 ` KAMEZAWA Hiroyuki
2008-03-19 21:19 ` Peter Zijlstra
2008-03-19 21:41 ` Peter Zijlstra
2008-03-20 9:08 ` Andy Whitcroft
2008-03-20 4:46 ` KAMEZAWA Hiroyuki
2008-03-14 10:22 ` [PATCH 7/7] memcg: freeing page_cgroup at suitable chance KAMEZAWA Hiroyuki
2008-03-17 3:10 ` Li Zefan
2008-03-18 1:30 ` KAMEZAWA Hiroyuki
2008-03-19 21:33 ` Peter Zijlstra
2008-03-20 5:07 ` KAMEZAWA Hiroyuki
2008-03-20 7:55 ` Peter Zijlstra
2008-03-20 14:49 ` kamezawa.hiroyu
2008-03-20 16:04 ` kamezawa.hiroyu
2008-03-20 16:09 ` Peter Zijlstra
2008-03-20 16:15 ` kamezawa.hiroyu
2008-03-15 6:15 ` [PATCH 0/7] memcg: radix-tree page_cgroup Balbir Singh
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=20080318101710.bd68c836.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=hugh@veritas.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=xemul@openvz.org \
/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