Prev: linux-next: build failure after merge of the block tree
Next: [PATCH resend] ksm: cleanup for mm_slots_hash
From: KAMEZAWA Hiroyuki on 3 Aug 2010 01:00 On Tue, 3 Aug 2010 13:51:29 +0900 Daisuke Nishimura <nishimura(a)mxp.nes.nec.co.jp> wrote: > On Tue, 3 Aug 2010 13:37:23 +0900 > KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com> wrote: > > > On Tue, 3 Aug 2010 13:31:09 +0900 > > Daisuke Nishimura <nishimura(a)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. ok, will rewrite in that style. -Kame -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Daisuke Nishimura on 3 Aug 2010 01:00 On Tue, 3 Aug 2010 13:37:23 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com> wrote: > On Tue, 3 Aug 2010 13:31:09 +0900 > Daisuke Nishimura <nishimura(a)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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Daisuke Nishimura on 3 Aug 2010 01:20 On Tue, 3 Aug 2010 13:54:13 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com> wrote: > On Tue, 3 Aug 2010 13:51:29 +0900 > Daisuke Nishimura <nishimura(a)mxp.nes.nec.co.jp> wrote: > > > On Tue, 3 Aug 2010 13:37:23 +0900 > > KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com> wrote: > > > > > On Tue, 3 Aug 2010 13:31:09 +0900 > > > Daisuke Nishimura <nishimura(a)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. > > > > Ah, looking into [2/5], this would not be true necessarily.. So, it might be better to leave as it is. Sorry for noise. > > > > > > 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. > > ok, will rewrite in that style. > > -Kame > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
First
|
Prev
|
Pages: 1 2 Prev: linux-next: build failure after merge of the block tree Next: [PATCH resend] ksm: cleanup for mm_slots_hash |