Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/pmap.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 7,539 Lines • ▼ Show 20 Lines | pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, | ||||||||
PG_V = pmap_valid_bit(pmap); | PG_V = pmap_valid_bit(pmap); | ||||||||
PMAP_LOCK_ASSERT(pmap, MA_OWNED); | PMAP_LOCK_ASSERT(pmap, MA_OWNED); | ||||||||
/* | /* | ||||||||
* In the case that a page table page is not | * In the case that a page table page is not | ||||||||
* resident, we are creating it here. | * resident, we are creating it here. | ||||||||
*/ | */ | ||||||||
if (va < VM_MAXUSER_ADDRESS) { | if (va < VM_MAXUSER_ADDRESS) { | ||||||||
pdp_entry_t *pdpe; | |||||||||
pd_entry_t *pde; | |||||||||
vm_pindex_t ptepindex; | vm_pindex_t ptepindex; | ||||||||
pd_entry_t *ptepa; | |||||||||
/* | /* | ||||||||
* Calculate pagetable page index | * Calculate pagetable page index | ||||||||
*/ | */ | ||||||||
ptepindex = pmap_pde_pindex(va); | ptepindex = pmap_pde_pindex(va); | ||||||||
if (mpte && (mpte->pindex == ptepindex)) { | if (mpte && (mpte->pindex == ptepindex)) { | ||||||||
kib: Remove the extra () if you are fixing style | |||||||||
mpte->ref_count++; | mpte->ref_count++; | ||||||||
} else { | } else { | ||||||||
/* | /* | ||||||||
* Get the page directory entry | |||||||||
*/ | |||||||||
ptepa = pmap_pde(pmap, va); | |||||||||
/* | |||||||||
* If the page table page is mapped, we just increment | * If the page table page is mapped, we just increment | ||||||||
* the hold count, and activate it. Otherwise, we | * the hold count, and activate it. Otherwise, we | ||||||||
* attempt to allocate a page table page. If this | * attempt to allocate a page table page, passing NULL | ||||||||
* attempt fails, we don't retry. Instead, we give up. | * instead of the PV list lock pointer because we don't | ||||||||
* intend to sleep. If this attempt fails, we don't | |||||||||
* retry. Instead, we give up. | |||||||||
*/ | */ | ||||||||
if (ptepa && (*ptepa & PG_V) != 0) { | pdpe = pmap_pdpe(pmap, va); | ||||||||
if (*ptepa & PG_PS) | if (pdpe != NULL && (*pdpe & PG_V) != 0) { | ||||||||
Done Inline Actions
kib: | |||||||||
if ((*pdpe & PG_PS) != 0) | |||||||||
Done Inline ActionsIn the newly introduced if statement above, we already know whether pde is not NULL, but I'm pretty sure that the compiler can't infer that pmap_pdpe_to_pde(pdpe, va) cannot be NULL. For example, it doesn't know that physical page 0 is not allocatable. So, you could fold this if/else statement into the above and thereby eliminate the pde NULL check. The PHYS_TO_VM_PAGE line might be the only one that crosses 80 characters. alc: In the newly introduced if statement above, we already know whether pde is not NULL, but I'm… | |||||||||
Done Inline ActionsI rewrote this fragment to avoid needless comparisons, but I can't see a way to do so that doesn't require adding either some code duplication or an ugly goto. markj: I rewrote this fragment to avoid needless comparisons, but I can't see a way to do so that… | |||||||||
Not Done Inline ActionsIn this case, I would expect the compiler to be able to deduplicate the generated code with no extra branches. alc: In this case, I would expect the compiler to be able to deduplicate the generated code with no… | |||||||||
return (NULL); | return (NULL); | ||||||||
mpte = PHYS_TO_VM_PAGE(*ptepa & PG_FRAME); | pde = pmap_pdpe_to_pde(pdpe, va); | ||||||||
if ((*pde & PG_V) != 0) { | |||||||||
if ((*pde & PG_PS) != 0) | |||||||||
return (NULL); | |||||||||
mpte = PHYS_TO_VM_PAGE(*pde & PG_FRAME); | |||||||||
mpte->ref_count++; | mpte->ref_count++; | ||||||||
} else { | } else { | ||||||||
/* | mpte = pmap_allocpte_alloc(pmap, | ||||||||
* Pass NULL instead of the PV list lock | ptepindex, NULL, va); | ||||||||
* pointer, because we don't intend to sleep. | if (mpte == NULL) | ||||||||
*/ | return (NULL); | ||||||||
} | |||||||||
} else { | |||||||||
mpte = pmap_allocpte_alloc(pmap, ptepindex, | mpte = pmap_allocpte_alloc(pmap, ptepindex, | ||||||||
NULL, va); | NULL, va); | ||||||||
if (mpte == NULL) | if (mpte == NULL) | ||||||||
return (mpte); | return (NULL); | ||||||||
} | } | ||||||||
} | } | ||||||||
pte = (pt_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(mpte)); | pte = (pt_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(mpte)); | ||||||||
pte = &pte[pmap_pte_index(va)]; | pte = &pte[pmap_pte_index(va)]; | ||||||||
} else { | } else { | ||||||||
mpte = NULL; | mpte = NULL; | ||||||||
pte = vtopte(va); | pte = vtopte(va); | ||||||||
} | } | ||||||||
▲ Show 20 Lines • Show All 4,497 Lines • Show Last 20 Lines |
Remove the extra () if you are fixing style