Re: page fault scalability patch V14 [5/7]: x86_64 atomic pte

Andi Kleen
2005-01-04T19:46:50Z

Christoph Lameter <clameter@sgi.com> writes:

I bet this has been never tested.

> #define pmd_populate_kernel(mm, pmd, pte) \
> set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
> #define pud_populate(mm, pud, pmd) \
> @@ -14,11 +18,24 @@
> #define pgd_populate(mm, pgd, pud) \
> set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)))
>
> +#define pmd_test_and_populate(mm, pmd, pte) \
> + (cmpxchg((int *)pmd, PMD_NONE, _PAGE_TABLE | __pa(pte)) = PMD_NONE)
> +#define pud_test_and_populate(mm, pud, pmd) \
> + (cmpxchg((int *)pgd, PUD_NONE, _PAGE_TABLE | __pa(pmd)) = PUD_NONE)
> +#define pgd_test_and_populate(mm, pgd, pud) \
> + (cmpxchg((int *)pgd, PGD_NONE, _PAGE_TABLE | __pa(pud)) = PGD_NONE)
> +

Shouldn't this all be (long *)pmd ? page table entries on x86-64 are 64bit.
Also why do you cast at all? i think the macro should handle an arbitary
pointer.

> +
> static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
> {
> set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
> }
>
> +static inline int pmd_test_and_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
> +{
> + return cmpxchg((int *)pmd, PMD_NONE, _PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)) = PMD_NONE;

Same.

-Andi