Re: [PATCH v3 4/4] mm/vmap: move BUG_ON() check to the unlink_va()

From: Steven Rostedt
Date: Mon May 27 2019 - 09:02:46 EST


On Mon, 27 May 2019 11:38:42 +0200
"Uladzislau Rezki (Sony)" <urezki@xxxxxxxxx> wrote:

> Move the BUG_ON()/RB_EMPTY_NODE() check under unlink_va()
> function, it means if an empty node gets freed it is a BUG
> thus is considered as faulty behaviour.

Can we switch it to a WARN_ON(). We are trying to remove all BUG_ON()s.
If a user wants to crash on warning, there's a sysctl for that. But
crashing the system can make it hard to debug. Especially if it is hit
by someone without a serial console, and the machine just hangs in X.
That is very annoying.

With a WARN_ON, you at least get a chance to see the crash dump.

-- Steve


>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
> ---
> mm/vmalloc.c | 24 +++++++++---------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 371aba9a4bf1..340959b81228 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -533,20 +533,16 @@ link_va(struct vmap_area *va, struct rb_root *root,
> static __always_inline void
> unlink_va(struct vmap_area *va, struct rb_root *root)
> {
> - /*
> - * During merging a VA node can be empty, therefore
> - * not linked with the tree nor list. Just check it.
> - */
> - if (!RB_EMPTY_NODE(&va->rb_node)) {
> - if (root == &free_vmap_area_root)
> - rb_erase_augmented(&va->rb_node,
> - root, &free_vmap_area_rb_augment_cb);
> - else
> - rb_erase(&va->rb_node, root);
> + BUG_ON(RB_EMPTY_NODE(&va->rb_node));
>
> - list_del(&va->list);
> - RB_CLEAR_NODE(&va->rb_node);
> - }
> + if (root == &free_vmap_area_root)
> + rb_erase_augmented(&va->rb_node,
> + root, &free_vmap_area_rb_augment_cb);
> + else
> + rb_erase(&va->rb_node, root);
> +
> + list_del(&va->list);
> + RB_CLEAR_NODE(&va->rb_node);
> }
>
> #if DEBUG_AUGMENT_PROPAGATE_CHECK
> @@ -1187,8 +1183,6 @@ EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier);
>
> static void __free_vmap_area(struct vmap_area *va)
> {
> - BUG_ON(RB_EMPTY_NODE(&va->rb_node));
> -
> /*
> * Remove from the busy tree/list.
> */