From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-mm@kvack.org,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
vgoyal@redhat.com, m-ikeda@ds.jp.nec.com, gthelen@google.com,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Subject: Re: [PATCH -mm 1/5] quick lookup memcg by ID
Date: Tue, 3 Aug 2010 13:51:29 +0900 [thread overview]
Message-ID: <20100803135129.4316dfff.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20100803133723.bb6487a0.kamezawa.hiroyu@jp.fujitsu.com>
On Tue, 3 Aug 2010 13:37:23 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> On Tue, 3 Aug 2010 13:31:09 +0900
> Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:
>
(snip)
> > > +/* 0 is unused */
> > > +static atomic_t mem_cgroup_num;
> > > +#define NR_MEMCG_GROUPS (CONFIG_MEM_CGROUP_MAX_GROUPS + 1)
> > > +static struct mem_cgroup *mem_cgroups[NR_MEMCG_GROUPS] __read_mostly;
> > > +
> > > +static struct mem_cgroup *id_to_memcg(unsigned short id)
> > > +{
> > > + /*
> > > + * This array is set to NULL when mem_cgroup is freed.
> > > + * IOW, there are no more references && rcu_synchronized().
> > > + * This lookup-caching is safe.
> > > + */
> > > + if (unlikely(!mem_cgroups[id])) {
> > > + struct cgroup_subsys_state *css;
> > > +
> > > + rcu_read_lock();
> > > + css = css_lookup(&mem_cgroup_subsys, id);
> > > + rcu_read_unlock();
> > > + if (!css)
> > > + return NULL;
> > > + mem_cgroups[id] = container_of(css, struct mem_cgroup, css);
> > > + }
> > > + return mem_cgroups[id];
> > > +}
> > id_to_memcg() seems to be called under rcu_read_lock() already, so I think
> > rcu_read_lock()/unlock() would be unnecessary.
> >
>
> Maybe. I thought about which is better to add
>
> VM_BUG_ON(!rcu_read_lock_held);
> or
> rcu_read_lock()
> ..
> rcu_read_unlock()
>
> Do you like former ? If so, it's ok to remove rcu-read-lock.
>
Yes, I personally like the former.
--
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-08-03 4:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-02 10:11 [PATCH -mm 0/5] towards I/O aware memory cgroup v3 KAMEZAWA Hiroyuki
2010-08-02 10:13 ` [PATCH -mm 1/5] quick lookup memcg by ID KAMEZAWA Hiroyuki
2010-08-03 3:22 ` Balbir Singh
2010-08-03 3:21 ` KAMEZAWA Hiroyuki
2010-08-03 3:38 ` Balbir Singh
2010-08-03 4:31 ` Daisuke Nishimura
2010-08-03 4:37 ` KAMEZAWA Hiroyuki
2010-08-03 4:51 ` Daisuke Nishimura [this message]
2010-08-03 4:54 ` KAMEZAWA Hiroyuki
2010-08-03 5:04 ` Daisuke Nishimura
2010-08-02 10:14 ` [PATCH -mm 2/5] use ID in page cgroup KAMEZAWA Hiroyuki
2010-08-03 3:45 ` Balbir Singh
2010-08-03 3:48 ` KAMEZAWA Hiroyuki
2010-08-02 10:15 ` [PATCH -mm 3/5] memcg scalable file stat accounting method KAMEZAWA Hiroyuki
2010-08-03 3:33 ` Balbir Singh
2010-08-03 3:39 ` KAMEZAWA Hiroyuki
2010-08-04 0:55 ` Daisuke Nishimura
2010-08-04 1:11 ` KAMEZAWA Hiroyuki
2010-08-04 1:25 ` Daisuke Nishimura
2010-08-02 10:17 ` [PATCH -mm 4/5] memcg generic file stat accounting interface KAMEZAWA Hiroyuki
2010-08-03 4:03 ` Balbir Singh
2010-08-03 4:24 ` KAMEZAWA Hiroyuki
2010-08-02 10:20 ` [PATCH -mm 5/5] memcg: use spinlock in page_cgroup instead of bit_spinlock KAMEZAWA Hiroyuki
2010-08-03 4:06 ` Balbir Singh
2010-08-03 4:25 ` KAMEZAWA Hiroyuki
2010-08-03 2:36 ` [PATCH -mm 0/5] towards I/O aware memory cgroup v3 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=20100803135129.4316dfff.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=gthelen@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m-ikeda@ds.jp.nec.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