[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100301103836.GC2087@linux>
Date: Mon, 1 Mar 2010 11:38:36 +0100
From: Andrea Righi <arighi@...eler.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: Balbir Singh <balbir@...ux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Suleiman Souhlal <suleiman@...gle.com>,
Vivek Goyal <vgoyal@...hat.com>,
Greg Thelen <gthelen@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
containers@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH -mmotm 1/2] memcg: dirty pages accounting and limiting
infrastructure
On Mon, Mar 01, 2010 at 10:58:35AM +0200, Kirill A. Shutemov wrote:
[snip]
> > +static u64 mem_cgroup_dirty_ratio_read(struct cgroup *cgrp, struct cftype *cft)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + return get_dirty_param(memcg, MEM_CGROUP_DIRTY_RATIO);
> > +}
> > +
> > +static int
> > +mem_cgroup_dirty_ratio_write(struct cgroup *cgrp, struct cftype *cft, u64 val)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + if ((cgrp->parent == NULL) || (val > 100))
> > + return -EINVAL;
> > +
> > + spin_lock(&memcg->reclaim_param_lock);
> > + memcg->dirty_ratio = val;
> > + memcg->dirty_bytes = 0;
> > + spin_unlock(&memcg->reclaim_param_lock);
> > +
> > + return 0;
> > +}
> > +
> > +static u64 mem_cgroup_dirty_bytes_read(struct cgroup *cgrp, struct cftype *cft)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + return get_dirty_param(memcg, MEM_CGROUP_DIRTY_BYTES);
> > +}
> > +
> > +static int
> > +mem_cgroup_dirty_bytes_write(struct cgroup *cgrp, struct cftype *cft, u64 val)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + if (cgrp->parent == NULL)
> > + return -EINVAL;
> > +
> > + spin_lock(&memcg->reclaim_param_lock);
> > + memcg->dirty_ratio = 0;
> > + memcg->dirty_bytes = val;
> > + spin_unlock(&memcg->reclaim_param_lock);
> > +
> > + return 0;
> > +}
> > +
> > +static u64
> > +mem_cgroup_dirty_background_ratio_read(struct cgroup *cgrp, struct cftype *cft)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + return get_dirty_param(memcg, MEM_CGROUP_DIRTY_BACKGROUND_RATIO);
> > +}
> > +
> > +static int mem_cgroup_dirty_background_ratio_write(struct cgroup *cgrp,
> > + struct cftype *cft, u64 val)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + if ((cgrp->parent == NULL) || (val > 100))
> > + return -EINVAL;
> > +
> > + spin_lock(&memcg->reclaim_param_lock);
> > + memcg->dirty_background_ratio = val;
> > + memcg->dirty_background_bytes = 0;
> > + spin_unlock(&memcg->reclaim_param_lock);
> > +
> > + return 0;
> > +}
> > +
> > +static u64
> > +mem_cgroup_dirty_background_bytes_read(struct cgroup *cgrp, struct cftype *cft)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + return get_dirty_param(memcg, MEM_CGROUP_DIRTY_BACKGROUND_BYTES);
> > +}
> > +
> > +static int mem_cgroup_dirty_background_bytes_write(struct cgroup *cgrp,
> > + struct cftype *cft, u64 val)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +
> > + if (cgrp->parent == NULL)
> > + return -EINVAL;
> > +
> > + spin_lock(&memcg->reclaim_param_lock);
> > + memcg->dirty_background_ratio = 0;
> > + memcg->dirty_background_bytes = val;
> > + spin_unlock(&memcg->reclaim_param_lock);
> > +
> > + return 0;
> > +}
> > +
> > static struct cftype mem_cgroup_files[] = {
> > {
> > .name = "usage_in_bytes",
> > @@ -3518,6 +3785,26 @@ static struct cftype mem_cgroup_files[] = {
> > .write_u64 = mem_cgroup_swappiness_write,
> > },
> > {
> > + .name = "dirty_ratio",
> > + .read_u64 = mem_cgroup_dirty_ratio_read,
> > + .write_u64 = mem_cgroup_dirty_ratio_write,
> > + },
> > + {
> > + .name = "dirty_bytes",
> > + .read_u64 = mem_cgroup_dirty_bytes_read,
> > + .write_u64 = mem_cgroup_dirty_bytes_write,
> > + },
> > + {
> > + .name = "dirty_background_ratio",
> > + .read_u64 = mem_cgroup_dirty_background_ratio_read,
> > + .write_u64 = mem_cgroup_dirty_background_ratio_write,
> > + },
> > + {
> > + .name = "dirty_background_bytes",
> > + .read_u64 = mem_cgroup_dirty_background_bytes_read,
> > + .write_u64 = mem_cgroup_dirty_background_bytes_write,
> > + },
> > + {
>
> mem_cgroup_dirty_background_* functions are too similar to
> mem_cgroup_dirty_bytes_*. I think they should be combined
> like mem_cgroup_read() and mem_cgroup_write(). It will be
> cleaner.
Agreed.
Thanks,
-Andrea
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists