Re: [PATCH 1/1] mm: vmalloc: Bail out early in find_vmap_area() if vmap is not init

From: Heiko Carstens
Date: Mon Mar 25 2024 - 10:01:36 EST


On Sun, Mar 24, 2024 at 04:32:00PM -0700, Christoph Hellwig wrote:
> On Sat, Mar 23, 2024 at 03:15:44PM +0100, Uladzislau Rezki (Sony) wrote:
> > During the boot the s390 system triggers "spinlock bad magic" messages
> > if the spinlock debugging is enabled:
> >
> > [ 0.465445] BUG: spinlock bad magic on CPU#0, swapper/0
> > [ 0.465490] lock: single+0x1860/0x1958, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
> > [ 0.466067] CPU: 0 PID: 0 Comm: swapper Not tainted 6.8.0-12955-g8e938e398669 #1
> > [ 0.466188] Hardware name: QEMU 8561 QEMU (KVM/Linux)
> > [ 0.466270] Call Trace:
> > [ 0.466470] [<00000000011f26c8>] dump_stack_lvl+0x98/0xd8
> > [ 0.466516] [<00000000001dcc6a>] do_raw_spin_lock+0x8a/0x108
> > [ 0.466545] [<000000000042146c>] find_vmap_area+0x6c/0x108
> > [ 0.466572] [<000000000042175a>] find_vm_area+0x22/0x40
> > [ 0.466597] [<000000000012f152>] __set_memory+0x132/0x150
> > [ 0.466624] [<0000000001cc0398>] vmem_map_init+0x40/0x118
> > [ 0.466651] [<0000000001cc0092>] paging_init+0x22/0x68
> > [ 0.466677] [<0000000001cbbed2>] setup_arch+0x52a/0x708
> > [ 0.466702] [<0000000001cb6140>] start_kernel+0x80/0x5c8
> > [ 0.466727] [<0000000000100036>] startup_continue+0x36/0x40
..
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index 22aa63f4ef63..0d77d171b5d9 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -2343,6 +2343,9 @@ struct vmap_area *find_vmap_area(unsigned long addr)
> > struct vmap_area *va;
> > int i, j;
> >
> > + if (unlikely(!vmap_initialized))
> > + return NULL;
> > +
>
> I guess this is ok as an urgend bandaid to get s390 booting again,
> but calling find_vmap_area before the vmap area is initialized
> seems an actual issue in the s390 mm init code.
>
> Adding the s390 maintainers to see if they have and idea how this could
> get fixed in a better way.

I'm going to push the patch below to the s390 git tree later. This is not a
piece of art, but I wanted to avoid to externalize vmalloc's vmap_initialized,
or come up with some s390 specific change_page_attr_alias_early() variant where
sooner or later nobody remembers what "early" means.

So this seems to be "good enough".