Commit 066fed59 authored by Uladzislau Rezki (Sony)'s avatar Uladzislau Rezki (Sony) Committed by Linus Torvalds

mm/vmalloc: check various alignments when debugging

Before we did not guarantee a free block with lowest start address for
allocations with alignment >= PAGE_SIZE.  Because an alignment overhead
was included into a search length like below:

     length = size + align - 1;

doing so we make sure that a bigger block would fit after applying an
alignment adjustment.  Now there is no such limitation, i.e.  any
alignment that user wants to apply will result to a lowest address of
returned free area.

Link: https://lkml.kernel.org/r/20211004142829.22222-2-urezki@gmail.comSigned-off-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Ping Fang <pifang@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9f531973
...@@ -1269,7 +1269,7 @@ find_vmap_lowest_linear_match(unsigned long size, ...@@ -1269,7 +1269,7 @@ find_vmap_lowest_linear_match(unsigned long size,
} }
static void static void
find_vmap_lowest_match_check(unsigned long size) find_vmap_lowest_match_check(unsigned long size, unsigned long align)
{ {
struct vmap_area *va_1, *va_2; struct vmap_area *va_1, *va_2;
unsigned long vstart; unsigned long vstart;
...@@ -1278,8 +1278,8 @@ find_vmap_lowest_match_check(unsigned long size) ...@@ -1278,8 +1278,8 @@ find_vmap_lowest_match_check(unsigned long size)
get_random_bytes(&rnd, sizeof(rnd)); get_random_bytes(&rnd, sizeof(rnd));
vstart = VMALLOC_START + rnd; vstart = VMALLOC_START + rnd;
va_1 = find_vmap_lowest_match(size, 1, vstart); va_1 = find_vmap_lowest_match(size, align, vstart);
va_2 = find_vmap_lowest_linear_match(size, 1, vstart); va_2 = find_vmap_lowest_linear_match(size, align, vstart);
if (va_1 != va_2) if (va_1 != va_2)
pr_emerg("not lowest: t: 0x%p, l: 0x%p, v: 0x%lx\n", pr_emerg("not lowest: t: 0x%p, l: 0x%p, v: 0x%lx\n",
...@@ -1458,7 +1458,7 @@ __alloc_vmap_area(unsigned long size, unsigned long align, ...@@ -1458,7 +1458,7 @@ __alloc_vmap_area(unsigned long size, unsigned long align,
return vend; return vend;
#if DEBUG_AUGMENT_LOWEST_MATCH_CHECK #if DEBUG_AUGMENT_LOWEST_MATCH_CHECK
find_vmap_lowest_match_check(size); find_vmap_lowest_match_check(size, align);
#endif #endif
return nva_start_addr; return nva_start_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment