Retire pmap_change_wiring(). We have never used it to wire virtual pages.

We continue to use pmap_enter() for that.  For unwiring virtual pages, we
now use pmap_unwire(), which unwires a range of virtual addresses instead
of a single virtual page.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Alan Cox 2014-08-03 20:40:51 +00:00
parent cb9b8e6f7d
commit a695d9b25b
17 changed files with 3 additions and 472 deletions

View File

@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
# 20140803: Remove an obsolete man page
OLD_FILES+=usr/share/man/man9/pmap_change_wiring.9.gz
# 20140728: libsbuf restored to old version.
OLD_LIBS+=lib/libsbuf.so.7
# 20140728: Remove an obsolete man page

View File

@ -199,7 +199,6 @@ MAN= accept_filter.9 \
physio.9 \
pmap.9 \
pmap_activate.9 \
pmap_change_wiring.9 \
pmap_clear_modify.9 \
pmap_copy.9 \
pmap_enter.9 \

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 18, 2014
.Dd August 3, 2014
.Dt PMAP 9
.Os
.Sh NAME
@ -89,7 +89,6 @@ operation.
.Sh SEE ALSO
.Xr pmap 9 ,
.Xr pmap_activate 9 ,
.Xr pmap_change_wiring 9 ,
.Xr pmap_clear_modify 9 ,
.Xr pmap_copy 9 ,
.Xr pmap_copy_page 9 ,

View File

@ -1,68 +0,0 @@
.\"
.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd July 21, 2003
.Dt PMAP_CHANGE_WIRING 9
.Os
.Sh NAME
.Nm pmap_change_wiring
.Nd change physical wiring for a map or virtual address pair
.Sh SYNOPSIS
.In sys/param.h
.In vm/vm.h
.In vm/pmap.h
.Ft void
.Fn pmap_change_wiring "pmap_t pmap" "vm_offset_t va" "boolean_t wired"
.Sh DESCRIPTION
The
.Fn pmap_change_wiring
function changes the wiring attribute for the page at virtual address
.Fa va
in the physical map
.Fa pmap .
A wired page gets its name from being
.Dq wired
into the system page tables so that it will not be paged out.
.Pp
The mapping must already exist in the
.Fa pmap .
If
.Fa wired
is
.Dv TRUE ,
the map's wired page count will be incremented; if
.Dv FALSE ,
it will be decremented.
.Pp
It is typically called by the
.Fn vm_fault_unwire
function.
.Sh SEE ALSO
.Xr pmap 9
.Sh AUTHORS
This manual page was written by
.An Bruce M Simpson Aq Mt bms@spc.org .

View File

