Re: Lockdep splat with xfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux