Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2012 19:57:50 +0800
From:      Paul Ambrose <ambrosehua@gmail.com>
To:        freebsd-mips@freebsd.org
Subject:   tlb.c tlb_invalidate_all_user simplified
Message-ID:  <CAMwoQQ6sFSh3MuPivwszTUOF0tWZRYMxtwEjtbRLE0X%2Bpx_Xfw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
when I saw this commit,
commit e60abd7cb37fb1b66e8b0c48050aa56732c73e90
Author: alc <alc@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 ?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMwoQQ6sFSh3MuPivwszTUOF0tWZRYMxtwEjtbRLE0X%2Bpx_Xfw>