Hi Jeff, I checked the code, found one suspicious place as below:
- f2fs_build_node_manager - init_node_manager - __get_nat_bitmaps - disable_nat_bits(, true) disable_nat_bits(.., lock) { ... if (lock) spin_lock_irqsave(&sbi->cp_lock, flags); __clear_ckpt_flags(F2FS_CKPT(sbi), CP_NAT_BITS_FLAG); kvfree(NM_I(sbi)->nat_bits); NM_I(sbi)->nat_bits = NULL; if (lock) spin_unlock_irqrestore(&sbi->cp_lock, flags); } I don't think we have to call kvfree() under spinlock, so I can simply change it as below to fix the warning. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 19e5a5f..e7c99b5 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1667,6 +1667,7 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f) static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock) { unsigned long flags; + unsigned char *nat_bits; /* * In order to re-enable nat_bits we need to call fsck.f2fs by @@ -1677,10 +1678,12 @@ static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock) if (lock) spin_lock_irqsave(&sbi->cp_lock, flags); __clear_ckpt_flags(F2FS_CKPT(sbi), CP_NAT_BITS_FLAG); - kvfree(NM_I(sbi)->nat_bits); + nat_bits = NM_I(sbi)->nat_bits; NM_I(sbi)->nat_bits = NULL; if (lock) spin_unlock_irqrestore(&sbi->cp_lock, flags); + + kvfree(nat_bits); } BTW, in f2fs, it's possible to hit kvfree()->vfree() in the case of we face memory pressure, due to f2fs_kmalloc() will fallback to call kvmalloc() once failed in kmalloc(). Thanks, On 2019/7/25 20:37, Jeff Layton wrote: > I was playing with a patch to add a might_sleep_if(!in_interrupt()); to > the top of kvfree: > > https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git/commit/?h=mm-5.4&id=e49f335dedc18a2ee0ac7791134b282abd9c857f > > The kernel test robot picked it up and saw a new warning pop in a f2fs > call stack. I took a quick look but didn't see the bug, but one of you > guys may want to play with that patch and try to hunt it down. > > Cheers, > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel