From mboxrd@z Thu Jan 1 00:00:00 1970 From: riel@surriel.com (Rik van Riel) Date: Thu, 31 Mar 2011 11:14:50 -0400 Subject: [virtual memory] page_table_lock & mmap_sem In-Reply-To: References: Message-ID: <4D949A6A.5040803@surriel.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On 03/29/2011 06:30 PM, Venkatram Tummala wrote: > Hi, > > Why do we need both page_table_lock & mmap_sem in the kernel. Why isn't > mmap_sem good enough for serialization. As far as i see it, all attempts > to change the page table hierarchy in the kernel is done after holding > the write lock on mmap_sem. As we are already holding the write lock, we > do we need an extra page_table_lock (spinlock) ? Are there any code > paths in the kernel which attempt to modify the page table hierarchy > without holding the write lock on mmap_sem ? Yes, there are. Look at the page fault code, which takes a read lock on mmap_sem. This allows multiple threads in a multi-threaded process to handle page faults simultaneously. -- All rights reversed.