Re: global kernel lock

Linus Torvalds (torvalds@transmeta.com)
Fri, 13 Nov 1998 12:33:18 -0800 (PST)


On 13 Nov 1998, Andi Kleen wrote:
>
> mm/memory.c:
>
> static int do_no_page ...
> {
> if (!vma->vm_ops || !vma->vm_ops->nopage) {
> unlock_kernel();
> return do_anonymous_page(tsk, vma, page_table, write_access);
> }
>
>
>
> static inline int handle_pte_fault ...
> {
> lock_kernel();
> entry = *pte;
>
> if (!pte_present(entry)) {
> if (pte_none(entry))
> return do_no_page(tsk, vma, address, write_access, pte);
>
> The mm semaphore should serialize access to the pte already so the
> lock_kernel should not be needed in this common case. Or do I miss something
> here?

Yes. You missed kswapd and synchronous processes trying to make more
memory available, walking and modifying page tables behind your back
unless you hold the kernel lock.

That's why we can unlock early in the (very common) case of doing an new
anonymous page: nobody is going to _add_ entries to the page tables
without holding the mm semaphore, and the anonymous page case doesn't need
the kernel lock for anything else either.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/