From: Miklos Szeredi <miklos@szeredi.hu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-aio <linux-aio@kvack.org>,
Benjamin LaHaise <bcrl@kvack.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
stable <stable@vger.kernel.org>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] fuse: disable irqs for fuse_iqueue::waitq.lock
Date: Fri, 6 Sep 2019 08:58:51 +0200 [thread overview]
Message-ID: <CAJfpegvdh53VSQ9okuUTS3jQFjkbcwPdJFmUorE0nseeFRPaoA@mail.gmail.com> (raw)
In-Reply-To: <20190906044324.GE803@sol.localdomain>
On Fri, Sep 6, 2019 at 6:43 AM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Wed, Sep 04, 2019 at 04:29:03PM +0200, Miklos Szeredi wrote:
> > TBH, I find the fix disgusting. It's confusing to sprinke code that
> > has absolutely nothing to do with interrupts with spin_lock_irq()
> > calls.
> >
> > I think the lock/unlock calls should at least be done with a helper
> > with a comment explaining why disabling interrupts is needed (though I
> > have not managed to understand why aio needs to actually mess with the
> > waitq lock...)
>
> The aio code is doing a poll(), so it needs to use the wait queue.
Doesn't explain why the irq disabled nested locking is needed in
aio_poll(). poll/select manage to do that without messing with waitq
internals. How is aio poll different?
> >
> > Probably a better fix would be to just use a separate spinlock to
> > avoid the need to disable interrupts in cases where it's not
> > necessary.
>
> Well, the below is what a separate lock would look like. Note that it actually
> still disables IRQs in some places; it's just hidden away in the nested
> spin_lock_irqsave() in wake_up(). Likewise, adding something to the fuse_iqueue
> then requires taking 2 spin locks -- one explicit, and one hidden in wake_up().
Right, that's exactly why the waitq lock was used.
> Is this the solution you'd prefer?
I'd actually prefer if aio was fixed. But I guess that's not
realistic, so yes, the below patch looks okay. If fiq->lock is in the
same cacheline as fiq->waitq then it shouldn't make a difference.
Thanks,
Miklos
next prev parent reply other threads:[~2019-09-06 6:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-18 16:18 possible deadlock in io_submit_one (2) syzbot
[not found] ` <20190822233529.4176-1-ebiggers@kernel.org>
2019-09-03 7:31 ` [PATCH] fuse: disable irqs for fuse_iqueue::waitq.lock Miklos Szeredi
2019-09-03 13:39 ` Eric Biggers
2019-09-04 14:29 ` Miklos Szeredi
2019-09-06 4:43 ` Eric Biggers
2019-09-06 6:58 ` Miklos Szeredi [this message]
2019-09-09 3:15 ` [PATCH v2] fuse: fix deadlock with aio poll and fuse_iqueue::waitq.lock Eric Biggers
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=CAJfpegvdh53VSQ9okuUTS3jQFjkbcwPdJFmUorE0nseeFRPaoA@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=bcrl@kvack.org \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
/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).