From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: containers@lists.osdl.org, linux-mm@kvack.org,
balbir@linux.vnet.ibm.com, xemul@openvz.org
Subject: Re: [RFC/PATCH] cgroup swap subsystem
Date: Wed, 5 Mar 2008 15:53:29 +0900 [thread overview]
Message-ID: <20080305155329.60e02f48.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <47CE36A9.3060204@mxp.nes.nec.co.jp>
On Wed, 05 Mar 2008 14:59:05 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
> #ifdef CONFIG_CGROUP_MEM_CONT
> +/*
> + * A page_cgroup page is associated with every page descriptor. The
> + * page_cgroup helps us identify information about the cgroup
> + */
> +struct page_cgroup {
> + struct list_head lru; /* per cgroup LRU list */
> + struct page *page;
> + struct mem_cgroup *mem_cgroup;
> +#ifdef CONFIG_CGROUP_SWAP_LIMIT
> + struct mm_struct *pc_mm;
> +#endif
> + atomic_t ref_cnt; /* Helpful when pages move b/w */
> + /* mapped and cached states */
> + int flags;
> +};
>
As first impression, I don't like to increase size of this...but have no alternative
idea.
> static inline int page_cgroup_locked(struct page *page)
> @@ -664,6 +665,10 @@ retry:
> pc->flags = PAGE_CGROUP_FLAG_ACTIVE;
> if (ctype == MEM_CGROUP_CHARGE_TYPE_CACHE)
> pc->flags |= PAGE_CGROUP_FLAG_CACHE;
> +#ifdef CONFIG_CGROUP_SWAP_LIMIT
> + atomic_inc(&mm->mm_count);
> + pc->pc_mm = mm;
> +#endif
>
Strongly Nack to this atomic_inc().
What happens when tmpfs pages goes to swap ?
> if (!page || page_cgroup_assign_new_page_cgroup(page, pc)) {
> /*
> @@ -673,6 +678,9 @@ retry:
> +int swap_cgroup_charge(struct page *page,
> + struct swap_info_struct *si,
> + unsigned long offset)
> +{
> + int ret;
> + struct page_cgroup *pc;
> + struct mm_struct *mm;
> + struct swap_cgroup *swap;
> +
> + BUG_ON(!page);
> +
> + /*
> + * Pages to be swapped out should have been charged by memory cgroup,
> + * but very rarely, pc would be NULL (pc is not reliable without lock,
> + * so I should fix here).
> + * In such cases, we charge the init_mm now.
> + */
> + pc = page_get_page_cgroup(page);
> + if (WARN_ON(!pc))
> + mm = &init_mm;
> + else
> + mm = pc->pc_mm;
> + BUG_ON(!mm);
> +
> + rcu_read_lock();
> + swap = rcu_dereference(mm->swap_cgroup);
> + rcu_read_unlock();
> + BUG_ON(!swap);
Is there no race ?
At first look, remembering mm struct is not very good.
Remembering swap controller itself is better.
If you go this direction, how about this way ?
==
enum {
#ifdef CONFIG_CGROUP_MEM_CONT
MEMORY_RESOURCE_CONTROLLER,
#endif
#ifdef CONFIG_CGROUP_SWAP_CONT
SWAP_CONTROLLER,
#endif
NR_PAGE_CONTROLLER,
}
struct page_cgroup {
......
void* controlls[NR_PAGE_CONTROLLER];
....
};
==
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>
next prev parent reply other threads:[~2008-03-05 6:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-05 5:59 Daisuke Nishimura
2008-03-05 6:36 ` Paul Menage
2008-03-06 12:20 ` Daisuke Nishimura
2008-03-05 6:53 ` KAMEZAWA Hiroyuki [this message]
2008-03-05 21:51 ` Hirokazu Takahashi
2008-03-06 11:45 ` Daisuke Nishimura
2008-03-06 12:25 ` Pavel Emelyanov
2008-03-06 12:56 ` kamezawa.hiroyu
2008-03-07 8:22 ` Daisuke Nishimura
2008-03-12 22:57 ` YAMAMOTO Takashi
2008-03-05 7:03 ` KAMEZAWA Hiroyuki
2008-03-05 7:28 ` Balbir Singh
2008-03-07 4:23 ` Daisuke Nishimura
2008-03-05 8:33 ` Pavel Emelyanov
2008-03-05 8:51 ` Daisuke Nishimura
2008-03-05 14:07 ` Hugh Dickins
2008-03-05 14:14 ` Pavel Emelyanov
2008-03-06 0:33 ` KAMEZAWA Hiroyuki
2008-03-06 0:35 ` Paul Menage
2008-03-06 8:20 ` Pavel Emelyanov
2008-03-06 8:33 ` KAMEZAWA Hiroyuki
2008-03-06 8:38 ` Pavel Emelyanov
2008-03-06 8:48 ` [Devel] " Paul Menage
2008-03-06 8:50 ` Pavel Emelyanov
2008-03-06 8:52 ` Paul Menage
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=20080305155329.60e02f48.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=linux-mm@kvack.org \
--cc=nishimura@mxp.nes.nec.co.jp \
--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