linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: "Simon Holm Thøgersen" <odie@cs.aau.dk>,
	"Dave Jones" <davej@redhat.com>,
	"Pekka Enberg" <penberg@cs.helsinki.fi>,
	"Dave Young" <hidave.darkstar@gmail.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Kernel Testers List" <kernel-testers@vger.kernel.org>,
	"cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
	"Rusty Russell" <rusty@rustcorp.com.au>,
	"trenn@suse.de" <trenn@suse.de>,
	"sven.wegener@stealer.net" <sven.wegener@stealer.net>,
	"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
Subject: Re: [Bug #13475] suspend/hibernate lockdep warning
Date: Tue, 16 Jun 2009 17:39:25 -0700	[thread overview]
Message-ID: <20090617003925.GA3900@linux-os.sc.intel.com> (raw)
In-Reply-To: <20090611152329.GB28099@Krystal>

On Thu, Jun 11, 2009 at 08:23:29AM -0700, Mathieu Desnoyers wrote:
> * Simon Holm Thøgersen (odie@cs.aau.dk) wrote:
> > man, 08 06 2009 kl. 10:32 -0400, skrev Dave Jones: 
> > > On Mon, Jun 08, 2009 at 08:48:45AM -0400, Mathieu Desnoyers wrote:
> > >  
> > >  > > > >> Bug-Entry       : http://bugzilla.kernel.org/show_bug.cgi?id=13475
> > >  > > > >> Subject         : suspend/hibernate lockdep warning
> > >  > > > >> References      : http://marc.info/?l=linux-kernel&m=124393723321241&w=4
> > >  > > > 
> > >  > > > I suspect the following commit, after revert this patch I test 5 times
> > >  > > > without lockdep warnings.
> > >  > > > 
> > >  > > > commit b14893a62c73af0eca414cfed505b8c09efc613c
> > >  > > > Author: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > >  > > > Date:   Sun May 17 10:30:45 2009 -0400
> > >  > > > 
> > >  > > > 	[CPUFREQ] fix timer teardown in ondemand governor
> > >  > > 
> > >  > > The patch is probably not at fault here. I suspect it's some latent bug
> > >  > > that simply got exposed by the change to cancel_delayed_work_sync(). In
> > >  > > any case, Mathieu, can you take a look at this please?
> > >  > 
> > >  > Yes, it's been looked at and discussed on the cpufreq ML. The short
> > >  > answer is that they plan to re-engineer cpufreq and remove the policy
> > >  > rwlock taken around almost every operations at the cpufreq level.
> > >  > 
> > >  > The short-term solution, which is recognised as ugly, would be do to the
> > >  > following before doing the cancel_delayed_work_sync() :
> > >  > 
> > >  > unlock policy rwlock write lock
> > >  > 
> > >  > lock policy rwlock write lock
> > >  > 
> > >  > It basically works because this rwlock is unneeded for teardown, hence
> > >  > the future re-work planned.
> > >  > 
> > >  > I'm sorry I cannot prepare a patch current... I've got quite a few pages
> > >  > of Ph.D. thesis due for the beginning of July.
> > >  
> > > I'm kinda scared to touch this code at all for .30 due to the number of
> > > unexpected gotchas we seem to run into every time we touch something
> > > locking related.  So I'm inclined to just live with the lockdep warning
> > > for .30, and see how the real fixes look for .31, and push them back
> > > as -stable updates if they work out.
> > 
> > Unfortunately I don't think it is just theoretical, I've actually hit
> > the following (that haven't got anything to do with suspend/hibernate)
> > 
> > INFO: task cpufreqd:4676 blocked for more than 120 seconds.
> >  "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> >  cpufreqd      D eee2ac60     0  4676      1
> >   ee01bd68 00000086 eee2aad0 eee2ac60 00000533 eee2aad0 eee2ac60 0002b16f
> >   00000000 eee2ac60 7fffffff 7fffffff eee2ac60 7fffffff 7fffffff 00000000
> >   ee01bd70 c03117ee ee01bdbc c0311c0c eee2aad0 eecf6900 eee2aad0 eecf6900
> >  Call Trace:
> >   [<c03117ee>] schedule+0x12/0x24
> >   [<c0311c0c>] schedule_timeout+0x17/0x170
> >   [<c011a4f7>] ? __wake_up+0x2b/0x51
> >   [<c0311afd>] wait_for_common+0xc4/0x135
> >   [<c011a694>] ? default_wake_function+0x0/0xd
> >   [<c0311be0>] wait_for_completion+0x12/0x14
> >   [<c012bc6a>] __cancel_work_timer+0xfe/0x129
> >   [<c012b635>] ? wq_barrier_func+0x0/0xd
> >   [<c012bca0>] cancel_delayed_work_sync+0xb/0xd
> >   [<f20948f9>] cpufreq_governor_dbs+0x22e/0x291 [cpufreq_ondemand]
> >   [<c02af857>] __cpufreq_governor+0x65/0x9d
> >   [<c02af960>] __cpufreq_set_policy+0xd1/0x11f
> >   [<c02b02ae>] store_scaling_governor+0x18a/0x1b2
> >   [<c02b09a5>] ? handle_update+0x0/0xd
> >   [<c02b0124>] ? store_scaling_governor+0x0/0x1b2
> >   [<c02b08c9>] store+0x48/0x61
> >   [<c01acbf4>] sysfs_write_file+0xb4/0xdf
> >   [<c01acb40>] ? sysfs_write_file+0x0/0xdf
> >   [<c0175535>] vfs_write+0x8a/0x104
> >   [<c0175648>] sys_write+0x3b/0x60
> >   [<c0103110>] sysenter_do_call+0x12/0x2c
> >  INFO: task kondemand/0:4956 blocked for more than 120 seconds.
> >  "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> >  kondemand/0   D 00000533     0  4956      2
> >   ee1d9efc 00000046 c011815f 00000533 071148de ee1e0080 ee1e0210 00000000
> >   c03ff478 9189e633 00000082 c03ff478 ee1e0210 c04159f4 c04159f0 00000000
> >   ee1d9f04 c03117ee ee1d9f28 c0313104 ee1d9f30 c04159f4 ee1e0080 c01183be
> >  Call Trace:
> >   [<c011815f>] ? update_curr+0x6c/0x14b
> >   [<c03117ee>] schedule+0x12/0x24
> >   [<c0313104>] rwsem_down_failed_common+0x150/0x16e
> >   [<c01183be>] ? dequeue_task_fair+0x51/0x56
> >   [<c031313d>] rwsem_down_write_failed+0x1b/0x23
> >   [<c031317e>] call_rwsem_down_write_failed+0x6/0x8
> >   [<c03125dd>] ? down_write+0x14/0x16
> >   [<c02b0460>] lock_policy_rwsem_write+0x1d/0x33
> >   [<f20944aa>] do_dbs_timer+0x45/0x266 [cpufreq_ondemand]
> >   [<c012b8f7>] worker_thread+0x165/0x212
> >   [<f2094465>] ? do_dbs_timer+0x0/0x266 [cpufreq_ondemand]
> >   [<c012e639>] ? autoremove_wake_function+0x0/0x33
> >   [<c012b792>] ? worker_thread+0x0/0x212
> >   [<c012e278>] kthread+0x42/0x67
> >   [<c012e236>] ? kthread+0x0/0x67
> >   [<c01038eb>] kernel_thread_helper+0x7/0x10
> > 
> > I've only seen it once in 5 boots and CONFIG_PROVELOCKING does not give any
> > warnings about this, though it does yell when switching governor as reported
> > by others in bug #13493.
> > 
> > Let's hope Mathieu nails it, though I know he's busy with his thesis.
> > 
> 
> Thanks for the lockdep reports,
> 
> I'm currently looking into it, and it's not pretty. Basically we have :
> 
> A
>   B
> (means B nested in A)
> 
> work
>   read rwlock policy
> 
> dbs_mutex
>   work
>     read rwlock policy
> 
> write rwlock policy
>   dbs_mutex
> 
> So the added dbs_mutex <- work <- rwlock policy dependency (for proper
> teardown) is firing the reverse dependency between policy rwlock and
> dbs_mutex.
> 
> The real way to fix this is to do not take the rwlock policy around
> non-policy-related actions, like governor START/STOP doing worker
> creation/teardown.
> 
> One simple short-term solution would be to take a mutex outside of the
> policy rwlock write lock in cpufreq.c. This mutex would be the
> equivalent of dbs_mutex "lifted" outside of the rwlock write lock. For
> teardown, we only need to hold this mutex, not the rwlock write lock.
> Then we can remove the dbs_mutex from the governors.
> 
> But looking at cpufreq.c's cpufreq_add_dev() is very much like kicking a
> wasp nest: a lot of error paths are not handled properly, and I fear
> someone will have to go through the code, fix the currently incorrect
> code paths, and then add the lifted mutex.
> 
> I currently have no time for implementation due to my thesis, but I'll
> be happy to review a patch.
> 

How about below patch on top of Mathieu's patch here
http://marc.info/?l=linux-kernel&m=124448150529838&w=2

[PATCH] cpufreq: Eliminate lockdep issue with dbs_mutex and policy_rwsem

This removes the unneeded dependency of 
write rwlock policy
  dbs_mutex

dbs_mutex does not have anything to do with timer_init and timer_exit. It
is just to protect dbs tunables in sysfs cpufreq/ondemand and is not
needed to be held during timer init, exit as well as during governor limit
changes.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
---
 drivers/cpufreq/cpufreq_ondemand.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e741c33..1c94ff5 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -352,8 +352,8 @@ static ssize_t store_powersave_bias(struct cpufreq_policy *unused,
 
 	mutex_lock(&dbs_mutex);
 	dbs_tuners_ins.powersave_bias = input;
-	ondemand_powersave_bias_init();
 	mutex_unlock(&dbs_mutex);
+	ondemand_powersave_bias_init();
 
 	return count;
 }
@@ -626,14 +626,14 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 
 			dbs_tuners_ins.sampling_rate = def_sampling_rate;
 		}
+		mutex_unlock(&dbs_mutex);
 		dbs_timer_init(this_dbs_info);
 
-		mutex_unlock(&dbs_mutex);
 		break;
 
 	case CPUFREQ_GOV_STOP:
-		mutex_lock(&dbs_mutex);
 		dbs_timer_exit(this_dbs_info);
+		mutex_lock(&dbs_mutex);
 		sysfs_remove_group(&policy->kobj, &dbs_attr_group);
 		dbs_enable--;
 		mutex_unlock(&dbs_mutex);
@@ -641,14 +641,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 		break;
 
 	case CPUFREQ_GOV_LIMITS:
-		mutex_lock(&dbs_mutex);
 		if (policy->max < this_dbs_info->cur_policy->cur)
 			__cpufreq_driver_target(this_dbs_info->cur_policy,
 				policy->max, CPUFREQ_RELATION_H);
 		else if (policy->min > this_dbs_info->cur_policy->cur)
 			__cpufreq_driver_target(this_dbs_info->cur_policy,
 				policy->min, CPUFREQ_RELATION_L);
-		mutex_unlock(&dbs_mutex);
 		break;
 	}
 	return 0;
-- 
1.6.0.6


  reply	other threads:[~2009-06-17  0:39 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-07  9:47 2.6.30-rc8-git4: Reported regressions from 2.6.29 Rafael J. Wysocki
2009-06-07  9:47 ` [Bug #13109] High latency on /sys/class/thermal Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13116] Can't boot with nosmp Rafael J. Wysocki
2009-06-08 16:15   ` Stephen Hemminger
2009-06-08 16:29     ` Dan Williams
2009-06-09  0:04       ` Stephen Hemminger
2009-06-09 17:20         ` Dan Williams
2009-06-09 18:30           ` Avi Kivity
2009-06-09 18:36             ` Stephen Hemminger
2009-06-09 18:42               ` Avi Kivity
2009-06-09 20:58                 ` Stephen Hemminger
2009-06-09 23:19                   ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13179] CD-R: wodim intermittent failures Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13277] 2.6.30 regression - unreliable resume - bisected - Thinkpad X40 Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13119] Trouble with make-install from a NFS mount Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13219] Since kernel 2.6.30-rc1, computers hangs randomly Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13180] 2.6.30-rc2: WARNING at i915_gem.c for i915_gem_idle Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13318] AGP doesn't work anymore on nforce2 Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13306] hibernate slow on _second_ run Rafael J. Wysocki
2009-06-08  6:36   ` Johannes Berg
2009-06-08 11:14     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13319] Page allocation failures with b43 and p54usb Rafael J. Wysocki
2009-06-07 13:10   ` Larry Finger
2009-06-07 13:40     ` Pekka Enberg
2009-06-07 14:19       ` Rik van Riel
2009-06-07 14:32         ` Pekka Enberg
2009-06-07 16:35           ` Larry Finger
2009-06-08  8:32             ` KAMEZAWA Hiroyuki
2009-06-08 17:20               ` Larry Finger
2009-06-08 10:17           ` Mel Gorman
2009-06-08 10:52             ` Pekka Enberg
2009-06-08 11:03               ` Mel Gorman
2009-06-08 13:58                 ` Pekka J Enberg
2009-06-08 14:12                   ` Mel Gorman
2009-06-08 14:42                     ` Christoph Lameter
2009-06-09  7:06                     ` Pekka Enberg
2009-06-09  7:54                       ` David Rientjes
2009-06-09  7:58                         ` Pekka Enberg
2009-06-09  8:14                           ` David Rientjes
2009-06-09  8:28                             ` Pekka Enberg
2009-06-10 14:41                               ` Larry Finger
2009-06-10 15:44                                 ` Pekka Enberg
2009-06-10 15:49                                   ` Pekka Enberg
2009-06-10 15:52                                     ` Johannes Berg
2009-06-10 16:06                                       ` Pekka Enberg
2009-06-10 16:16                                       ` Pekka Enberg
2009-06-10 16:10                                     ` Larry Finger
2009-06-11 14:41                                   ` Christoph Lameter
2009-06-11 15:09                                     ` Pekka Enberg
2009-06-11 18:41                                       ` Johannes Berg
2009-06-10 15:56                       ` Mel Gorman
2009-06-10 18:03                         ` Pekka Enberg
2009-06-09  7:50                     ` Pekka Enberg
2009-06-08 13:20             ` Rik van Riel
2009-06-08 13:35               ` Mel Gorman
2009-06-08 13:34             ` Larry Finger
2009-06-07  9:52 ` [Bug #13313] vm86old oops Rafael J. Wysocki
2009-06-11 13:02   ` Sergey Senozhatsky
2009-06-07  9:52 ` [Bug #13328] b44: eth0: BUG! Timeout waiting for bit 00000002 of register 42c to clear Rafael J. Wysocki
2009-06-08  7:29   ` Francis Moreau
2009-06-12 13:27     ` Francis Moreau
2009-06-12 19:14       ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13341] Random Oops at boot at loading ip6tables rules Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13337] [post 2.6.29 regression] hang during suspend of b44/b43 modules Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13330] nfs4 NULL pointer dereference in _nfs4_do_setlk Rafael J. Wysocki
2009-06-07 19:28   ` Trond Myklebust
2009-06-07 21:04     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13351] 2.6.30 corrupts my system after suspend resume with readonly mounted hard disk Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13362] rt2x00: slow wifi with correct basic rate bitmap Rafael J. Wysocki
2009-06-07 12:58   ` Alejandro Riveira Fernández
2009-06-07 21:05     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13366] About 80% of shutdowns fail (blocking) Rafael J. Wysocki
2009-06-07 16:02   ` Martin Bammer
2009-06-07 21:09     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13389] Warning 'Invalid throttling state, reset' gets displayed when it should not be Rafael J. Wysocki
2009-06-08 11:31   ` Frans Pop
2009-06-07  9:52 ` [Bug #13374] reiserfs blocked for more than 120secs Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13391] Kernel boot hangs at about every second start when kms is activated Rafael J. Wysocki
2009-06-07 16:04   ` Martin Bammer
2009-06-07 21:11     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13373] fbcon, intelfb, i915: INFO: possible circular locking dependency detected Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13401] pktcdvd writing is really slow with CFQ scheduler (bisected) Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13407] adb trackpad disappears after suspend to ram Rafael J. Wysocki
2009-06-25 15:07   ` Jan Scholz
2009-06-07  9:52 ` [Bug #13408] Performance regression in 2.6.30-rc7 Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13423] JMicron SATA controller not available Rafael J. Wysocki
2009-06-07 15:23   ` Marc Dionne
2009-06-07 21:13     ` Rafael J. Wysocki
2009-06-08  2:12       ` Marc Dionne
2009-06-07  9:52 ` [Bug #13424] possible deadlock when doing governor switching Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13446] resume after suspend-to-ram broken on Toshiba Satellite A100 with 2.6.30-rc8 (works in 2.6.28) Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13470] Machine doesn't boot due to mmconfig detection problem Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13462] Unused bands in intefb console and smaller 180x56 -> 128x48 Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13474] Oops whilst booting Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13475] suspend/hibernate lockdep warning Rafael J. Wysocki
2009-06-07 13:21   ` Pekka Enberg
2009-06-08  7:35     ` Dave Young
2009-06-08  7:49       ` Pekka Enberg
2009-06-08 12:48         ` Mathieu Desnoyers
2009-06-08 14:32           ` Dave Jones
2009-06-08 15:23             ` [PATCH] remove rwsem lock from CPUFREQ_GOV_STOP call (second call site) Mathieu Desnoyers
2009-06-08 16:57               ` Pallipadi, Venkatesh
2009-06-08 17:17                 ` Mathieu Desnoyers
2009-06-09  1:15               ` Dave Young
2009-06-09 15:23                 ` Mathieu Desnoyers
2009-06-11  4:46                   ` Dave Young
2009-06-11 13:39             ` [Bug #13475] suspend/hibernate lockdep warning Simon Holm Thøgersen
2009-06-11 15:23               ` Mathieu Desnoyers
2009-06-17  0:39                 ` Pallipadi, Venkatesh [this message]
2009-06-17  1:05                   ` Mathieu Desnoyers
2009-06-17 15:29                   ` Thomas Renninger
2009-06-17 17:03                     ` Pallipadi, Venkatesh
2009-06-18  5:46                   ` Dave Young
2009-06-07  9:52 ` [Bug #13473] Bug while trying to launch a KVM guest Rafael J. Wysocki
2009-06-08  4:26   ` Sachin Sant
2009-06-08 11:16     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13471] Loading parport_pc kills the keyboard if ACPI is enabled Rafael J. Wysocki
2009-06-07 13:25   ` Ozan Çağlayan
2009-06-07 21:14     ` Rafael J. Wysocki
2009-06-07  9:52 ` [Bug #13472] Oops with minicom and USB serial Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2009-06-29  0:26 2.6.31-rc1-git3: Reported regressions 2.6.29 -> 2.6.30 Rafael J. Wysocki
2009-06-29  0:30 ` [Bug #13475] suspend/hibernate lockdep warning Rafael J. Wysocki
2009-07-06 23:57 2.6.31-rc2: Reported regressions 2.6.29 -> 2.6.30 Rafael J. Wysocki
2009-07-07  0:00 ` [Bug #13475] suspend/hibernate lockdep warning Rafael J. Wysocki
2009-07-26 20:41 2.6.31-rc4: Reported regressions 2.6.29 -> 2.6.30 Rafael J. Wysocki
2009-07-26 20:45 ` [Bug #13475] suspend/hibernate lockdep warning Rafael J. Wysocki
2009-07-27  1:59   ` Dave Young
2009-07-27 16:52   ` Mathieu Desnoyers
2009-07-27 21:57     ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090617003925.GA3900@linux-os.sc.intel.com \
    --to=venkatesh.pallipadi@intel.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=hidave.darkstar@gmail.com \
    --cc=kernel-testers@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=odie@cs.aau.dk \
    --cc=penberg@cs.helsinki.fi \
    --cc=rjw@sisk.pl \
    --cc=rusty@rustcorp.com.au \
    --cc=sven.wegener@stealer.net \
    --cc=trenn@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).