diff options
| author | Uladzislau Rezki (Sony) <urezki@gmail.com> | 2019-05-17 17:31:34 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-18 18:52:26 -0400 |
| commit | bb850f4dae4abb18c5ee727bb2d6df9ca47ede49 (patch) | |
| tree | eb7f503bd8ff66de51cb5df02c9040724a8ef04a | |
| parent | 68ad4a3304335358f95a417f2a2b0c909e5119c4 (diff) | |
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.
[urezki@gmail.com: v4]
Link: http://lkml.kernel.org/r/20190406183508.25273-3-urezki@gmail.com
Link: http://lkml.kernel.org/r/20190402162531.10888-3-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | mm/vmalloc.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index f8f61ff3235b..aac34c2a410b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
| @@ -325,6 +325,8 @@ EXPORT_SYMBOL(vmalloc_to_pfn); | |||
| 325 | 325 | ||
| 326 | /*** Global kva allocator ***/ | 326 | /*** Global kva allocator ***/ |
| 327 | 327 | ||
| 328 | #define DEBUG_AUGMENT_PROPAGATE_CHECK 0 | ||
| 329 | |||
| 328 | #define VM_LAZY_FREE 0x02 | 330 | #define VM_LAZY_FREE 0x02 |
| 329 | #define VM_VM_AREA 0x04 | 331 | #define VM_VM_AREA 0x04 |
| 330 | 332 | ||
| @@ -539,6 +541,48 @@ unlink_va(struct vmap_area *va, struct rb_root *root) | |||
| 539 | } | 541 | } |
| 540 | } | 542 | } |
| 541 | 543 | ||
| 544 | #if DEBUG_AUGMENT_PROPAGATE_CHECK | ||
| 545 | static void | ||
| 546 | augment_tree_propagate_check(struct rb_node *n) | ||
| 547 | { | ||
| 548 | struct vmap_area *va; | ||
| 549 | struct rb_node *node; | ||
| 550 | unsigned long size; | ||
| 551 | bool found = false; | ||
| 552 | |||
| 553 | if (n == NULL) | ||
| 554 | return; | ||
| 555 | |||
| 556 | va = rb_entry(n, struct vmap_area, rb_node); | ||
| 557 | size = va->subtree_max_size; | ||
| 558 | node = n; | ||
| 559 | |||
| 560 | while (node) { | ||
| 561 | va = rb_entry(node, struct vmap_area, rb_node); | ||
| 562 | |||
| 563 | if (get_subtree_max_size(node->rb_left) == size) { | ||
| 564 | node = node->rb_left; | ||
| 565 | } else { | ||
| 566 | if (va_size(va) == size) { | ||
| 567 | found = true; | ||
| 568 | break; | ||
| 569 | } | ||
| 570 | |||
| 571 | node = node->rb_right; | ||
| 572 | } | ||
| 573 | } | ||
| 574 | |||
| 575 | if (!found) { | ||
| 576 | va = rb_entry(n, struct vmap_area, rb_node); | ||
| 577 | pr_emerg("tree is corrupted: %lu, %lu\n", | ||
| 578 | va_size(va), va->subtree_max_size); | ||
| 579 | } | ||
| 580 | |||
| 581 | augment_tree_propagate_check(n->rb_left); | ||
| 582 | augment_tree_propagate_check(n->rb_right); | ||
| 583 | } | ||
| 584 | #endif | ||
| 585 | |||
| 542 | /* | 586 | /* |
| 543 | * This function populates subtree_max_size from bottom to upper | 587 | * This function populates subtree_max_size from bottom to upper |
| 544 | * levels starting from VA point. The propagation must be done | 588 | * levels starting from VA point. The propagation must be done |
| @@ -588,6 +632,10 @@ augment_tree_propagate_from(struct vmap_area *va) | |||
| 588 | va->subtree_max_size = new_va_sub_max_size; | 632 | va->subtree_max_size = new_va_sub_max_size; |
| 589 | node = rb_parent(&va->rb_node); | 633 | node = rb_parent(&va->rb_node); |
| 590 | } | 634 | } |
| 635 | |||
| 636 | #if DEBUG_AUGMENT_PROPAGATE_CHECK | ||
| 637 | augment_tree_propagate_check(free_vmap_area_root.rb_node); | ||
| 638 | #endif | ||
| 591 | } | 639 | } |
| 592 | 640 | ||
| 593 | static void | 641 | static void |
