lkml.org 
[lkml]   [2013]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] block: Fix possible sleep in invalid context
On Mon, 01 Jul 2013 15:24:11 -0700 James Bottomley <James.Bottomley@hansenpartnership.com> wrote:

> > --- a/block/blk-core.c~block-fix-possible-sleep-in-invalid-context-fix
> > +++ a/block/blk-core.c
> > @@ -3159,15 +3159,14 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
> > */
> > void blk_post_runtime_resume(struct request_queue *q, int err)
> > {
> > + spin_lock_irq(q->queue_lock);
> > if (!err) {
> > - spin_lock_irq(q->queue_lock);
> > q->rpm_status = RPM_ACTIVE;
> > __blk_run_queue(q);
> > pm_runtime_mark_last_busy(q->dev);
> > spin_unlock_irq(q->queue_lock);
> > pm_request_autosuspend(q->dev);
> > } else {
> > - spin_lock_irq(q->queue_lock);
> > q->rpm_status = RPM_SUSPENDED;
> > spin_unlock_irq(q->queue_lock);
> > }
> > _
> >
> >
> > I wonder if we actually need locking around that second write to
> > q->rpm_status.
>
> Shouldn't: it's an int, which makes it a 32 bit quantity we believe to
> have atomic write properties on every platform.

Yes, but. If there's some other code path which does:

spin_lock(queue_lock);
x = q->rpm_status;
...
y = q->rpm_status;
...
<assumes x == y>
spin_unlock(queue_lock);

then it blows up if we make the suggested change. Stranger things have
happened...



\
 
 \ /
  Last update: 2013-07-02 01:01    [W:0.038 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site