@ -4692,58 +4692,6 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
}
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
pd_entry_t *pde;
pt_entry_t *pte;
boolean_t pv_lists_locked;
pv_lists_locked = FALSE;
/*
* Wiring is not a hardware characteristic so there is no need to
* invalidate TLB.
*/
retry:
PMAP_LOCK(pmap);
pde = pmap_pde(pmap, va);
if ((*pde & PG_PS) != 0) {
if (!wired != ((*pde & PG_W) == 0)) {
if (!pv_lists_locked) {
pv_lists_locked = TRUE;
if (!rw_try_rlock(&pvh_global_lock)) {
PMAP_UNLOCK(pmap);
rw_rlock(&pvh_global_lock);
goto retry;
}
}
if (!pmap_demote_pde(pmap, pde, va))
panic("pmap_change_wiring: demotion failed");
} else
goto out;
}
pte = pmap_pde_to_pte(pde, va);
if (wired && (*pte & PG_W) == 0) {
pmap->pm_stats.wired_count++;
atomic_set_long(pte, PG_W);
} else if (!wired && (*pte & PG_W) != 0) {
pmap->pm_stats.wired_count--;
atomic_clear_long(pte, PG_W);
}
out:
if (pv_lists_locked)
rw_runlock(&pvh_global_lock);
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -3252,56 +3252,6 @@ pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
rw_wunlock(&pvh_global_lock);
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
struct l2_bucket *l2b;
struct md_page *pvh;
struct pv_entry *pve;
pd_entry_t *pl1pd, l1pd;
pt_entry_t *ptep, pte;
vm_page_t m;
rw_wlock(&pvh_global_lock);
PMAP_LOCK(pmap);
pl1pd = &pmap->pm_l1->l1_kva[L1_IDX(va)];
l1pd = *pl1pd;
if ((l1pd & L1_TYPE_MASK) == L1_S_PROTO) {
m = PHYS_TO_VM_PAGE(l1pd & L1_S_FRAME);
KASSERT((m != NULL) && ((m->oflags & VPO_UNMANAGED) == 0),
("pmap_change_wiring: unmanaged superpage should not "
"be changed"));
KASSERT(pmap != pmap_kernel(),
("pmap_change_wiring: managed kernel superpage "
"should not exist"));
pvh = pa_to_pvh(l1pd & L1_S_FRAME);
pve = pmap_find_pv(pvh, pmap, trunc_1mpage(va));
if (!wired != ((pve->pv_flags & PVF_WIRED) == 0)) {
if (!pmap_demote_section(pmap, va))
panic("pmap_change_wiring: demotion failed");
} else
goto out;
}
l2b = pmap_get_l2_bucket(pmap, va);
KASSERT(l2b, ("No l2b bucket in pmap_change_wiring"));
ptep = &l2b->l2b_kva[l2pte_index(va)];
pte = *ptep;
m = PHYS_TO_VM_PAGE(l2pte_pa(pte));
if (m != NULL)
pmap_modify_pv(m, pmap, va, PVF_WIRED,
wired == TRUE ? PVF_WIRED : 0);
out:
rw_wunlock(&pvh_global_lock);
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -3543,33 +3543,6 @@ pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
PMAP_UNLOCK(pmap);
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
struct l2_bucket *l2b;
pt_entry_t *ptep, pte;
vm_page_t pg;
rw_wlock(&pvh_global_lock);
PMAP_LOCK(pmap);
l2b = pmap_get_l2_bucket(pmap, va);
KASSERT(l2b, ("No l2b bucket in pmap_change_wiring"));
ptep = &l2b->l2b_kva[l2pte_index(va)];
pte = *ptep;
pg = PHYS_TO_VM_PAGE(l2pte_pa(pte));
if (pg)
pmap_modify_pv(pg, pmap, va, PVF_WIRED, wired ? PVF_WIRED : 0);
rw_wunlock(&pvh_global_lock);
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -3967,58 +3967,6 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
}
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
pd_entry_t *pde;
pt_entry_t *pte;
boolean_t are_queues_locked;
are_queues_locked = FALSE;
retry:
PMAP_LOCK(pmap);
pde = pmap_pde(pmap, va);
if ((*pde & PG_PS) != 0) {
if (!wired != ((*pde & PG_W) == 0)) {
if (!are_queues_locked) {
are_queues_locked = TRUE;
if (!rw_try_wlock(&pvh_global_lock)) {
PMAP_UNLOCK(pmap);
rw_wlock(&pvh_global_lock);
goto retry;
}
}
if (!pmap_demote_pde(pmap, pde, va))
panic("pmap_change_wiring: demotion failed");
} else
goto out;
}
pte = pmap_pte(pmap, va);
if (wired && !pmap_pte_w(pte))
pmap->pm_stats.wired_count++;
else if (!wired && pmap_pte_w(pte))
pmap->pm_stats.wired_count--;
/*
* Wiring is not a hardware characteristic so there is no need to
* invalidate TLB.
*/
pmap_pte_set_w(pte, wired);
pmap_pte_release(pte);
out:
if (are_queues_locked)
rw_wunlock(&pvh_global_lock);
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -3166,39 +3166,6 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
}
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
pt_entry_t *pte;
rw_wlock(&pvh_global_lock);
PMAP_LOCK(pmap);
pte = pmap_pte(pmap, va);
if (wired && !pmap_pte_w(pte)) {
PT_SET_VA_MA((pte), *(pte) | PG_W, TRUE);
pmap->pm_stats.wired_count++;
} else if (!wired && pmap_pte_w(pte)) {
PT_SET_VA_MA((pte), *(pte) & ~PG_W, TRUE);
pmap->pm_stats.wired_count--;
}
/*
* Wiring is not a hardware characteristic so there is no need to
* invalidate TLB.
*/
pmap_pte_release(pte);
PMAP_UNLOCK(pmap);
rw_wunlock(&pvh_global_lock);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -2424,37 +2424,6 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr,
("pmap_object_init_pt: non-device object"));
}
/*
* Routine: pmap_change_wiring
* Function: Change the wiring attribute for a map/virtual-address
* pair.
* In/out conditions:
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
pt_entry_t *pte;
PMAP_LOCK(pmap);
pte = pmap_pte(pmap, va);
if (wired && !pte_test(pte, PTE_W))
pmap->pm_stats.wired_count++;
else if (!wired && pte_test(pte, PTE_W))
pmap->pm_stats.wired_count--;
/*
* Wiring is not a hardware characteristic so there is no need to
* invalidate TLB.
*/
if (wired)
pte_set(pte, PTE_W);
else
pte_clear(pte, PTE_W);
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range

