@@ -326,6 +326,7 @@ EXPORT_SYMBOL(vmalloc_to_pfn);
326
326
/*** Global kva allocator ***/
327
327
328
328
#define DEBUG_AUGMENT_PROPAGATE_CHECK 0
329
+ #define DEBUG_AUGMENT_LOWEST_MATCH_CHECK 0
329
330
330
331
#define VM_LAZY_FREE 0x02
331
332
#define VM_VM_AREA 0x04
@@ -834,6 +835,44 @@ find_vmap_lowest_match(unsigned long size,
834
835
return NULL ;
835
836
}
836
837
838
+ #if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
839
+ #include <linux/random.h>
840
+
841
+ static struct vmap_area *
842
+ find_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
+
857
+ static void
858
+ find_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
+
837
876
enum fit_type {
838
877
NOTHING_FIT = 0 ,
839
878
FL_FIT_TYPE = 1 , /* full fit */
@@ -976,6 +1015,10 @@ __alloc_vmap_area(unsigned long size, unsigned long align,
976
1015
if (ret )
977
1016
return vend ;
978
1017
1018
+ #if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
1019
+ find_vmap_lowest_match_check (size );
1020
+ #endif
1021
+
979
1022
return nva_start_addr ;
980
1023
}
981
1024
0 commit comments