|
Lines 728-741
Link Here
|
| 728 |
int err = -ENOMEM; |
728 |
int err = -ENOMEM; |
| 729 |
|
729 |
|
| 730 |
/* |
730 |
/* |
| 731 |
* vma->vm_start/vm_end cannot change under us because the caller is required |
731 |
* vma->vm_start/vm_end cannot change under us because the caller |
| 732 |
* to hold the mmap_sem in write mode. We need to get the spinlock only |
732 |
* is required to hold the mmap_sem in read mode. We need the |
| 733 |
* before relocating the vma range ourself. |
733 |
* page_table_lock lock to serialize against concurrent expand_stacks. |
| 734 |
*/ |
734 |
*/ |
| 735 |
address &= PAGE_MASK; |
735 |
address &= PAGE_MASK; |
| 736 |
if (prev_vma && prev_vma->vm_end + (heap_stack_gap << PAGE_SHIFT) > address) |
736 |
if (prev_vma && prev_vma->vm_end + (heap_stack_gap << PAGE_SHIFT) > address) |
| 737 |
goto out; |
737 |
goto out; |
| 738 |
spin_lock(&vma->vm_mm->page_table_lock); |
738 |
spin_lock(&vma->vm_mm->page_table_lock); |
|
|
739 |
|
| 740 |
/* already expanded while we were spinning? */ |
| 741 |
if (vma->vm_start <= address) { |
| 742 |
spin_unlock(&vma->vm_mm->page_table_lock); |
| 743 |
return 0; |
| 744 |
} |
| 745 |
|
| 739 |
grow = (vma->vm_start - address) >> PAGE_SHIFT; |
746 |
grow = (vma->vm_start - address) >> PAGE_SHIFT; |
| 740 |
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur || |
747 |
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur || |
| 741 |
((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) |
748 |
((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) |