aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/vmalloc.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index aac34c2a410b..c42872ed82ac 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -326,6 +326,7 @@ EXPORT_SYMBOL(vmalloc_to_pfn);
326/*** Global kva allocator ***/ 326/*** Global kva allocator ***/
327 327
328#define DEBUG_AUGMENT_PROPAGATE_CHECK 0 328#define DEBUG_AUGMENT_PROPAGATE_CHECK 0
329#define DEBUG_AUGMENT_LOWEST_MATCH_CHECK 0
329 330
330#define VM_LAZY_FREE 0x02 331#define VM_LAZY_FREE 0x02
331#define VM_VM_AREA 0x04 332#define VM_VM_AREA 0x04
@@ -834,6 +835,44 @@ find_vmap_lowest_match(unsigned long size,
834 return NULL; 835 return NULL;
835} 836}
836 837
838#if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
839#include <linux/random.h>
840
841static struct vmap_area *
842find_vmap_lowest_linear_match(unsigned long size,
843 unsigned long align, unsigned long vstart)
844{
845 struct vmap_area *va;
846
847 list_for_each_entry(va, &free_vmap_area_list, list) {
848 if (!is_within_this_va(va, size, align, vstart))
849 continue;
850
851 return va;
852 }
853
854 return NULL;
855}
856
857static void
858find_vmap_lowest_match_check(unsigned long size)
859{
860 struct vmap_area *va_1, *va_2;
861 unsigned long vstart;
862 unsigned int rnd;
863
864 get_random_bytes(&rnd, sizeof(rnd));
865 vstart = VMALLOC_START + rnd;
866
867 va_1 = find_vmap_lowest_match(size, 1, vstart);
868 va_2 = find_vmap_lowest_linear_match(size, 1, vstart);
869
870 if (va_1 != va_2)
871 pr_emerg("not lowest: t: 0x%p, l: 0x%p, v: 0x%lx\n",
872 va_1, va_2, vstart);
873}
874#endif
875
837enum fit_type { 876enum fit_type {
838 NOTHING_FIT = 0, 877 NOTHING_FIT = 0,
839 FL_FIT_TYPE = 1, /* full fit */ 878 FL_FIT_TYPE = 1, /* full fit */
@@ -976,6 +1015,10 @@ __alloc_vmap_area(unsigned long size, unsigned long align,
976 if (ret) 1015 if (ret)
977 return vend; 1016 return vend;
978 1017
1018#if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
1019 find_vmap_lowest_match_check(size);
1020#endif
1021
979 return nva_start_addr; 1022 return nva_start_addr;
980} 1023}
981 1024