Re: 4level page tables for Linux II

From: Andi Kleen
Date: Tue Oct 12 2004 - 14:19:56 EST


On Tue, Oct 12, 2004 at 09:03:46PM +0200, Andi Kleen wrote:
> On Tue, Oct 12, 2004 at 11:48:22AM -0700, Dave Hansen wrote:
> > @@ -110,13 +115,18 @@ int install_file_pte(struct mm_struct *m
> > unsigned long addr, unsigned long pgoff, pgprot_t prot)
> > {
> > ...
> > + pml4 = pml4_offset(mm, addr);
> > +
> > + spin_lock(&mm->page_table_lock);
> > + pgd = pgd_alloc(mm, pml4, addr);
> > + if (!pgd)
> > + goto err_unlock;
> >
> > Locking isn't needed for access to the pml4? This is a wee bit
> > different from pgd's and I didn't see any documentation about it
> > anywhere. Could be confusing.
>
> No, the lock is still needed. Thanks for catching this, that was indeed
> wrong.

Actually on second though - the code was actually ok. The reason is
that the highest page table level never goes away while the process
exists, and holding a pointer into it is always valid.

Only referencing it needs a lock, but pml4_offset doesn't reference
anything yet.

The same used to hold for pgds, but the 4level page tables change that.
However there was at least one bug in the patchkit in this area
which I now fixed.

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