From: Peter Zijlstra <peterz@infradead.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
Larry Finger <Larry.Finger@lwfinger.net>,
LKML <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
Li Zefan <lizf@cn.fujitsu.com>,
Wu Fengguang <fengguang.wu@intel.com>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: Possible IRQ lock inversion from 2.6.29-Linus-03321-gbe0ea69 (2.6.29-git)
Date: Sat, 28 Mar 2009 01:32:01 +0100 [thread overview]
Message-ID: <1238200321.4039.371.camel@laptop> (raw)
In-Reply-To: <20090327120623.3056c795@bike.lwn.net>
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;
> }
next prev parent reply other threads:[~2009-03-28 0:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 5:07 Possible IRQ lock inversion from 2.6.29-Linus-03321-gbe0ea69 (2.6.29-git) Larry Finger
2009-03-27 12:54 ` Bartlomiej Zolnierkiewicz
2009-03-27 18:06 ` Jonathan Corbet
2009-03-27 19:05 ` Larry Finger
2009-03-28 0:32 ` Peter Zijlstra [this message]
2009-03-28 13:36 ` Bartlomiej Zolnierkiewicz
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=1238200321.4039.371.camel@laptop \
--to=peterz@infradead.org \
--cc=Larry.Finger@lwfinger.net \
--cc=bzolnier@gmail.com \
--cc=corbet@lwn.net \
--cc=fengguang.wu@intel.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mingo@elte.hu \
--cc=viro@zeniv.linux.org.uk \
/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