All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Dave Chinner <david@fromorbit.com>
Cc: "linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
	Dave Chinner <dchinner@redhat.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	kasan-dev@googlegroups.com,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>
Subject: Re: Lockdep splat with xfs
Date: Thu, 19 Jan 2023 14:13:36 +0900	[thread overview]
Message-ID: <29f91612-bcb7-e9a7-ec14-b89efe455b1f@opensource.wdc.com> (raw)
In-Reply-To: <20230119045253.GI360264@dread.disaster.area>

On 2023/01/19 13:52, Dave Chinner wrote:
> It's a false positive, and the allocation context it comes from
> in XFS is documented as needing to avoid lockdep tracking because
> this path is know to trigger false positive memory reclaim recursion
> reports:
> 
>         if (!args->value) {
>                 args->value = kvmalloc(valuelen, GFP_KERNEL | __GFP_NOLOCKDEP);
>                 if (!args->value)
>                         return -ENOMEM;
>         }
>         args->valuelen = valuelen;
> 
> 
> XFS is telling the allocator not to track this allocation with
> lockdep, and that is getting passed down through the allocator which
> has not passed it to lockdep (correct behaviour!), but then KASAN is
> trying to track the allocation and that needs to do a memory
> allocation.  __stack_depot_save() is passed the gfp mask from the
> allocation context so it has __GFP_NOLOCKDEP right there, but it
> does:
> 
>         if (unlikely(can_alloc && !smp_load_acquire(&next_slab_inited))) {
>                 /*
>                  * Zero out zone modifiers, as we don't have specific zone
>                  * requirements. Keep the flags related to allocation in atomic
>                  * contexts and I/O.
>                  */
>                 alloc_flags &= ~GFP_ZONEMASK;
>>>>>>>>         alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
>                 alloc_flags |= __GFP_NOWARN;
>                 page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
> 
> It masks masks out anything other than GFP_ATOMIC and GFP_KERNEL
> related flags. This drops __GFP_NOLOCKDEP on the floor, hence
> lockdep tracks an allocation in a context we've explicitly said not
> to track. Hence lockdep (correctly!) explodes later when the
> false positive "lock inode in reclaim context" situation triggers.
> 
> This is a KASAN bug. It should not be dropping __GFP_NOLOCKDEP from
> the allocation context flags.

OK. Thanks for the explanation !

-- 
Damien Le Moal
Western Digital Research


      reply	other threads:[~2023-01-19  5:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  1:28 Lockdep splat with xfs Damien Le Moal
2023-01-19  4:52 ` Dave Chinner
2023-01-19  5:13   ` Damien Le Moal [this message]

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=29f91612-bcb7-e9a7-ec14-b89efe455b1f@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=david@fromorbit.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ryabinin.a.a@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.