Messages in this thread | | | Subject | Re: Possible IRQ lock inversion from 2.6.29-Linus-03321-gbe0ea69 (2.6.29-git) | From | Peter Zijlstra <> | Date | Sat, 28 Mar 2009 01:32:01 +0100 |
| |
On Fri, 2009-03-27 at 12:06 -0600, Jonathan Corbet wrote: > On Fri, 27 Mar 2009 13:54:35 +0100 > Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote: > > > I remember looking a bit more closely into the issue and not seeing > > the problem with the locking (though I could have missed something): > > > > file->f_lock is never taken in hard-irq or soft-irq context and in > > the only place where file->f_lock is taken with fasync_lock hold we're > > protected against IRQs by write_lock_irq(). > > I do think that the warning is spurious at this time.
I think you're right (although at 1:30 am I can't be sure).
It does point to inconsistent (sloppy) lock usage though, because f_lock is used both with and without irqs disabled -- so on that ground its correct to complain.
> diff --git a/fs/fcntl.c b/fs/fcntl.c > index d865ca6..b9c1a4b 100644 > --- a/fs/fcntl.c > +++ b/fs/fcntl.c > @@ -531,6 +531,7 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap > if (!new) > return -ENOMEM; > } > + spin_lock(&filp->f_lock); /* outside fasync_lock to keep lockdep happy */
Please don't put in comments like that, they're worse than useless. Either explain in detail how and why, or don't bother.
> write_lock_irq(&fasync_lock); > for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) { > if (fa->fa_file == filp) { > @@ -555,14 +556,12 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap > result = 1; > } > out: > - /* Fix up FASYNC bit while still holding fasync_lock */ > - spin_lock(&filp->f_lock); > if (on) > filp->f_flags |= FASYNC; > else > filp->f_flags &= ~FASYNC; > - spin_unlock(&filp->f_lock); > write_unlock_irq(&fasync_lock); > + spin_unlock(&filp->f_lock); > return result; > }
| |