Timur Tabi <timur.tabi@ammasso.com> writes: ... > with a spinlock? That is, should I change the above to: > > spin_lock(¤t->mm->page_table_lock); > pgd_t *pgd = pgd_offset(current->mm, address); > pmd_t *pmd = pmd_offset(pgd, address); > pte_t *pte = pte_offset_map(pmd, address); > pte_t _pte = *pte; > pte_unmap(pte); > spin_unlock(¤t->mm->page_table_lock); The normal order of lock acquisition is first to get the mmap semaphore (at which point you may sleep) and then to get the page table lock. A good reference for the proceedure you're implementing is follow_page in mm/memory.c. Note that it's called with the page_table_lock held. > I'm guessing I only need to call a spinlock if the page isn't locked > in memory. Is that correct? No, the page table lock allows you to see a consistent view of the page tables while you hold it. -- Ed L Cashin <ecashin@coraid.com> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/