Skip to contentSkip to conversation

mmap-rb-7 [was Re: /proc/<n>/maps growing...]

DISCUSSION Manfred Spraul 2 participants 2 messages Sep 3, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

+/*
+ * vma->vm_start/vm_end cannot change under us because the caller is

required

Quoted 1 line

+ * to hold the mmap_sem in write mode. We need to get the spinlock

only

Quoted 2 lines

+ * before relocating the vma range ourself.
+ */

There is one exception to that rule: a growable stack grows with mmap_sem only acquired in read mode. vm_start can change on platforms where the stack grows down, probably vm_end changes on platforms where the stack grows upwards.

Quoted 6 lines

- lock_vma_mappings(vma);
- spin_lock(&vma->vm_mm->page_table_lock); vma->vm_pgoff += (end - vma->vm_start) >> PAGE_SHIFT;
+ lock_vma_mappings(vma);
+ spin_lock(&mm->page_table_lock); vma->vm_start = end;

Could be wrong with concurrent stack faults.

--
Manfred

#1 lore raw
Quoted 10 lines · Manfred Spraul
Quoted 2 lines

+/*
+ * vma->vm_start/vm_end cannot change under us because the caller is

required

Quoted 1 line

+ * to hold the mmap_sem in write mode. We need to get the spinlock

only

Quoted 2 lines

+ * before relocating the vma range ourself.
+ */

There is one exception to that rule: a growable stack grows with mmap_sem only acquired in read mode. vm_start can change on platforms

expand_stack was broken. I fixed that, see the other patch posted to l-k today. growsup faults must grab the write semaphore too of course.

Quoted 8 lines
Quoted 6 lines

- lock_vma_mappings(vma);
- spin_lock(&vma->vm_mm->page_table_lock); vma->vm_pgoff += (end - vma->vm_start) >> PAGE_SHIFT;
+ lock_vma_mappings(vma);
+ spin_lock(&mm->page_table_lock); vma->vm_start = end;

Could be wrong with concurrent stack faults.

even if the growsdown faults would acquire only the read seamphore that change would still be obviously right because there (madvise) we hold the write semaphore, and even in the buggy 2.4.10pre4 the stack faults at least grab the read semaphore so they cannot race.

Andrea