changing mm->mmap_sem (was: Re: system call for process information?)
Subsystems (3)
Quoted 4 lines
The problem is that
mmap_semseems to be protecting the list of VMAs, so taking _only_ thepage_table_lockcould let a VMA change under us while a page fault is underway ...
No, that can't happen.
VMA changes only happen if both the mmap_sem and the page table lock is acquired. (check insert_vm() at the end of mm/mmap.c)
The page fault path uses the map_sem, kswaps uses page_table_lock.
<< from your patch:
mm/vmscan.c renamed from mm/vmscan.c.orig +1 -0
@@ -231,6 +231,7 @@* Find the proper vm-area after freezing the vma chain * and ptes. */ +down_read (&mm->mmap_sem);spin_lock (&mm->page_table_lock); >>>>
Why do you acquire the mmap semaphore in swapout_mm()? The old rule was that kswapd should never sleep on the mmap semaphore. Isn't there a deadlock if mmap sem is already acquired? I don't remember the details.
Quoted 4 lines
The problem is that
mmap_semseems to be protecting the list of VMAs, so taking _only_ thepage_table_lockcould let a VMA change under us while a page fault is underway ...
I remember that the pmd_alloc() and pte_alloc() functions need additional locking.
--
Manfred
Quoted 8 lines · Manfred Spraul
Quoted 3 lines
The problem is that
mmap_semseems to be protecting the list of VMAs, so taking _only_ thepage_table_lockcould let a VMA change under us while a page fault is underway ...No, that can't happen.
VMA changes only happen if both themmap_semand the page table lock is acquired. (checkinsert_vm()at the end ofmm/mmap.c)
The page fault path uses themap_sem, kswaps usespage_table_lock.
You're right here, I missed this "little detail"...
Quoted 11 lines
<< from your patch:
mm/vmscan.c renamed from mm/vmscan.c.orig +1
-0@@ -231,6 +231,7 @@* Find the proper vm-area after freezing the vma chain * and ptes. */ +down_read (&mm->mmap_sem);spin_lock (&mm->page_table_lock); >>>>
Quoted 3 lines
Why do you acquire the mmap semaphore in
swapout_mm()? The old rule was that kswapd should never sleep on the mmap semaphore. Isn't there a deadlock if mmap sem is already acquired? I don't remember the details.
You're right, kswapd shouldn't do this. I have this removed from my code right now...
Quoted 6 lines
Quoted 3 lines
The problem is that
mmap_semseems to be protecting the list of VMAs, so taking _only_ thepage_table_lockcould let a VMA change under us while a page fault is underway ...I remember that the
pmd_alloc()andpte_alloc()functions need additional locking.
Isn't this what the page_table_lock is for ?
(too bad they're not using it...)
regards,
Rik
--
Virtual memory is like a game you can't win; However, without VM there's truly nothing to lose...
http://www.surriel.com/
Hi,
Quoted 5 lines · Manfred Spraul
Quoted 3 lines
The problem is that
mmap_semseems to be protecting the list of VMAs, so taking _only_ thepage_table_lockcould let a VMA change under us while a page fault is underway ...No, that can't happen.
It can. Page faults often need to block, so they have to be able to drop the page_table_lock. Holding the mmap_sem is all that keeps the vma intact until the IO is complete.
Cheers,
Stephen