one question about pgd allocation

From: liyu@WAN
Date: Fri Jul 01 2005 - 07:52:04 EST


hi LKML:

I am reading kernel code about memory management.

on i386 platform, the function pgd_alloc() alloc one page table directory,
every directory entry is one PMD address. that is OK.

pgd_t *pgd_alloc(struct mm_struct *mm)
{
int i;
pgd_t *pgd = kmem_cache_alloc(pgd_cache, GFP_KERNEL);

if (PTRS_PER_PMD == 1 || !pgd)
return pgd;

for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
if (!pmd)
goto out_oom;
set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
}
return pgd;

out_oom:
for (i--; i >= 0; i--)
kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
kmem_cache_free(pgd_cache, pgd);
return NULL;
}

My question is the statement:

set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));

why here is not :

set_pgd(&pgd[i], __pgd(__pa(pmd)));

I can not understand this. I search intel developer mannal. but nothing to help.
Who can tell me why?


thank in advanced.

liyu
2005/7/1


-
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/