From: Dave Chinner <david@fromorbit.com>
To: Waiman Long <longman@redhat.com>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Qian Cai <cai@lca.pw>, Eric Sandeen <sandeen@redhat.com>
Subject: Re: [PATCH v2] xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim
Date: Fri, 5 Jun 2020 09:13:27 +1000 [thread overview]
Message-ID: <20200604231327.GV2040@dread.disaster.area> (raw)
In-Reply-To: <20200604210130.697-1-longman@redhat.com>
On Thu, Jun 04, 2020 at 05:01:30PM -0400, Waiman Long wrote:
> ---
> fs/xfs/xfs_log.c | 3 ++-
> fs/xfs/xfs_trans.c | 8 +++++++-
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 00fda2e8e738..d273d4e74ef8 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -433,7 +433,8 @@ xfs_log_reserve(
> XFS_STATS_INC(mp, xs_try_logspace);
>
> ASSERT(*ticp == NULL);
> - tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent, 0);
> + tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent,
> + mp->m_super->s_writers.frozen ? KM_NOLOCKDEP : 0);
> *ticp = tic;
Hi Waiman,
As I originally stated when you posted this the first time 6 months
ago: we are not going to spread this sort of conditional gunk though
the XFS codebase just to shut up lockdep false positives.
I pointed you at the way to conditionally turn of lockdep for
operations where we are doing transactions when the filesystem has
already frozen the transaction subsystem. That is:
>
> xlog_grant_push_ail(log, tic->t_cnt ? tic->t_unit_res * tic->t_cnt
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 3c94e5ff4316..3a9f394a0f02 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -261,8 +261,14 @@ xfs_trans_alloc(
> * Allocate the handle before we do our freeze accounting and setting up
> * GFP_NOFS allocation context so that we avoid lockdep false positives
> * by doing GFP_KERNEL allocations inside sb_start_intwrite().
> + *
> + * To prevent false positive lockdep warning of circular locking
> + * dependency between sb_internal and fs_reclaim, disable the
> + * acquisition of the fs_reclaim pseudo-lock when the superblock
> + * has been frozen or in the process of being frozen.
> */
> - tp = kmem_zone_zalloc(xfs_trans_zone, 0);
> + tp = kmem_zone_zalloc(xfs_trans_zone,
> + mp->m_super->s_writers.frozen ? KM_NOLOCKDEP : 0);
> if (!(flags & XFS_TRANS_NO_WRITECOUNT))
We only should be setting KM_NOLOCKDEP when XFS_TRANS_NO_WRITECOUNT
is set. That's the flag that transactions set when they run in a
fully frozen context to avoid deadlocking with the freeze in
progress, and that's the only case where we should be turning off
lockdep.
And, as I also mentioned, this should be done via a process flag -
PF_MEMALLOC_NOLOCKDEP - so that it is automatically inherited by
all subsequent memory allocations done in this path. That way we
only need this wrapping code in xfs_trans_alloc():
if (flags & XFS_TRANS_NO_WRITECOUNT)
memalloc_nolockdep_save()
.....
if (flags & XFS_TRANS_NO_WRITECOUNT)
memalloc_nolockdep_restore()
and nothing else needs to change.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2020-06-04 23:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 21:01 [PATCH v2] xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim Waiman Long
2020-06-04 23:13 ` Dave Chinner [this message]
2020-06-05 0:46 ` Waiman Long
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=20200604231327.GV2040@dread.disaster.area \
--to=david@fromorbit.com \
--cc=cai@lca.pw \
--cc=darrick.wong@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=longman@redhat.com \
--cc=sandeen@redhat.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