From: Boqun Feng <boqun.feng@gmail.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Filipe Manana <fdmanana@gmail.com>,
Peter Zijlstra <peterz@infradead.org>, Jan Kara <jack@suse.cz>,
David Sterba <dsterba@suse.com>,
Nikolay Borisov <nborisov@suse.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [RFC] fs: Avoid to use lockdep information if it's turned off
Date: Tue, 10 Nov 2020 13:40:16 +0800 [thread overview]
Message-ID: <20201110054016.GC286534@boqun-archlinux> (raw)
In-Reply-To: <20201110014925.GB9685@magnolia>
On Mon, Nov 09, 2020 at 05:49:25PM -0800, Darrick J. Wong wrote:
> On Tue, Nov 10, 2020 at 09:37:37AM +0800, Boqun Feng wrote:
> > Filipe Manana reported a warning followed by task hanging after attempts
> > to freeze a filesystem[1]. The problem happened in a LOCKDEP=y kernel,
> > and percpu_rwsem_is_held() provided incorrect results when
> > debug_locks == 0. Although the behavior is caused by commit 4d004099a668
> > ("lockdep: Fix lockdep recursion"): after that lock_is_held() and its
> > friends always return true if debug_locks == 0. However, one could argue
>
> ...the silent trylock conversion with no checking of the return value is
> completely broken. I already sent a patch to tear all this out:
>
> https://lore.kernel.org/linux-fsdevel/160494580419.772573.9286165021627298770.stgit@magnolia/T/#t
>
Thanks! That looks good to me. I'm all for removing that piece of code.
While we are at it, I have to ask, when you hit the original problem
(warning after trylock in __start_sb_write()), did you see any lockdep
splat happened previously? Or just like Filipe, you hit that without
seeing any lockdep splat happened before? Thanks! I'm trying to track
down the silent lockdep turn-off.
Regards,
Boqun
> --D
>
> > that querying the lock holding information regardless if the lockdep
> > turn-off status is inappropriate in the first place. Therefore instead
> > of reverting lock_is_held() and its friends to the previous semantics,
> > add the explicit checking in fs code to avoid use the lock holding
> > information if lockdpe is turned off. And since the original problem
> > also happened with a silent lockdep turn-off, put a warning if
> > debug_locks is 0, which will help us spot the silent lockdep turn-offs.
> >
> > [1]: https://lore.kernel.org/lkml/a5cf643b-842f-7a60-73c7-85d738a9276f@suse.com/
> >
> > Reported-by: Filipe Manana <fdmanana@gmail.com>
> > Fixes: 4d004099a668 ("lockdep: Fix lockdep recursion")
> > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Jan Kara <jack@suse.cz>
> > Cc: David Sterba <dsterba@suse.com>
> > Cc: Nikolay Borisov <nborisov@suse.com>
> > Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
> > ---
> > Hi Filipe,
> >
> > I use the slightly different approach to fix this problem, and I think
> > it should have the similar effect with my previous fix[2], except that
> > you will hit a warning if the problem happens now. The warning is added
> > on purpose because I don't want to miss a silent lockdep turn-off.
> >
> > Could you and other fs folks give this a try?
> >
> > Regards,
> > Boqun
> >
> > [2]: https://lore.kernel.org/lkml/20201103140828.GA2713762@boqun-archlinux/
> >
> > fs/super.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/fs/super.c b/fs/super.c
> > index a51c2083cd6b..1803c8d999e9 100644
> > --- a/fs/super.c
> > +++ b/fs/super.c
> > @@ -1659,12 +1659,23 @@ int __sb_start_write(struct super_block *sb, int level, bool wait)
> > * twice in some cases, which is OK only because we already hold a
> > * freeze protection also on higher level. Due to these cases we have
> > * to use wait == F (trylock mode) which must not fail.
> > + *
> > + * Note: lockdep can only prove correct information if debug_locks != 0
> > */
> > if (wait) {
> > int i;
> >
> > for (i = 0; i < level - 1; i++)
> > if (percpu_rwsem_is_held(sb->s_writers.rw_sem + i)) {
> > + /*
> > + * XXX: the WARN_ON_ONCE() here is to help
> > + * track down silent lockdep turn-off, i.e.
> > + * this warning is triggered, but no lockdep
> > + * splat is reported.
> > + */
> > + if (WARN_ON_ONCE(!debug_locks))
> > + break;
> > +
> > force_trylock = true;
> > break;
> > }
> > --
> > 2.29.2
> >
next prev parent reply other threads:[~2020-11-10 5:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 1:37 [RFC] fs: Avoid to use lockdep information if it's turned off Boqun Feng
2020-11-10 1:49 ` Darrick J. Wong
2020-11-10 5:40 ` Boqun Feng [this message]
2020-11-10 16:49 ` Darrick J. Wong
2020-11-10 15:33 ` David Sterba
2020-11-11 14:01 ` David Sterba
2020-11-12 3:22 ` Boqun Feng
2020-11-13 17:19 ` David Sterba
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=20201110054016.GC286534@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=dsterba@suse.com \
--cc=fdmanana@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=nborisov@suse.com \
--cc=peterz@infradead.org \
--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