Re: [syzbot] [mm?] [cgroups?] WARNING in __mod_memcg_lruvec_state

Shakeel Butt
2024-05-06T15:59:38Z

On Mon, May 06, 2024 at 02:11:57PM +0000, Yosry Ahmed wrote:
> On Mon, May 06, 2024 at 06:03:29AM -0700, syzbot wrote:
> > syzbot has found a reproducer for the following issue on:
> >
> > HEAD commit: 2b84edefcad1 Add linux-next specific files for 20240506
> > git tree: linux-next
> > console+strace: https://syzkaller.appspot.com/x/log.txt?x=1164931f180000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=b499929e4aaba1af
> > dashboard link: https://syzkaller.appspot.com/bug?extid=9319a4268a640e26b72b
> > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=123d5d1f180000
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16527450980000
> >
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/6a22cf95ee14/disk-2b84edef.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/f5c45b515282/vmlinux-2b84edef.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/9bf98258a662/bzImage-2b84edef.xz
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+9319a4268a640e26b72b@syzkaller.appspotmail.com
> >
> > ------------[ cut here ]------------
> > __mod_memcg_lruvec_state: missing stat item 25
> > WARNING: CPU: 0 PID: 5091 at mm/memcontrol.c:999 __mod_memcg_lruvec_state+0x18c/0x430 mm/memcontrol.c:999
>
> This doesn't seem to be the same issue as the original one syzbot
> reported. It's the same function but a different warning. I am not sure
> how to tell syzbot that.
>
> Anyway, this warning is the one newly introduced by Shakeel. It is
> firing because NR_SHMEM_PMDMAPPED and/or NR_FILE_PMDMAPPED are being
> updated using __lruvec_stat_mod_folio(), which also updates the memcg
> stats. However, these stats are not exported per-memcg.
>
> I think the following should fix it.
>

Hey Yosry, can you please post your patch with the signoff? The patch
looks good and you can put my ack on it.

> #syz test
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 12be4241474ab..d3a26ea4dbae2 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1441,7 +1441,7 @@ static __always_inline void __folio_add_file_rmap(struct folio *folio,
>
> nr = __folio_add_rmap(folio, page, nr_pages, level, &nr_pmdmapped);
> if (nr_pmdmapped)
> - __lruvec_stat_mod_folio(folio, folio_test_swapbacked(folio) ?
> + __mod_node_page_state(folio, folio_test_swapbacked(folio) ?
> NR_SHMEM_PMDMAPPED : NR_FILE_PMDMAPPED, nr_pmdmapped);
> if (nr)
> __lruvec_stat_mod_folio(folio, NR_FILE_MAPPED, nr);
>