lkml.org 
[lkml]   [2010]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [linux-pm] [GIT PULL] One more power management fix for 2.6.37
On Thu, Nov 4, 2010 at 9:24 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>
> OK, so I think we can relax the locking in dpm_[suspend/resume]_noirq() to
> avoid executing callbacks under dpm_list_mtx, like in the (untested) patch
> below.

ABSOLUTELY NOT.

If you drop the lock in the middle of the loop, you should remove the
lock around the loop entirely. There is absolutely no difference
between "drop lock in the middle" and "don't take lock at all".

Either that list traversal needs the lock or it does not. There is no
"it needs the lock, but not while doing random crap X in the middle of
traversal".

If nothing can possibly change the list while calling the device, then
you don't need the lock. And if something _can_ change the list,
dropping the lock means that the list is no longer trustworthy and you
can't just continue in the middle.

Don't write code like this with nonsensical locking. Not even if it is
a case of "it happens to work because we have those other totally
random rules".

Linus


\
 
 \ /
  Last update: 2010-11-04 18:11    [W:0.107 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site