From: Linus Torvalds <torvalds@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Hugh Dickins <hughd@google.com>, Jan Kara <jack@suse.cz>,
syzbot <syzbot+3622cea378100f45d59f@syzkaller.appspotmail.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
"Theodore Ts'o" <tytso@mit.edu>, Linux-MM <linux-mm@kvack.org>,
Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Nicholas Piggin <npiggin@gmail.com>,
Alex Shi <alex.shi@linux.alibaba.com>, Qian Cai <cai@lca.pw>,
Christoph Hellwig <hch@infradead.org>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
William Kucharski <william.kucharski@oracle.com>,
Jens Axboe <axboe@kernel.dk>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: kernel BUG at fs/ext4/inode.c:LINE!
Date: Tue, 24 Nov 2020 11:00:42 -0800 [thread overview]
Message-ID: <CAHk-=wjtGAUP5fydxR8iWbzB65p2XvM0BrHE=PkPLQcJ=kq_8A@mail.gmail.com> (raw)
In-Reply-To: <20201124183351.GD4327@casper.infradead.org>
On Tue, Nov 24, 2020 at 10:33 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> We could fix this by turning that 'if' into a 'while' in
> write_cache_pages().
That might be the simplest patch indeed.
At the same time, I do worry about other cases like this: while
spurious wakeup events are normal and happen in other places, this is
a bit different.
This is literally a wakeup that leaks from a previous use of a page,
and makes us think that something could have happened to the new use.
The unlock_page() case presumably never hits that, because even if we
have some unlock without a page ref (which I don't think can happen,
but whatever..), the exclusive nature of "lock_page()" means that no
locker can care - once you get the lock, you own the page./
The writeback code is special in that the writeback bit isn't some
kind of exclusive bit, but this code kind of expected it to be that.
So I'd _like_ to have something like
WARN_ON_ONCE(!page_count(page));
in the wake_up_page_bit() function, to catch things that wake up a
page that has already been released and might be reused..
And that would require the "get_page()" to be done when we set the
writeback bit and queue the page up for IO (so that then
end_page_writeback() would clear the bit, do the wakeup, and then drop
the ref).
Hugh's second patch isn't pretty - I think the "get_page()" is
conceptually in the wrong place - but it "works" in that it keeps that
"implicit page reference" being kept by the PG_writeback bit, and then
it takes an explicit page reference before it clears the bit.
So while I don't love the whole "PG_writeback is an implicit reference
to the page" model, Hugh's patch at least makes that model much more
straightforward: we really either have that PG_writeback, _or_ we have
a real ref to the page, and we never have that odd "we could actually
lose the page" situation.
So I think I prefer Hugh's two-liner over your one-liner suggestion.
But your one-liner is technically not just smaller, it obviously also
avoids the whole mucking with the atomic page ref.
I don't _think_ that the extra get/put overhead could possibly really
matter: doing the writeback is going to be a lot more expensive
anyway. And an atomic access to a 'struct page' sounds expensive, but
that cacheline is already likely dirty in the L1 cache because we've
touch page->flags and done other things to it).
So I'd personally be inclined to go with Hugh's patch. Comments?
Linus
next prev parent reply other threads:[~2020-11-24 19:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <000000000000d3a33205add2f7b2@google.com>
2020-08-28 10:07 ` Jan Kara
2020-08-31 10:03 ` Jan Kara
2020-08-31 18:21 ` Linus Torvalds
2020-11-24 4:07 ` Hugh Dickins
2020-11-24 4:26 ` Linus Torvalds
2020-11-24 4:53 ` Linus Torvalds
2020-11-24 6:34 ` Hugh Dickins
2020-11-24 16:46 ` Hugh Dickins
2020-11-24 12:19 ` Matthew Wilcox
2020-11-24 16:28 ` Hugh Dickins
2020-11-24 18:33 ` Matthew Wilcox
2020-11-24 19:00 ` Linus Torvalds [this message]
2020-11-24 20:15 ` Matthew Wilcox
2020-11-24 20:34 ` Linus Torvalds
2020-11-24 21:46 ` Hugh Dickins
2020-11-24 23:24 ` Linus Torvalds
2020-11-25 21:30 ` Linus Torvalds
2020-11-25 22:01 ` Linus Torvalds
2020-11-25 9:20 ` Jan Kara
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='CAHk-=wjtGAUP5fydxR8iWbzB65p2XvM0BrHE=PkPLQcJ=kq_8A@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=cai@lca.pw \
--cc=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=kirill@shutemov.name \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=npiggin@gmail.com \
--cc=oleg@redhat.com \
--cc=syzbot+3622cea378100f45d59f@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tytso@mit.edu \
--cc=william.kucharski@oracle.com \
--cc=willy@infradead.org \
/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