The patch titled Subject: mm/vmap: add DEBUG_AUGMENT_PROPAGATE_CHECK macro has been added to the -mm tree. Its filename is mm-vmap-add-debug_augment_propagate_check-macro.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-vmap-add-debug_augment_propagate_check-macro.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-vmap-add-debug_augment_propagate_check-macro.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Uladzislau Rezki (Sony)" <urezki@xxxxxxxxx> Subject: mm/vmap: add DEBUG_AUGMENT_PROPAGATE_CHECK macro This macro adds some debug code to check that the augment tree is maintained correctly, meaning that every node contains valid subtree_max_size value. By default this option is set to 0 and not active. It requires recompilation of the kernel to activate it. Set to 1, compile the kernel. Link: http://lkml.kernel.org/r/20190402162531.10888-3-urezki@xxxxxxxxx Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Joel Fernandes <joelaf@xxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Oleksiy Avramchenko <oleksiy.avramchenko@xxxxxxxxxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: Thomas Garnier <thgarnie@xxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmalloc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) --- a/mm/vmalloc.c~mm-vmap-add-debug_augment_propagate_check-macro +++ a/mm/vmalloc.c @@ -322,6 +322,8 @@ unsigned long vmalloc_to_pfn(const void EXPORT_SYMBOL(vmalloc_to_pfn); /*** Global kva allocator ***/ +#define DEBUG_AUGMENT_PROPAGATE_CHECK 0 + #define VM_LAZY_FREE 0x02 #define VM_VM_AREA 0x04 @@ -544,6 +546,53 @@ __unlink_va(struct vmap_area *va, struct } } +#if DEBUG_AUGMENT_PROPAGATE_CHECK +static void +augment_tree_propagate_do_check(struct rb_node *n) +{ + struct vmap_area *va; + struct rb_node *node; + unsigned long size; + bool found = false; + + if (n == NULL) + return; + + va = rb_entry(n, struct vmap_area, rb_node); + size = va->subtree_max_size; + node = n; + + while (node) { + va = rb_entry(node, struct vmap_area, rb_node); + + if (get_subtree_max_size(node->rb_left) == size) { + node = node->rb_left; + } else { + if (__va_size(va) == size) { + found = true; + break; + } + + node = node->rb_right; + } + } + + if (!found) { + va = rb_entry(n, struct vmap_area, rb_node); + pr_emerg("tree is corrupted: %lu, %lu\n", + __va_size(va), va->subtree_max_size); + } + + augment_tree_propagate_do_check(n->rb_left); + augment_tree_propagate_do_check(n->rb_right); +} + +static void augment_tree_propagate_from_check(void) +{ + augment_tree_propagate_do_check(free_vmap_area_root.rb_node); +} +#endif + /* * This function populates subtree_max_size from bottom to upper * levels starting from VA point. The propagation must be done @@ -593,6 +642,10 @@ __augment_tree_propagate_from(struct vma va->subtree_max_size = new_va_sub_max_size; node = rb_parent(&va->rb_node); } + +#if DEBUG_AUGMENT_PROPAGATE_CHECK + augment_tree_propagate_from_check(); +#endif } static void _ Patches currently in -mm which might be from urezki@xxxxxxxxx are mm-add-priority-threshold-to-__purge_vmap_area_lazy.patch mm-vmap-keep-track-of-free-blocks-for-vmap-allocation.patch mm-vmap-keep-track-of-free-blocks-for-vmap-allocation-v3.patch mm-vmap-add-debug_augment_propagate_check-macro.patch mm-vmap-add-debug_augment_lowest_match_check-macro.patch mm-vmalloc-convert-vmap_lazy_nr-to-atomic_long_t.patch