Re: pte locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Le Wed, 29 Aug 2007 11:10:37 +0200,
Johannes Schmid <johnny@xxxxxxxx> a écrit :

> spin_lock(&task->mm->page_table_lock);
> 
> 	pte = pte_offset_map_lock(task->mm, pmd, addr, &ptl);
> 
> spin_unlock(&task->mm->page_table_lock);		

pte_offset_map_lock() does:

932 #define pte_offset_map_lock(mm, pmd, address, ptlp)     \
933 ({                                                      \
934         spinlock_t *__ptl = pte_lockptr(mm, pmd);       \
935         pte_t *__pte = pte_offset_map(pmd, address);    \
936         *(ptlp) = __ptl;                                \
937         spin_lock(__ptl);                               \
938         __pte;                                          \
939 })

So it takes the lock returned by pte_lockptr, which is defined as
follows:

929 #define pte_lockptr(mm, pmd)    ({(void)(pmd);
                                     &(mm)->page_table_lock;})

Which takes the page_table_lock you've already taken previously.

So I'd say that whenever you reach your call to pte_offset_map_lock(),
your kernel will deadlock.

Looking more closely at the code, you can see that there are cases
where pte_offset_map_lock() doesn't take the mm->page_table_lock, but
page->ptl. It's when you have NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS. See
http://users.sosdg.org/~qiyong/lxr/source/include/linux/mm.h#L910.
However, CONFIG_SPLIT_PTLOCK_CPUS is defined as follows:

config SPLIT_PTLOCK_CPUS
        int
        default "4096" if ARM && !CPU_CACHE_VIPT
        default "4096" if PARISC && !PA20
        default "4"

So on i386, it defaults to 4. So unless you have more than 4
processors, pte_offset_map_lock() takes mm->page_table_lock.

Sincerly,

Thomas
-- 
Thomas Petazzoni - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux