Re: [linux-next:master] [mm] bbcbf2a3f0: kernel_BUG_at_mm/memory.c

From: Oliver Sang
Date: Fri Dec 22 2023 - 03:14:06 EST


hi, David,

On Thu, Dec 21, 2023 at 11:07:21PM +0100, David Hildenbrand wrote:
> On 21.12.23 22:58, Andrew Morton wrote:
> > On Thu, 21 Dec 2023 12:32:04 +0100 David Hildenbrand <david@xxxxxxxxxx> wrote:
> >
> > > On 21.12.23 12:23, Oliver Sang wrote:
> > > > hi, Andrew Morton,
> > > >
> > > > On Wed, Dec 20, 2023 at 02:11:35PM -0800, Andrew Morton wrote:
> > > > > On Tue, 19 Dec 2023 23:46:50 +0800 kernel test robot <oliver.sang@xxxxxxxxx> wrote:
> > > > >
> > > > > >
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > kernel test robot noticed "kernel_BUG_at_mm/memory.c" on:
> > > > > >
> > > > > > commit: bbcbf2a3f05f74f9d268eab57abbdce6a65a94ad ("mm: convert ksm_might_need_to_copy() to work on folios")
> > > > >
> > > > > I assume this is a bisection result, so it's quite repeatable?
> > > >
> > > > yes, we bisect to this commit, it's quite repeatable:
> > > >
> > > > ddd06bb63d9793ce bbcbf2a3f05f74f9d268eab57ab
> > > > ---------------- ---------------------------
> > > > fail:runs %reproduction fail:runs
> > > > | | |
> > > > :6 100% 6:6 dmesg.Kernel_panic-not_syncing:Fatal_exception
> > > > :6 100% 6:6 dmesg.RIP:do_swap_page
> > > > :6 100% 6:6 dmesg.invalid_opcode:#[##]
> > > > :6 100% 6:6 dmesg.kernel_BUG_at_mm/memory.c
> > > >
> > > >
> > >
> > > Can you try with the snipped I sent? Please let me know if you need a
> > > full patch for testing purposes.
> >
> > I think a full patch would be better, please.
> >

we cannot reproduce the issue reported previously after applying below patch.
Thanks

>
> From b82e309096abde6c0f24bba50a281e8d3855c132 Mon Sep 17 00:00:00 2001
> From: David Hildenbrand <david@xxxxxxxxxx>
> Date: Thu, 21 Dec 2023 23:04:30 +0100
> Subject: [PATCH] Fixup: mm: convert ksm_might_need_to_copy() to work on folios
>
> We must only adjust the page if the folio changed. Otherwise, if we
> had a large folio in the swapcache and the folio didn't change, we'd
> suddenly change the page to-be-mapped.
>
> Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-lkp/202312192319.fa8f5709-oliver.sang@xxxxxxxxx
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
> ---
> mm/memory.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 149f779910fd5..2f9668d357f5c 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3952,7 +3952,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> folio = swapcache;
> goto out_page;
> }
> - page = folio_page(folio, 0);
> + if (folio != swapcache)
> + page = folio_page(folio, 0);
> /*
> * If we want to map a page that's in the swapcache writable, we
> --
> 2.43.0
>
>
> --
> Cheers,
>
> David / dhildenb
>