Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753996Ab0DWDcc (ORCPT ); Thu, 22 Apr 2010 23:32:32 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:41991 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482Ab0DWDca (ORCPT ); Thu, 22 Apr 2010 23:32:30 -0400 Date: Fri, 23 Apr 2010 09:02:23 +0530 From: Balbir Singh To: KAMEZAWA Hiroyuki Cc: Li Zefan , Daisuke Nishimura , "Paul E. McKenney" , "linux-mm@kvack.org" , LKML , "akpm@linux-foundation.org" Subject: Re: [BUGFIX][PATCH] memcg rcu lock fix in swap code (Was Re: [BUG] an RCU warning in memcg Message-ID: <20100423033223.GR3994@balbir.in.ibm.com> Reply-To: balbir@linux.vnet.ibm.com References: <4BD10D59.9090504@cn.fujitsu.com> <20100423121424.ae47efcb.kamezawa.hiroyu@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20100423121424.ae47efcb.kamezawa.hiroyu@jp.fujitsu.com> User-Agent: Mutt/1.5.20 (2009-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3226 Lines: 91 * KAMEZAWA Hiroyuki [2010-04-23 12:14:24]: > On Fri, 23 Apr 2010 11:00:41 +0800 > Li Zefan wrote: > > > with CONFIG_PROVE_RCU=y, I saw this warning, it's because > > css_id() is not under rcu_read_lock(). > > > > Ok. Thank you for reporting. > This is ok ? > == > From: KAMEZAWA Hiroyuki > > css_id() should be called under rcu_read_lock(). > Following is a report from Li Zefan. > == > =================================================== > [ INFO: suspicious rcu_dereference_check() usage. ] > --------------------------------------------------- > kernel/cgroup.c:4438 invoked rcu_dereference_check() without protection! > > other info that might help us debug this: > > > rcu_scheduler_active = 1, debug_locks = 1 > 1 lock held by kswapd0/31: > #0: (swap_lock){+.+.-.}, at: [] swap_info_get+0x4b/0xd0 > > stack backtrace: > Pid: 31, comm: kswapd0 Not tainted 2.6.34-rc5-tip+ #13 > Call Trace: > [] ? printk+0x1d/0x1f > [] lockdep_rcu_dereference+0x94/0xb0 > [] css_id+0x5d/0x60 > [] mem_cgroup_uncharge_swapcache+0x45/0xa0 > [] swapcache_free+0x3f/0x60 > [] __remove_mapping+0xb2/0xf0 > [] shrink_page_list+0x26b/0x490 > [] ? put_lock_stats+0xd/0x30 > [] ? _raw_spin_unlock_irq+0x27/0x50 > [] ? trace_hardirqs_on_caller+0xb6/0x220 > [] shrink_inactive_list+0x278/0x620 > [] ? sched_clock_cpu+0x121/0x180 > [] ? trace_hardirqs_off_caller+0x18/0x130 > [] ? trace_hardirqs_off+0xb/0x10 > [] ? sub_preempt_count+0x8/0x90 > [] ? put_lock_stats+0xd/0x30 > [] shrink_zone+0x204/0x3c0 > [] ? _raw_spin_unlock+0x2c/0x50 > [] kswapd+0x61e/0x7c0 > [] ? isolate_pages_global+0x0/0x1f0 > [] ? autoremove_wake_function+0x0/0x50 > [] ? kswapd+0x0/0x7c0 > [] kthread+0x74/0x80 > [] ? kthread+0x0/0x80 > [] kernel_thread_helper+0x6/0x10 > > Reported-by: Li Zefan > Cc: Daisuke Nishimura > Cc: Balbir Singh > Signed-off-by: KAMEZAWA Hiroyuki > --- > mm/memcontrol.c | 2 ++ > 1 file changed, 2 insertions(+) > > Index: linux-2.6.34-rc5-mm1/mm/memcontrol.c > =================================================================== > --- linux-2.6.34-rc5-mm1.orig/mm/memcontrol.c > +++ linux-2.6.34-rc5-mm1/mm/memcontrol.c > @@ -2401,7 +2401,9 @@ mem_cgroup_uncharge_swapcache(struct pag > > /* record memcg information */ > if (do_swap_account && swapout && memcg) { > + rcu_read_lock(); > swap_cgroup_record(ent, css_id(&memcg->css)); > + rcu_read_unlock(); > mem_cgroup_get(memcg); Excellent Catch! Reviewed-by: Balbir Singh -- Three Cheers, Balbir -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/