From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx103.postini.com [74.125.245.103]) by kanga.kvack.org (Postfix) with SMTP id 92AE86B004D for ; Mon, 2 Apr 2012 19:10:52 -0400 (EDT) Received: by wgbds1 with SMTP id ds1so3110386wgb.2 for ; Mon, 02 Apr 2012 16:10:50 -0700 (PDT) Date: Tue, 3 Apr 2012 02:10:43 +0300 From: Sergey Senozhatsky Subject: Re: kmemleak: illegal RCU use assertion error Message-ID: <20120402231042.GB4353@swordfish> References: <20120402070911.GB3464@swordfish> <20120402130936.GF2450@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline In-Reply-To: <20120402130936.GF2450@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: "Paul E. McKenney" Cc: Catalin Marinas , linux-mm@kvack.org, linux-kernel@vger.kernel.org --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On (04/02/12 06:09), Paul E. McKenney wrote: > On Mon, Apr 02, 2012 at 10:09:11AM +0300, Sergey Senozhatsky wrote: > > Hello, > >=20 > > commit e5601400081651060a59bd1f45f2821bb8e97f95 > > Author: Paul E. McKenney > > Date: Sat Jan 7 11:03:57 2012 -0800 > >=20 > > rcu: Simplify offline processing > > =20 > > Move ->qsmaskinit and blkd_tasks[] manipulation to the CPU_DYING > > notifier. This simplifies the code by eliminating a potential > > deadlock and by reducing the responsibilities of force_quiescent_st= ate(). > > Also rename functions to make their connection to the CPU-hotplug > > stages explicit. > > =20 > > Signed-off-by: Paul E. McKenney > > Signed-off-by: Paul E. McKenney > >=20 > >=20 > > introduced WARN_ON_ONCE(cpu_is_offline(smp_processor_id())); to __call_= rcu() > > function, Paul also added cpu_offline checks to other routines (e.g. ca= llbacks) > > in later commits. It happens that kmemleak() triggers one of them. > >=20 > > During cpu core offline, kfree()->kmemleak_free()->put_object()-->__cal= l_rcu() chain > > for struct intel_shared_regs * is executed when no struct users left on= this core --=20 > > all CPUs are dead or dying. > >=20 > >=20 > > [ 4703.342462] CPU 3 is now offline > > [ 4705.588116] ------------[ cut here ]------------ > > [ 4705.588129] WARNING: at kernel/rcutree.c:1823 __call_rcu+0x9d/0x1d2() > > [..] > > [ 4705.588196] Call Trace: > > [ 4705.588207] [] ? synchronize_srcu+0x6/0x17 > > [ 4705.588215] [] warn_slowpath_common+0x83/0x9c > > [ 4705.588223] [] ? get_object+0x31/0x31 > > [ 4705.588229] [] warn_slowpath_null+0x1a/0x1c > > [ 4705.588235] [] __call_rcu+0x9d/0x1d2 > > [ 4705.588243] [] ? intel_pmu_cpu_dying+0x3b/0x5d > > [ 4705.588249] [] call_rcu_sched+0x17/0x19 > > [ 4705.588255] [] put_object+0x47/0x4b > > [ 4705.588261] [] delete_object_full+0x2a/0x2e > > [ 4705.588269] [] kmemleak_free+0x26/0x45 > > [ 4705.588274] [] kfree+0x130/0x221 > > [ 4705.588280] [] intel_pmu_cpu_dying+0x3b/0x5d > > [ 4705.588287] [] x86_pmu_notifier+0xaf/0xb9 > > [ 4705.588296] [] notifier_call_chain+0xac/0xd9 > > [ 4705.588303] [] __raw_notifier_call_chain+0xe/0x10 > > [ 4705.588309] [] __cpu_notify+0x20/0x37 > > [ 4705.588314] [] cpu_notify+0x13/0x15 > > [ 4705.588320] [] take_cpu_down+0x28/0x2e > > [ 4705.588326] [] stop_machine_cpu_stop+0x96/0xf1 > > [ 4705.588332] [] cpu_stopper_thread+0xe3/0x183 > > [ 4705.588338] [] ? queue_stop_cpus_work+0xd0/0xd0 > > [ 4705.588344] [] ? _raw_spin_unlock_irqrestore+0x47= /0x65 > > [ 4705.588353] [] ? trace_hardirqs_on_caller+0x119/0= x175 > > [ 4705.588358] [] ? trace_hardirqs_on+0xd/0xf > > [ 4705.588364] [] ? cpu_stop_signal_done+0x2c/0x2c > > [ 4705.588370] [] kthread+0x8b/0x93 > > [ 4705.588378] [] kernel_thread_helper+0x4/0x10 > > [ 4705.588385] [] ? retint_restore_args+0x13/0x13 > > [ 4705.588391] [] ? __init_kthread_worker+0x5a/0x5a > > [ 4705.588397] [] ? gs_change+0x13/0x13 > > [ 4705.588400] ---[ end trace 720328982e35a713 ]--- > > [ 4705.588507] CPU 2 is now offline > >=20 > >=20 > > My first solution was to return from delete_object() if object dealloca= tion > > performed on cpu_is_offline(smp_processor_id()), marking object with sp= ecial > > flag, say OBJECT_ORPHAN. And issue real object_delete() during scan (fo= r example) > > when we see OBJECT_ORPHAN object. =20 > > That, however, requires to handle special case when cpu core offlined > > for small period of time, leading to object insertion error in > > create_object(), which either may be handled in 2 possible ways (assumi= ng > > that lookup_object() returned OBJECT_ORPHAN): > > #1 delete orphaned object and retry with insertion (*) > > #2 re-set existing orphan object > >=20 > >=20 > > (*) performing delete_object() from within create_object() requires rel= easing > > of held kmemleak and object locks, which is racy with other create_obje= ct() and > > any possible scan() activities. > >=20 > > Yet I'm not exactly sure that option #2 is the correct one. > > (I've kind of a patch [not properly tested, etc.] for #2 option). >=20 > Alternatively, I can make RCU tolerate __call_rcu() from late in the > CPU_DYING notifiers without too much trouble. >=20 Well, if that will `do the trick', then I'm ready to test it. Sergey --lrZ03NoBR/3+SXJZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iJwEAQECAAYFAk96MfIACgkQfKHnntdSXjSRxAP/QjaJzvZFzgGdLHUvveNCeVdd EtYw4vkYccNSx/iRBq/pTQqlppuC28FtbXRuoOUFTWtjLuzwHrVAapsC0w0rr3Ln almvUQvZJyMTTtjnld9VueChc/9WAiYRcmmdP6wjrOo7nzTjBhokZgckpjJ2lzSJ lrnR/zj6K9M5KtPlhZ8= =VE6m -----END PGP SIGNATURE----- --lrZ03NoBR/3+SXJZ-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org