Re: [PATCH] mm/vmalloc: Remove WARN_ON_ONCE related to adjust_va_to_fit_type

From: Jaeseon Sim
Date: Mon Sep 25 2023 - 06:52:05 EST


> On 09/22/23 at 05:34pm, Baoquan He wrote:
> > Hi Jaeseon,
Hello Baoquan,
> >
> > On 09/22/23 at 03:27pm, Jaeseon Sim wrote:
> > > There's panic issue as follows when do alloc_vmap_area:
> > >
> > > Kernel panic - not syncing: kernel: panic_on_warn set ...
> > >
> > > page allocation failure: order:0, mode:0x800(GFP_NOWAIT)
> > > Call Trace:
> > > warn_alloc+0xf4/0x190
> > > __alloc_pages_slowpath+0xe0c/0xffc
> > > __alloc_pages+0x250/0x2d0
> > > new_slab+0x17c/0x4e0
> > > ___slab_alloc+0x4e4/0x8a8
> > > __slab_alloc+0x34/0x6c
> > > kmem_cache_alloc+0x20c/0x2f0
> > > adjust_va_to_fit_type
> > > __alloc_vmap_area
> > > alloc_vmap_area+0x298/0x7fc
> > > __get_vm_area_node+0x10c/0x1b4
> > > __vmalloc_node_range+0x19c/0x7c0

To Uladzislau,
Sorry. The path is as below.

Call trace:
alloc_vmap_area+0x298/0x7fc
__get_vm_area_node+0x10c/0x1b4
__vmalloc_node_range+0x19c/0x7c0
dup_task_struct+0x1b8/0x3b0
copy_process+0x170/0xc40

> > >
> > > Commit 1b23ff80b399 ("mm/vmalloc: invoke classify_va_fit_type() in
> > > adjust_va_to_fit_type()") moved classify_va_fit_type() into
> > > adjust_va_to_fit_type() and used WARN_ON_ONCE() to handle return
> > > value of adjust_va_to_fit_type(), just as classify_va_fit_type()
> > > was handled.
> >
> > I don't get what you are fixing. In commit 1b23ff80b399, we have
> ~~ s/In/Before/, typo
> > "if (WARN_ON_ONCE(type == NOTHING_FIT))", it's the same as the current
> > code. You set panic_on_warn, it will panic in old code before commit
> > 1b23ff80b399. Isn't it an expected behaviour?
There is a call path which didn't panic in old code, but does on the current.

static __always_inline int adjust_va_to_fit_type()

} else if (type == NE_FIT_TYPE) {
lva = kmem_cache_alloc(vmap_area_cachep, GFP_NOWAIT);
if (!lva)
return -1;

If the above path is taken, Retry path should be triggred at alloc_vmap_area().
But it is currenly unable to so.

> >
> > >
> > > There is another path in adjust_va_to_fit_type() which could
> > > return failure and will be handled in alloc_vmap_area().
> > > Remove WARN_ON_ONCE() for this case.
> > >
> > > Fixes: 45c62fc2897d ("mm/vmalloc: Remove WARN_ON_ONCE related to adjust_va_to_fit_type")
> >
> > The commit id for Fixes tag is wrong.
> >
> > > Signed-off-by: Jaeseon Sim <jason.sim@xxxxxxxxxxx>
> > > ---
> > > mm/vmalloc.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > > index ef8599d394fd..4a82b6525d48 100644
> > > --- a/mm/vmalloc.c
> > > +++ b/mm/vmalloc.c
> > > @@ -1522,7 +1522,7 @@ __alloc_vmap_area(struct rb_root *root, struct list_head *head,
> > >
> > > /* Update the free vmap_area. */
> > > ret = adjust_va_to_fit_type(root, head, va, nva_start_addr, size);
> > > - if (WARN_ON_ONCE(ret))
> > > + if (ret)
> > > return vend;
> > >
> > > #if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
> > > @@ -4143,7 +4143,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
> > > ret = adjust_va_to_fit_type(&free_vmap_area_root,
> > > &free_vmap_area_list,
> > > va, start, size);
> > > - if (WARN_ON_ONCE(unlikely(ret)))
> > > + if (unlikely(ret))
> > > /* It is a BUG(), but trigger recovery instead. */
> > > goto recovery;
> > >
> > > --
> > > 2.17.1
> > >
> >
>