tlb.c tlb_invalidate_all_user simplified
Paul Ambrose
ambrosehua at gmail.com
Fri Aug 10 11:57:52 UTC 2012
when I saw this commit,
commit e60abd7cb37fb1b66e8b0c48050aa56732c73e90
Author: alc <alc at FreeBSD.org>
Date: Fri Aug 10 05:00:50 2012 +0000
Merge r134393 from amd64/i386:
The machine-independent parts of the virtual memory system always
pass a
valid pmap to the pmap functions that require one. Remove the checks
for
NULL. (These checks have their origins in the Mach pmap.c that was
integrated into BSD. None of the new code written specifically for
FreeBSD included them.)
according to the description here, pmap should not be null, I think
tlb_invalidate_all_user(struct pmap * pmap), in mips/mips/tlb.c
----------------------------------------------------------------------------------------------------
tlb_invalidate_all_user(struct pmap *pmap)
{
register_t asid;
register_t s;
unsigned i;
s = intr_disable();
asid = mips_rd_entryhi() & TLBHI_ASID_MASK;
for (i = mips_rd_wired(); i < num_tlbentries; i++) {
register_t uasid;
mips_wr_index(i);
tlb_read();
uasid = mips_rd_entryhi() & TLBHI_ASID_MASK;
if (pmap == NULL) {
/*
* Invalidate all non-kernel entries.
*/
if (uasid == 0)
continue;
} else {
/*
* Invalidate this pmap's entries.
*/
if (uasid != pmap_asid(pmap))
continue;
}
tlb_invalidate_one(i);
}
mips_wr_entryhi(asid);
intr_restore(s);
}
---------------------------------------------------------------------------
could be simplified like this:
---------------------------------------------------------------------------
tlb_invalidate_all_user(struct pmap *pmap)
{
register_t asid;
register_t s;
unsigned i;
s = intr_disable();
asid = mips_rd_entryhi() & TLBHI_ASID_MASK;
for (i = mips_rd_wired(); i < num_tlbentries; i++) {
register_t uasid;
mips_wr_index(i);
tlb_read();
uasid = mips_rd_entryhi() & TLBHI_ASID_MASK;
if ((uasid != pmap_asid(pmap)) || (uasid == 0))
continue;
tlb_invalidate_one(i);
}
mips_wr_entryhi(asid);
intr_restore(s);
}
funcntion tlb_invalidate_all_user(struct pmap *pmap) is ONLY called like
this:
pmap_activate -> pmap_alloc_asid -> tlb_invalidate_all_user, I think the
pmap passed
fullfils the assumption. How do you like it ?
More information about the freebsd-mips
mailing list