mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-09-21 20:22:13 +08:00
xtensa: remove vma linked list walks
Use the VMA iterator instead. Since VMA can no longer be NULL in the loop, then deal with out-of-memory outside the loop. This means a slightly longer run time in the failure case (-ENOMEM) - it will run to the end of the VMAs before erroring instead of in the middle of the loop. Link: https://lkml.kernel.org/r/20220906194824.2110408-37-Liam.Howlett@oracle.com Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Tested-by: Yu Zhao <yuzhao@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: SeongJae Park <sj@kernel.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
a388462116
commit
49c40fb4b8
@ -58,6 +58,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|||||||
unsigned long len, unsigned long pgoff, unsigned long flags)
|
unsigned long len, unsigned long pgoff, unsigned long flags)
|
||||||
{
|
{
|
||||||
struct vm_area_struct *vmm;
|
struct vm_area_struct *vmm;
|
||||||
|
struct vma_iterator vmi;
|
||||||
|
|
||||||
if (flags & MAP_FIXED) {
|
if (flags & MAP_FIXED) {
|
||||||
/* We do not accept a shared mapping if it would violate
|
/* We do not accept a shared mapping if it would violate
|
||||||
@ -79,15 +80,20 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|||||||
else
|
else
|
||||||
addr = PAGE_ALIGN(addr);
|
addr = PAGE_ALIGN(addr);
|
||||||
|
|
||||||
for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
|
vma_iter_init(&vmi, current->mm, addr);
|
||||||
/* At this point: (!vmm || addr < vmm->vm_end). */
|
for_each_vma(vmi, vmm) {
|
||||||
if (TASK_SIZE - len < addr)
|
/* At this point: (addr < vmm->vm_end). */
|
||||||
return -ENOMEM;
|
if (addr + len <= vm_start_gap(vmm))
|
||||||
if (!vmm || addr + len <= vm_start_gap(vmm))
|
break;
|
||||||
return addr;
|
|
||||||
addr = vmm->vm_end;
|
addr = vmm->vm_end;
|
||||||
if (flags & MAP_SHARED)
|
if (flags & MAP_SHARED)
|
||||||
addr = COLOUR_ALIGN(addr, pgoff);
|
addr = COLOUR_ALIGN(addr, pgoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TASK_SIZE - len < addr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
return addr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user