Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Aug 2001 19:51:31 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        current@freebsd.org
Subject:   Silliness in pmap code?
Message-ID:  <Pine.BSF.4.21.0108241947070.60806-100000@InterJet.elischer.org>

next in thread | raw e-mail | index | archive | help

Consider the folowing function:
/*
 * Super fast pmap_pte routine best used when scanning
 * the pv lists.  This eliminates many coarse-grained
 * invltlb calls.  Note that many of the pv list
 * scans are across different pmaps.  It is very wasteful
 * to do an entire invltlb for checking a single mapping.
 */

static unsigned *
pmap_pte_quick(pmap, va)
        register pmap_t pmap;
        vm_offset_t va;
{
        unsigned pde, newpf;
        /* 
         * Check if the appropriate PDE is valid. If not, we're done.
         */
**A**   if ((pde = (unsigned) pmap->pm_pdir[va >> PDRSHIFT]) !=
0) {
                unsigned frame = (unsigned) pmap->pm_pdir[PTDPTDI] &
PG_FRAME;
                unsigned index = i386_btop(va);
                /* are we current address space or kernel? */
                /* If so, use the exsiting PTE mappings into KVE space */
                if ((pmap == kernel_pmap) ||
                        (frame == (((unsigned) PTDpde) & PG_FRAME))) {
                        return (unsigned *) PTmap + index;
                }
                /*
                 * IF not, set up a single page to map 
                 * the approptiate PTEs into
                 * thos doesn;t make sense since the PDIR test above
                 * only applies to the current pmap
                 */
                newpf = pde & PG_FRAME;
                if ( ((* (unsigned *) PMAP1) & PG_FRAME) != newpf) {
                        * (unsigned *) PMAP1 = newpf | PG_RW | PG_V;
                        invltlb_1pg((vm_offset_t) PADDR1);
                }
                return PADDR1 + ((unsigned) index & (NPTEPG - 1));
        }
        return (0);
}

The test marked **A** only applies to the current pmap

However inside the test, we check to see if we are talking about the 
current pmap, or another pmap.

If other pmaps are allowed top be examined, then the foirst test is
flawed, otherwise, if other maps are not to be examined using this
function, then the second part of the inside of the clause is
not needed.. (and should be a panic)

which is correct?




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0108241947070.60806-100000>