linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@develer.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Suleiman Souhlal <suleiman@google.com>,
	Vivek Goyal <vgoyal@redhat.com>, Greg Thelen <gthelen@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH -mmotm 1/2] memcg: dirty pages accounting and limiting infrastructure
Date: Mon, 1 Mar 2010 11:38:36 +0100	[thread overview]
Message-ID: <20100301103836.GC2087@linux> (raw)
In-Reply-To: <cc557aab1003010058i3a824f98l4cec173fac05911f@mail.gmail.com>

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, 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:[~2010-03-01 10:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-26 22:52 [PATCH -mmotm 0/2] memcg: per cgroup dirty limit (v2) Andrea Righi
2010-02-26 22:52 ` [PATCH -mmotm 1/2] memcg: dirty pages accounting and limiting infrastructure Andrea Righi
2010-03-01  1:09   ` KAMEZAWA Hiroyuki
2010-03-01 10:24     ` Andrea Righi
2010-03-01  8:05   ` Daisuke Nishimura
2010-03-01 10:30     ` Andrea Righi
2010-03-01  8:58   ` Kirill A. Shutemov
2010-03-01 10:38     ` Andrea Righi [this message]
2010-02-26 22:52 ` [PATCH -mmotm 2/2] memcg: dirty pages instrumentation Andrea Righi

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=20100301103836.GC2087@linux \
    --to=arighi@develer.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=gthelen@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=suleiman@google.com \
    --cc=vgoyal@redhat.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;
as well as URLs for NNTP newsgroup(s).