In a multiprocessor, the PG_W bit in the pte must be changed atomically.

Otherwise, the setting of the PG_M bit by one processor could be lost if
another processor is simultaneously changing the PG_W bit.

Reviewed by:	tegge@
This commit is contained in:
Alan Cox 2004-06-12 20:01:48 +00:00
parent c8fd7c3227
commit 2d0dc0fcd6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130386
2 changed files with 4 additions and 3 deletions

View File

@ -2200,10 +2200,10 @@ pmap_change_wiring(pmap, va, wired)
pte = pmap_pte(pmap, va);
if (wired && (*pte & PG_W) == 0) {
pmap->pm_stats.wired_count++;
*pte |= PG_W;
atomic_set_long(pte, PG_W);
} else if (!wired && (*pte & PG_W) != 0) {
pmap->pm_stats.wired_count--;
*pte &= ~PG_W;
atomic_clear_long(pte, PG_W);
}
}

View File

@ -178,7 +178,8 @@ __FBSDID("$FreeBSD$");
#define pmap_pte_u(pte) ((*(int *)pte & PG_A) != 0)
#define pmap_pte_v(pte) ((*(int *)pte & PG_V) != 0)
#define pmap_pte_set_w(pte, v) ((v)?(*(int *)pte |= PG_W):(*(int *)pte &= ~PG_W))
#define pmap_pte_set_w(pte, v) ((v) ? atomic_set_int((u_int *)(pte), PG_W) : \
atomic_clear_int((u_int *)(pte), PG_W))
#define pmap_pte_set_prot(pte, v) ((*(int *)pte &= ~PG_PROT), (*(int *)pte |= (v)))
struct pmap kernel_pmap_store;