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>,
Greg Thelen <gthelen@google.com>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
Andrew Morton <akpm@linux-foundation.org>,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH -mmotm 2/3] memcg: dirty pages accounting and limiting infrastructure
Date: Tue, 2 Mar 2010 12:00:58 +0100 [thread overview]
Message-ID: <20100302110058.GA1921@linux> (raw)
In-Reply-To: <cc557aab1003020204k16038838ta537357aeeb67b11@mail.gmail.com>
On Tue, Mar 02, 2010 at 12:04:53PM +0200, Kirill A. Shutemov wrote:
[snip]
> > +static inline s64 mem_cgroup_page_stat(enum mem_cgroup_page_stat_item item)
> > +{
> > + return -ENOMEM;
>
> Why ENOMEM? Probably, EINVAL or ENOSYS?
OK, ENOSYS is more appropriate IMHO.
> > +static s64 mem_cgroup_get_local_page_stat(struct mem_cgroup *memcg,
> > + enum mem_cgroup_page_stat_item item)
> > +{
> > + s64 ret;
> > +
> > + switch (item) {
> > + case MEMCG_NR_DIRTYABLE_PAGES:
> > + ret = res_counter_read_u64(&memcg->res, RES_LIMIT) -
> > + res_counter_read_u64(&memcg->res, RES_USAGE);
> > + /* Translate free memory in pages */
> > + ret >>= PAGE_SHIFT;
> > + ret += mem_cgroup_read_stat(memcg, LRU_ACTIVE_FILE) +
> > + mem_cgroup_read_stat(memcg, LRU_INACTIVE_FILE);
> > + if (mem_cgroup_can_swap(memcg))
> > + ret += mem_cgroup_read_stat(memcg, LRU_ACTIVE_ANON) +
> > + mem_cgroup_read_stat(memcg, LRU_INACTIVE_ANON);
> > + break;
> > + case MEMCG_NR_RECLAIM_PAGES:
> > + ret = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_FILE_DIRTY) +
> > + mem_cgroup_read_stat(memcg,
> > + MEM_CGROUP_STAT_UNSTABLE_NFS);
> > + break;
> > + case MEMCG_NR_WRITEBACK:
> > + ret = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
> > + break;
> > + case MEMCG_NR_DIRTY_WRITEBACK_PAGES:
> > + ret = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK) +
> > + mem_cgroup_read_stat(memcg,
> > + MEM_CGROUP_STAT_UNSTABLE_NFS);
> > + break;
> > + default:
> > + ret = 0;
> > + WARN_ON_ONCE(1);
>
> I think it's a bug, not warning.
OK.
> > + }
> > + return ret;
> > +}
> > +
> > +static int mem_cgroup_page_stat_cb(struct mem_cgroup *mem, void *data)
> > +{
> > + struct mem_cgroup_page_stat *stat = (struct mem_cgroup_page_stat *)data;
> > +
> > + stat->value += mem_cgroup_get_local_page_stat(mem, stat->item);
> > + return 0;
> > +}
> > +
> > +s64 mem_cgroup_page_stat(enum mem_cgroup_page_stat_item item)
> > +{
> > + struct mem_cgroup_page_stat stat = {};
> > + struct mem_cgroup *memcg;
> > +
> > + if (mem_cgroup_disabled())
> > + return -ENOMEM;
>
> EINVAL/ENOSYS?
OK.
>
> > + rcu_read_lock();
> > + memcg = mem_cgroup_from_task(current);
> > + if (memcg) {
> > + /*
> > + * Recursively evaulate page statistics against all cgroup
> > + * under hierarchy tree
> > + */
> > + stat.item = item;
> > + mem_cgroup_walk_tree(memcg, &stat, mem_cgroup_page_stat_cb);
> > + } else
> > + stat.value = -ENOMEM;
>
> ditto.
OK.
>
> > + rcu_read_unlock();
> > +
> > + return stat.value;
> > +}
> > +
> > static int mem_cgroup_count_children_cb(struct mem_cgroup *mem, void *data)
> > {
> > int *val = data;
> > @@ -1263,14 +1418,16 @@ static void record_last_oom(struct mem_cgroup *mem)
> > }
> >
> > /*
> > - * Currently used to update mapped file statistics, but the routine can be
> > - * generalized to update other statistics as well.
> > + * Generalized routine to update memory cgroup statistics.
> > */
> > -void mem_cgroup_update_file_mapped(struct page *page, int val)
> > +void mem_cgroup_update_stat(struct page *page,
> > + enum mem_cgroup_stat_index idx, int val)
>
> EXPORT_SYMBOL_GPL(mem_cgroup_update_stat) is needed, since
> it uses by filesystems.
Agreed.
> > +static int
> > +mem_cgroup_dirty_write(struct cgroup *cgrp, struct cftype *cft, u64 val)
> > +{
> > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > + int type = cft->private;
> > +
> > + if (cgrp->parent == NULL)
> > + return -EINVAL;
> > + if (((type == MEM_CGROUP_DIRTY_RATIO) ||
> > + (type == MEM_CGROUP_DIRTY_BACKGROUND_RATIO)) && (val > 100))
>
> Too many unnecessary brackets
>
> if ((type == MEM_CGROUP_DIRTY_RATIO ||
> type == MEM_CGROUP_DIRTY_BACKGROUND_RATIO) && val > 100)
>
OK.
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>
next prev parent reply other threads:[~2010-03-02 11:01 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-01 21:23 [PATCH -mmotm 0/3] memcg: per cgroup dirty limit (v3) Andrea Righi
2010-03-01 21:23 ` [PATCH -mmotm 1/3] memcg: dirty memory documentation Andrea Righi
2010-03-01 21:23 ` [PATCH -mmotm 2/3] memcg: dirty pages accounting and limiting infrastructure Andrea Righi
2010-03-02 0:20 ` KAMEZAWA Hiroyuki
2010-03-02 10:04 ` Kirill A. Shutemov
2010-03-02 11:00 ` Andrea Righi [this message]
2010-03-02 13:02 ` Balbir Singh
2010-03-02 21:50 ` Andrea Righi
2010-03-02 18:08 ` Greg Thelen
2010-03-02 22:24 ` Andrea Righi
2010-03-01 21:23 ` [PATCH -mmotm 3/3] memcg: dirty pages instrumentation Andrea Righi
2010-03-01 22:02 ` Vivek Goyal
2010-03-01 22:18 ` Andrea Righi
2010-03-02 15:05 ` Vivek Goyal
2010-03-02 22:22 ` Andrea Righi
2010-03-02 23:59 ` Vivek Goyal
2010-03-03 11:47 ` Andrea Righi
2010-03-03 11:56 ` Andrea Righi
2010-03-02 0:23 ` KAMEZAWA Hiroyuki
2010-03-02 8:01 ` Andrea Righi
2010-03-02 8:12 ` Daisuke Nishimura
2010-03-02 8:23 ` KAMEZAWA Hiroyuki
2010-03-02 13:50 ` Balbir Singh
2010-03-02 22:18 ` Andrea Righi
2010-03-02 23:21 ` Daisuke Nishimura
2010-03-03 11:48 ` Andrea Righi
2010-03-02 10:11 ` Kirill A. Shutemov
2010-03-02 11:02 ` Andrea Righi
2010-03-02 11:09 ` Kirill A. Shutemov
2010-03-02 11:34 ` Andrea Righi
2010-03-02 13:47 ` Balbir Singh
2010-03-02 13:56 ` Kirill A. Shutemov
2010-03-02 13:48 ` Peter Zijlstra
2010-03-02 15:26 ` Balbir Singh
2010-03-02 15:49 ` Trond Myklebust
2010-03-02 22:14 ` Andrea Righi
2010-03-03 10:07 ` Peter Zijlstra
2010-03-03 12:05 ` Andrea Righi
2010-03-03 2:12 ` Daisuke Nishimura
2010-03-03 3:29 ` KAMEZAWA Hiroyuki
2010-03-03 6:01 ` Daisuke Nishimura
2010-03-03 6:15 ` KAMEZAWA Hiroyuki
2010-03-03 8:21 ` KAMEZAWA Hiroyuki
2010-03-03 11:50 ` Andrea Righi
2010-03-03 22:03 ` Andrea Righi
2010-03-03 23:25 ` Daisuke Nishimura
2010-03-04 3:45 ` 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=20100302110058.GA1921@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=nishimura@mxp.nes.nec.co.jp \
--cc=suleiman@google.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).