On 20 August 2013 21:04, Fengguang Wu <fengguang.wu@xxxxxxxxx> wrote: > Greetings, > > I got the below dmesg and the first bad commit is > > commit 6eed9404ab3c4baea54ce4c7e862e69df1d39f38 > Author: Viresh Kumar <viresh.kumar@xxxxxxxxxx> > Date: Tue Aug 6 22:53:11 2013 +0530 > > cpufreq: Use rwsem for protecting critical sections > > Critical sections of the cpufreq core are protected with the help of > the driver module owner's refcount, which isn't the correct approach, > because it causes rmmod to return an error when some routine has > updated that refcount. > > Let's use rwsem for this purpose instead. Only > cpufreq_unregister_driver() will use write sem > and everybody else will use read sem. > > [rjw: Subject & changelog] > Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx> Somebody reported similar stuff with a fix but sent it to wrong mailing list. Can you try attached patch?
Delivered-To: viresh.kumar@xxxxxxxxxx Received: by 10.182.28.168 with SMTP id c8csp163823obh; Mon, 19 Aug 2013 22:11:59 -0700 (PDT) X-Received: by 10.66.123.5 with SMTP id lw5mr1509155pab.83.1376975519171; Mon, 19 Aug 2013 22:11:59 -0700 (PDT) Return-Path: <zhong@xxxxxxxxxxxxxxxxxx> Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com. [122.248.162.7]) by mx.google.com with ESMTPS id sl4si1013207pac.329.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Aug 2013 22:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of zhong@xxxxxxxxxxxxxxxxxx designates 122.248.162.7 as permitted sender) client-ip=122.248.162.7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of zhong@xxxxxxxxxxxxxxxxxx designates 122.248.162.7 as permitted sender) smtp.mail=zhong@xxxxxxxxxxxxxxxxxx Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for <viresh.kumar@xxxxxxxxxx> from <zhong@xxxxxxxxxxxxxxxxxx>; Tue, 20 Aug 2013 10:32:57 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Aug 2013 10:32:56 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id D8321E004F for <viresh.kumar@xxxxxxxxxx>; Tue, 20 Aug 2013 10:42:21 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7K5DMkN27263136 for <viresh.kumar@xxxxxxxxxx>; Tue, 20 Aug 2013 10:43:22 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7K5Brl9019962 for <viresh.kumar@xxxxxxxxxx>; Tue, 20 Aug 2013 10:41:53 +0530 Received: from [9.123.210.51] (thinkpad-t5421.cn.ibm.com [9.123.210.51]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r7K5Bpsk019830 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 20 Aug 2013 10:41:52 +0530 Message-ID: <1376975510.3788.9.camel@ThinkPad-T5421> Subject: [RFC PATCH next]cpufreq: fix bad unlock balance on !CONFIG_SMP From: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx> To: linux-next list <linux-next@xxxxxxxxxxxxxxx> Cc: viresh.kumar@xxxxxxxxxx, rafael.j.wysocki@xxxxxxxxx Date: Tue, 20 Aug 2013 13:11:50 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13082005-8878-0000-0000-00000876DB1D This patch tries to fix lockdep complaint attached below. It seems that we should always read acquire the cpufreq_rwsem, whether CONFIG_SMP is enabled or not. And CONFIG_HOTPLUG_CPU depends on CONFIG_SMP, so it seems we don't need CONFIG_SMP for the code enabled by CONFIG_HOTPLUG_CPU. [ 0.504191] ===================================== [ 0.504627] [ BUG: bad unlock balance detected! ] [ 0.504627] 3.11.0-rc6-next-20130819 #1 Not tainted [ 0.504627] ------------------------------------- [ 0.504627] swapper/1 is trying to release lock (cpufreq_rwsem) at: [ 0.504627] [<ffffffff813d927a>] cpufreq_add_dev+0x13a/0x3e0 [ 0.504627] but there are no more locks to release! [ 0.504627] [ 0.504627] other info that might help us debug this: [ 0.504627] 1 lock held by swapper/1: [ 0.504627] #0: (subsys mutex#4){+.+.+.}, at: [<ffffffff8134a7bf>] subsys_interface_register+0x4f/0xe0 [ 0.504627] [ 0.504627] stack backtrace: [ 0.504627] CPU: 0 PID: 1 Comm: swapper Not tainted 3.11.0-rc6-next-20130819 #1 [ 0.504627] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007 [ 0.504627] ffffffff813d927a ffff88007f847c98 ffffffff814c062b ffff88007f847cc8 [ 0.504627] ffffffff81098bce ffff88007f847cf8 ffffffff81aadc30 ffffffff813d927a [ 0.504627] 00000000ffffffff ffff88007f847d68 ffffffff8109d0be 0000000000000006 [ 0.504627] Call Trace: [ 0.504627] [<ffffffff813d927a>] ? cpufreq_add_dev+0x13a/0x3e0 [ 0.504627] [<ffffffff814c062b>] dump_stack+0x19/0x1b [ 0.504627] [<ffffffff81098bce>] print_unlock_imbalance_bug+0xfe/0x110 [ 0.504627] [<ffffffff813d927a>] ? cpufreq_add_dev+0x13a/0x3e0 [ 0.504627] [<ffffffff8109d0be>] lock_release_non_nested+0x1ee/0x310 [ 0.504627] [<ffffffff81099d0e>] ? mark_held_locks+0xae/0x120 [ 0.504627] [<ffffffff811510cb>] ? kfree+0xcb/0x1d0 [ 0.504627] [<ffffffff813d77ea>] ? cpufreq_policy_free+0x4a/0x60 [ 0.504627] [<ffffffff813d927a>] ? cpufreq_add_dev+0x13a/0x3e0 [ 0.504627] [<ffffffff8109d2a4>] lock_release+0xc4/0x250 [ 0.504627] [<ffffffff8106c9f3>] up_read+0x23/0x40 [ 0.504627] [<ffffffff813d927a>] cpufreq_add_dev+0x13a/0x3e0 [ 0.504627] [<ffffffff8134a809>] subsys_interface_register+0x99/0xe0 [ 0.504627] [<ffffffff81b19f3b>] ? cpufreq_gov_dbs_init+0x12/0x12 [ 0.504627] [<ffffffff813d7f0d>] cpufreq_register_driver+0x9d/0x1d0 [ 0.504627] [<ffffffff81b19f3b>] ? cpufreq_gov_dbs_init+0x12/0x12 [ 0.504627] [<ffffffff81b1a039>] acpi_cpufreq_init+0xfe/0x1f8 [ 0.504627] [<ffffffff810002ba>] do_one_initcall+0xda/0x180 [ 0.504627] [<ffffffff81ae301e>] kernel_init_freeable+0x12c/0x1bb [ 0.504627] [<ffffffff81ae2841>] ? do_early_param+0x8c/0x8c [ 0.504627] [<ffffffff814b4dd0>] ? rest_init+0x140/0x140 [ 0.504627] [<ffffffff814b4dde>] kernel_init+0xe/0xf0 [ 0.504627] [<ffffffff814d029a>] ret_from_fork+0x7a/0xb0 [ 0.504627] [<ffffffff814b4dd0>] ? rest_init+0x140/0x140 Signed-off-by: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx> --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c0ef84d..8408957 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -986,6 +986,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, cpufreq_cpu_put(policy); return 0; } +#endif if (!down_read_trylock(&cpufreq_rwsem)) return 0; @@ -1004,7 +1005,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, } read_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif -#endif if (frozen) /* Restore the saved policy when doing light-weight init */