Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755236Ab3GPKoh (ORCPT ); Tue, 16 Jul 2013 06:44:37 -0400 Received: from mail-ee0-f51.google.com ([74.125.83.51]:64154 "EHLO mail-ee0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754169Ab3GPKof (ORCPT ); Tue, 16 Jul 2013 06:44:35 -0400 Date: Tue, 16 Jul 2013 13:44:00 +0300 From: Sergey Senozhatsky To: "Srivatsa S. Bhat" Cc: Michael Wang , Jiri Kosina , Borislav Petkov , "Rafael J. Wysocki" , Viresh Kumar , linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: Re: [LOCKDEP] cpufreq: possible circular locking dependency detected Message-ID: <20130716104400.GA2359@swordfish.minsk.epam.com> References: <20130710231305.GA4046@swordfish> <51DE1BE1.3090707@linux.vnet.ibm.com> <20130714114721.GB2178@swordfish> <20130714120629.GA4067@swordfish> <51E37194.1080103@linux.vnet.ibm.com> <51E3AA3B.9090003@linux.vnet.ibm.com> <20130715082918.GA2435@swordfish> <51E3F6EB.2050807@linux.vnet.ibm.com> <20130715232057.GA2486@swordfish> <51E50570.8080704@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51E50570.8080704@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11679 Lines: 268 On (07/16/13 14:03), Srivatsa S. Bhat wrote: > >> So here is the solution: > >> > >> On 3.11-rc1, apply these patches in the order mentioned below, and check > >> whether it fixes _all_ problems (both the warnings about IPI as well as the > >> lockdep splat). > >> > >> 1. Patch given in: https://lkml.org/lkml/2013/7/11/661 > >> (Just apply patch 1, not the entire patchset). > >> > >> 2. Apply the patch shown below, on top of the above patch: > >> > >> --------------------------------------------------------------------------- > >> > > > > Hello Srivatsa, > > Thanks, I'll test a bit later -- in the morning. (laptop stopped resuming from > > suspend, probably radeon dmp). > > > > > > Sure, thanks! > > > > > Shouldn't we also kick the console lock? > > > > > > kernel/printk.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/kernel/printk.c b/kernel/printk.c > > index d37d45c..3e20233 100644 > > --- a/kernel/printk.c > > +++ b/kernel/printk.c > > @@ -1926,8 +1926,11 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self, > > { > > switch (action) { > > case CPU_ONLINE: > > + case CPU_ONLINE_FROZEN: > > case CPU_DEAD: > > + case CPU_DEAD_FROZEN: > > case CPU_DOWN_FAILED: > > + case CPU_DOWN_FAILED_FROZEN: > > case CPU_UP_CANCELED: > > console_lock(); > > console_unlock(); > > > > > > No need. suspend_console() and resume_console() already handle it > properly in the suspend/resume case, from what I can see. > I've managed to wake up my laptop from suspend, and something's not right. # for i in {1..5}; do \ echo 0 > /sys/devices/system/cpu/cpu3/online; \ echo 0 > /sys/devices/system/cpu/cpu2/online; \ echo 1 > /sys/devices/system/cpu/cpu3/online; \ echo 0 > /sys/devices/system/cpu/cpu1/online; \ echo 1 > /sys/devices/system/cpu/cpu1/online; \ echo 1 > /sys/devices/system/cpu/cpu2/online; \ done # systemctl suspend -> resume [ 227.329656] ACPI: Preparing to enter system sleep state S3 [ 227.353334] PM: Saving platform NVS memory [ 227.355403] ====================================================== [ 227.355404] [ INFO: possible circular locking dependency detected ] [ 227.355407] 3.11.0-rc1-dbg-01398-gf537e41-dirty #1838 Not tainted [ 227.355408] ------------------------------------------------------- [ 227.355411] systemd-sleep/2280 is trying to acquire lock: [ 227.355426] (cpu_add_remove_lock){+.+.+.}, at: [] disable_nonboot_cpus+0x24/0x120 [ 227.355427] but task is already holding lock: [ 227.355434] (console_lock){+.+.+.}, at: [] suspend_console+0x26/0x40 [ 227.355435] which lock already depends on the new lock. [ 227.355436] the existing dependency chain (in reverse order) is: [ 227.355441] -> #2 (console_lock){+.+.+.}: [ 227.355448] [] lock_acquire+0xa4/0x200 [ 227.355452] [] console_lock+0x77/0x80 [ 227.355456] [] console_cpu_notify+0x31/0x40 [ 227.355462] [] notifier_call_chain+0x5d/0x110 [ 227.355466] [] __raw_notifier_call_chain+0xe/0x10 [ 227.355469] [] cpu_notify+0x23/0x50 [ 227.355473] [] cpu_notify_nofail+0xe/0x20 [ 227.355482] [] _cpu_down+0x1ad/0x330 [ 227.355486] [] cpu_down+0x36/0x50 [ 227.355493] [] cpu_subsys_offline+0x1d/0x30 [ 227.355498] [] device_offline+0x95/0xc0 [ 227.355502] [] store_online+0x42/0x90 [ 227.355506] [] dev_attr_store+0x18/0x30 [ 227.355513] [] sysfs_write_file+0xdb/0x150 [ 227.355517] [] vfs_write+0xbd/0x1e0 [ 227.355522] [] SyS_write+0x4c/0xa0 [ 227.355527] [] tracesys+0xd0/0xd5 [ 227.355531] -> #1 (cpu_hotplug.lock){+.+.+.}: [ 227.355535] [] lock_acquire+0xa4/0x200 [ 227.355541] [] mutex_lock_nested+0x67/0x410 [ 227.355545] [] cpu_hotplug_begin+0x2b/0x60 [ 227.355549] [] _cpu_up+0x2a/0x170 [ 227.355552] [] cpu_up+0x59/0x80 [ 227.355558] [] smp_init+0x64/0x95 [ 227.355566] [] kernel_init_freeable+0x84/0x191 [ 227.355570] [] kernel_init+0xe/0x180 [ 227.355574] [] ret_from_fork+0x7c/0xb0 [ 227.355578] -> #0 (cpu_add_remove_lock){+.+.+.}: [ 227.355582] [] __lock_acquire+0x1766/0x1d30 [ 227.355586] [] lock_acquire+0xa4/0x200 [ 227.355590] [] mutex_lock_nested+0x67/0x410 [ 227.355594] [] disable_nonboot_cpus+0x24/0x120 [ 227.355601] [] suspend_devices_and_enter+0x1f3/0x680 [ 227.355605] [] pm_suspend+0x1d2/0x240 [ 227.355609] [] state_store+0x79/0xf0 [ 227.355614] [] kobj_attr_store+0xf/0x20 [ 227.355618] [] sysfs_write_file+0xdb/0x150 [ 227.355621] [] vfs_write+0xbd/0x1e0 [ 227.355624] [] SyS_write+0x4c/0xa0 [ 227.355628] [] tracesys+0xd0/0xd5 [ 227.355629] other info that might help us debug this: [ 227.355635] Chain exists of: cpu_add_remove_lock --> cpu_hotplug.lock --> console_lock [ 227.355637] Possible unsafe locking scenario: [ 227.355638] CPU0 CPU1 [ 227.355639] ---- ---- [ 227.355642] lock(console_lock); [ 227.355644] lock(cpu_hotplug.lock); [ 227.355647] lock(console_lock); [ 227.355650] lock(cpu_add_remove_lock); [ 227.355651] *** DEADLOCK *** [ 227.355653] 5 locks held by systemd-sleep/2280: [ 227.355661] #0: (sb_writers#6){.+.+.+}, at: [] vfs_write+0x1bb/0x1e0 [ 227.355668] #1: (&buffer->mutex){+.+.+.}, at: [] sysfs_write_file+0x3c/0x150 [ 227.355676] #2: (s_active#110){.+.+.+}, at: [] sysfs_write_file+0xc3/0x150 [ 227.355683] #3: (pm_mutex){+.+.+.}, at: [] pm_suspend+0x32/0x240 [ 227.355690] #4: (console_lock){+.+.+.}, at: [] suspend_console+0x26/0x40 [ 227.355691] stack backtrace: [ 227.355695] CPU: 0 PID: 2280 Comm: systemd-sleep Not tainted 3.11.0-rc1-dbg-01398-gf537e41-dirty #1838 [ 227.355697] Hardware name: Acer Aspire 5741G /Aspire 5741G , BIOS V1.20 02/08/2011 [ 227.355703] ffffffff82208680 ffff88015151bbc8 ffffffff81603038 ffffffff822073f0 [ 227.355707] ffff88015151bc08 ffffffff815ffdaa ffff880153389fa0 ffff88015338a788 [ 227.355712] 1d81e4832c04c441 ffff88015338a760 ffff88015338a788 ffff880153389fa0 [ 227.355713] Call Trace: [ 227.355719] [] dump_stack+0x4e/0x82 [ 227.355723] [] print_circular_bug+0x2b6/0x2c5 [ 227.355727] [] __lock_acquire+0x1766/0x1d30 [ 227.355733] [] ? walk_system_ram_range+0x5c/0x140 [ 227.355737] [] ? mark_held_locks+0x94/0x140 [ 227.355741] [] lock_acquire+0xa4/0x200 [ 227.355745] [] ? disable_nonboot_cpus+0x24/0x120 [ 227.355749] [] ? disable_nonboot_cpus+0x24/0x120 [ 227.355753] [] mutex_lock_nested+0x67/0x410 [ 227.355757] [] ? disable_nonboot_cpus+0x24/0x120 [ 227.355761] [] ? mutex_unlock+0xe/0x10 [ 227.355768] [] ? acpi_os_get_iomem+0x4c/0x54 [ 227.355772] [] disable_nonboot_cpus+0x24/0x120 [ 227.355777] [] suspend_devices_and_enter+0x1f3/0x680 [ 227.355780] [] ? printk+0x67/0x69 [ 227.355785] [] pm_suspend+0x1d2/0x240 [ 227.355789] [] state_store+0x79/0xf0 [ 227.355792] [] kobj_attr_store+0xf/0x20 [ 227.355796] [] sysfs_write_file+0xdb/0x150 [ 227.355799] [] vfs_write+0xbd/0x1e0 [ 227.355804] [] ? fget_light+0x320/0x4b0 [ 227.355808] [] SyS_write+0x4c/0xa0 [ 227.355811] [] tracesys+0xd0/0xd5 [ 227.355814] Disabling non-boot CPUs ... [ 227.357731] smpboot: CPU 1 is now offline [ 227.461072] smpboot: CPU 2 is now offline [ 227.565119] smpboot: CPU 3 is now offline Just to make sure I didn't miss anything: git diff -u -p drivers/cpufreq/ diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0937b8d..7dcfa68 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1942,13 +1942,15 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, if (dev) { switch (action) { case CPU_ONLINE: + case CPU_ONLINE_FROZEN: cpufreq_add_dev(dev, NULL); break; case CPU_DOWN_PREPARE: - case CPU_UP_CANCELED_FROZEN: + case CPU_DOWN_PREPARE_FROZEN: __cpufreq_remove_dev(dev, NULL); break; case CPU_DOWN_FAILED: + case CPU_DOWN_FAILED_FROZEN: cpufreq_add_dev(dev, NULL); break; } diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 4645876..7b839a8 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "cpufreq_governor.h" @@ -137,10 +136,8 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, if (!all_cpus) { __gov_queue_work(smp_processor_id(), dbs_data, delay); } else { - get_online_cpus(); for_each_cpu(i, policy->cpus) __gov_queue_work(i, dbs_data, delay); - put_online_cpus(); } } EXPORT_SYMBOL_GPL(gov_queue_work); diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index cd9e817..12225d1 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -353,13 +353,11 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, cpufreq_update_policy(cpu); break; case CPU_DOWN_PREPARE: + case CPU_DOWN_PREPARE_FROZEN: cpufreq_stats_free_sysfs(cpu); break; case CPU_DEAD: - cpufreq_stats_free_table(cpu); - break; - case CPU_UP_CANCELED_FROZEN: - cpufreq_stats_free_sysfs(cpu); + case CPU_DEAD_FROZEN: cpufreq_stats_free_table(cpu); break; } -ss -- 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/