From patchwork Tue Jul 16 20:04:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 2828302 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4BABF9F967 for ; Tue, 16 Jul 2013 20:05:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E38020263 for ; Tue, 16 Jul 2013 20:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3E962024A for ; Tue, 16 Jul 2013 20:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933950Ab3GPUFJ (ORCPT ); Tue, 16 Jul 2013 16:05:09 -0400 Received: from mail-ea0-f174.google.com ([209.85.215.174]:49300 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933196Ab3GPUFH (ORCPT ); Tue, 16 Jul 2013 16:05:07 -0400 Received: by mail-ea0-f174.google.com with SMTP id o10so596295eaj.19 for ; Tue, 16 Jul 2013 13:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=OHHy6t4uyUFRBfMdwfJHizKv0KaSlo15v6E+yOJgjxE=; b=mUwDwDXr5P4amiPAc2OGgPFkoabOPwVk8mBSJ3flTZEdSAuz/mNiyGFXw3cM/rSV0Y 7If6O5p0Bxid+vHUuiftKkMGCbyf1PPXealAzQyw6dxZEtvuY5eCAJRZ+KN18sXsm2Y7 z2bUNyDbxTvgxe85hSoURhSgW/7ut9Y0tWtFtxxaPpnJHvfBYLEiFdhlSuWU2+v/RHVB 6Ubf7hWF45TB0l1hkefOwgK8WDv1GNtu5xbhb1o38CKqY/mwnvwEsbyqpKsOlKxtAFtM /YWGPkblCCE9H22gfMPdP8mJvLCaRg7h0LI3XnNpWOooSt0Gh59aexH/1dg0mCKaagAg TQCg== X-Received: by 10.15.44.203 with SMTP id z51mr3061256eev.106.1374005105360; Tue, 16 Jul 2013 13:05:05 -0700 (PDT) Received: from localhost ([31.24.91.81]) by mx.google.com with ESMTPSA id l42sm5221472eeo.14.2013.07.16.13.05.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 16 Jul 2013 13:05:04 -0700 (PDT) Date: Tue, 16 Jul 2013 23:04:27 +0300 From: Sergey Senozhatsky To: "Srivatsa S. Bhat" , Michael Wang , Viresh Kumar , linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Subject: cpufreq: possible circular locking detected on suspend Message-ID: <20130716200427.GA2997@swordfish> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, extracted as a new thread from https://lkml.org/lkml/2013/7/16/344 cpufreq midifications are: > Srivatsa S. Bhat wrote: > > 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: > [2: is a revert of commit 2f7021a815f20f3481c10884fe9735ce2a56db35] # 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 Local midifications are: git diff -u -p drivers/cpufreq/ -ss --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }