]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Change gap calculations
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 2 Feb 2021 14:14:41 +0000 (09:14 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 2 Feb 2021 14:14:41 +0000 (09:14 -0500)
When calculating the gaps, make sure the alignment is okay.

This needs further analysis.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index 30c68d02aba92c5f978af9dc160883057effa5c4..d4b199d0db5b52eadf7f09455ee7e0c0c8b337a8 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1622,8 +1622,9 @@ static unsigned long unmapped_area(struct vm_unmapped_area_info *info)
                        rcu_read_unlock();
                        return -ENOMEM;
                }
-               gap = mas.index + gap_start_offset(info, mas.index);
-       } while (gap > mas.last + 1 - info->length);
+               gap = mas.index & ~(info->align_mask);
+               gap += info->align_offset;
+       } while ((gap < mas.index) && (gap > mas.last - info->length + 1));
        rcu_read_unlock();
 
        return gap;
@@ -1652,8 +1653,10 @@ static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
                        rcu_read_unlock();
                        return -ENOMEM;
                }
-               gap = mas.last + gap_end_offset(info, mas.last) -
-                       info->length + 1;
+
+               gap = mas.last - info->length + 1;
+               gap &= ~(info->align_mask);
+               gap += info->align_offset;
        } while (mas.index > gap);
        rcu_read_unlock();