|
Lines 647-658
Link Here
|
| 647 |
unsigned long grow; |
647 |
unsigned long grow; |
| 648 |
|
648 |
|
| 649 |
/* |
649 |
/* |
| 650 |
* vma->vm_start/vm_end cannot change under us because the caller is required |
650 |
* vma->vm_start/vm_end cannot change under us because the caller |
| 651 |
* to hold the mmap_sem in write mode. We need to get the spinlock only |
651 |
* is required to hold the mmap_sem in read mode. We need the |
| 652 |
* before relocating the vma range ourself. |
652 |
* page_table_lock lock to serialize against concurrent expand_stacks. |
| 653 |
*/ |
653 |
*/ |
| 654 |
address &= PAGE_MASK; |
654 |
address &= PAGE_MASK; |
| 655 |
spin_lock(&vma->vm_mm->page_table_lock); |
655 |
spin_lock(&vma->vm_mm->page_table_lock); |
|
|
656 |
|
| 657 |
/* already expanded while we were spinning? */ |
| 658 |
if ((vma->vm_flags & VM_GROWSDOWN) && vma->vm_start <= address) { |
| 659 |
spin_unlock(vma->vm_mm->page_table_lock); |
| 660 |
return 0; |
| 661 |
} else if ((vma->vm_flags & VM_GROWSUP) && vma->vm_start >= address) { |
| 662 |
spin_unlock(vma->vm_mm->page_table_lock); |
| 663 |
return 0; |
| 664 |
} |
| 665 |
|
| 656 |
grow = (vma->vm_start - address) >> PAGE_SHIFT; |
666 |
grow = (vma->vm_start - address) >> PAGE_SHIFT; |
| 657 |
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur || |
667 |
if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur || |
| 658 |
((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) { |
668 |
((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) { |