View File

@ -269,7 +269,6 @@ int moea_pte_spill(vm_offset_t);
/*
* Kernel MMU interface
*/
void moea_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t);
void moea_clear_modify(mmu_t, vm_page_t);
void moea_copy_page(mmu_t, vm_page_t, vm_page_t);
void moea_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
@ -319,7 +318,6 @@ vm_offset_t moea_dumpsys_map(mmu_t mmu, struct pmap_md *md, vm_size_t ofs,
struct pmap_md * moea_scan_md(mmu_t mmu, struct pmap_md *prev);
static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_change_wiring, moea_change_wiring),
MMUMETHOD(mmu_clear_modify, moea_clear_modify),
MMUMETHOD(mmu_copy_page, moea_copy_page),
MMUMETHOD(mmu_copy_pages, moea_copy_pages),
@ -1015,28 +1013,6 @@ moea_deactivate(mmu_t mmu, struct thread *td)
PCPU_SET(curpmap, NULL);
}
void
moea_change_wiring(mmu_t mmu, pmap_t pm, vm_offset_t va, boolean_t wired)
{
struct pvo_entry *pvo;
PMAP_LOCK(pm);
pvo = moea_pvo_find_va(pm, va & ~ADDR_POFF, NULL);
if (pvo != NULL) {
if (wired) {
if ((pvo->pvo_vaddr & PVO_WIRED) == 0)
pm->pm_stats.wired_count++;
pvo->pvo_vaddr |= PVO_WIRED;
} else {
if ((pvo->pvo_vaddr & PVO_WIRED) != 0)
pm->pm_stats.wired_count--;
pvo->pvo_vaddr &= ~PVO_WIRED;
}
}
PMAP_UNLOCK(pm);
}
void
moea_unwire(mmu_t mmu, pmap_t pm, vm_offset_t sva, vm_offset_t eva)
{

View File

@ -283,7 +283,6 @@ static void moea64_syncicache(mmu_t, pmap_t pmap, vm_offset_t va,
/*
* Kernel MMU interface
*/
void moea64_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t);
void moea64_clear_modify(mmu_t, vm_page_t);
void moea64_copy_page(mmu_t, vm_page_t, vm_page_t);
void moea64_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
@ -332,7 +331,6 @@ vm_offset_t moea64_dumpsys_map(mmu_t mmu, struct pmap_md *md, vm_size_t ofs,
struct pmap_md * moea64_scan_md(mmu_t mmu, struct pmap_md *prev);
static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_change_wiring, moea64_change_wiring),
MMUMETHOD(mmu_clear_modify, moea64_clear_modify),
MMUMETHOD(mmu_copy_page, moea64_copy_page),
MMUMETHOD(mmu_copy_pages, moea64_copy_pages),
@ -1025,59 +1023,6 @@ moea64_deactivate(mmu_t mmu, struct thread *td)
#endif
}
void
moea64_change_wiring(mmu_t mmu, pmap_t pm, vm_offset_t va, boolean_t wired)
{
struct pvo_entry *pvo;
uintptr_t pt;
uint64_t vsid;
int i, ptegidx;
LOCK_TABLE_WR();
PMAP_LOCK(pm);
pvo = moea64_pvo_find_va(pm, va & ~ADDR_POFF);
if (pvo != NULL) {
pt = MOEA64_PVO_TO_PTE(mmu, pvo);
if (wired) {
if ((pvo->pvo_vaddr & PVO_WIRED) == 0)
pm->pm_stats.wired_count++;
pvo->pvo_vaddr |= PVO_WIRED;
pvo->pvo_pte.lpte.pte_hi |= LPTE_WIRED;
} else {
if ((pvo->pvo_vaddr & PVO_WIRED) != 0)
pm->pm_stats.wired_count--;
pvo->pvo_vaddr &= ~PVO_WIRED;
pvo->pvo_pte.lpte.pte_hi &= ~LPTE_WIRED;
}
if (pt != -1) {
/* Update wiring flag in page table. */
MOEA64_PTE_CHANGE(mmu, pt, &pvo->pvo_pte.lpte,
pvo->pvo_vpn);
} else if (wired) {
/*
* If we are wiring the page, and it wasn't in the
* page table before, add it.
*/
vsid = PVO_VSID(pvo);
ptegidx = va_to_pteg(vsid, PVO_VADDR(pvo),
pvo->pvo_vaddr & PVO_LARGE);
i = MOEA64_PTE_INSERT(mmu, ptegidx, &pvo->pvo_pte.lpte);
if (i >= 0) {
PVO_PTEGIDX_CLR(pvo);
PVO_PTEGIDX_SET(pvo, i);
}
}
}
UNLOCK_TABLE_WR();
PMAP_UNLOCK(pm);
}
void
moea64_unwire(mmu_t mmu, pmap_t pm, vm_offset_t sva, vm_offset_t eva)
{

View File

@ -266,7 +266,6 @@ void pmap_bootstrap_ap(volatile uint32_t *);
/*
* Kernel MMU interface
*/
static void mmu_booke_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t);
static void mmu_booke_clear_modify(mmu_t, vm_page_t);
static void mmu_booke_copy(mmu_t, pmap_t, pmap_t, vm_offset_t,
vm_size_t, vm_offset_t);
@ -331,7 +330,6 @@ static struct pmap_md *mmu_booke_scan_md(mmu_t, struct pmap_md *);
static mmu_method_t mmu_booke_methods[] = {
/* pmap dispatcher interface */
MMUMETHOD(mmu_change_wiring, mmu_booke_change_wiring),
MMUMETHOD(mmu_clear_modify, mmu_booke_clear_modify),
MMUMETHOD(mmu_copy, mmu_booke_copy),
MMUMETHOD(mmu_copy_page, mmu_booke_copy_page),
@ -2411,31 +2409,6 @@ mmu_booke_ts_referenced(mmu_t mmu, vm_page_t m)
return (count);
}
/*
* Change wiring attribute for a map/virtual-address pair.
*/
static void
mmu_booke_change_wiring(mmu_t mmu, pmap_t pmap, vm_offset_t va, boolean_t wired)
{
pte_t *pte;
PMAP_LOCK(pmap);
if ((pte = pte_find(mmu, pmap, va)) != NULL) {
if (wired) {
if (!PTE_ISWIRED(pte)) {
pte->flags |= PTE_WIRED;
pmap->pm_stats.wired_count++;
}
} else {
if (PTE_ISWIRED(pte)) {
pte->flags &= ~PTE_WIRED;
pmap->pm_stats.wired_count--;
}
}
}
PMAP_UNLOCK(pmap);
}
/*
* Clear the wired attribute from the mappings for the specified range of
* addresses in the given pmap. Every valid mapping within that range must

View File

@ -151,22 +151,6 @@ METHOD void advise {
};
/**
* @brief Change the wiring attribute for the page in the given physical
* map and virtual address.
*
* @param _pmap physical map of page
* @param _va page virtual address
* @param _wired TRUE to increment wired count, FALSE to decrement
*/
METHOD void change_wiring {
mmu_t _mmu;
pmap_t _pmap;
vm_offset_t _va;
boolean_t _wired;
};
/**
* @brief Clear the 'modified' bit on the given physical page
*

View File

@ -99,14 +99,6 @@ pmap_advise(pmap_t pmap, vm_offset_t start, vm_offset_t end, int advice)
MMU_ADVISE(mmu_obj, pmap, start, end, advice);
}
void
pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired)
{
CTR4(KTR_PMAP, "%s(%p, %#x, %u)", __func__, pmap, va, wired);
MMU_CHANGE_WIRING(mmu_obj, pmap, va, wired);
}
void
pmap_clear_modify(vm_page_t m)
{

View File

@ -1666,31 +1666,6 @@ pmap_object_init_pt(pmap_t pm, vm_offset_t addr, vm_object_t object,
("pmap_object_init_pt: non-device object"));
}
/*
* Change the wiring attribute for a map/virtual-address pair.
* The mapping must already exist in the pmap.
*/
void
pmap_change_wiring(pmap_t pm, vm_offset_t va, boolean_t wired)
{
struct tte *tp;
u_long data;
PMAP_LOCK(pm);
if ((tp = tsb_tte_lookup(pm, va)) != NULL) {
if (wired) {
data = atomic_set_long(&tp->tte_data, TD_WIRED);
if ((data & TD_WIRED) == 0)
pm->pm_stats.wired_count++;
} else {
data = atomic_clear_long(&tp->tte_data, TD_WIRED);
if ((data & TD_WIRED) != 0)
pm->pm_stats.wired_count--;
}
}
PMAP_UNLOCK(pm);
}
static int
pmap_unwire_tte(pmap_t pm, pmap_t pm2, struct tte *tp, vm_offset_t va)
{

View File

@ -102,7 +102,6 @@ void pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t eva,
int advice);
void pmap_align_superpage(vm_object_t, vm_ooffset_t, vm_offset_t *,
vm_size_t);
void pmap_change_wiring(pmap_t, vm_offset_t, boolean_t);
void pmap_clear_modify(vm_page_t m);
void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t);
void pmap_copy_page(vm_page_t, vm_page_t);