Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Aug 2001 12:20:36 -0700 (PDT)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Chad David <davidc@acns.ab.ca>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Page Coloring
Message-ID:  <200108051920.f75JKa581920@earth.backplane.com>
References:   <20010802120335.A11520@colnta.acns.ab.ca>

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

:
:If I added this to a man page would I be telling the truth :).
:
:Note, these are my notes and not the exact text that I would
:add, and I have not bother with anything to do with object
:coloring etc.  I just want to make sure I've got this part
:down.
:
:Chad

    It's a good description but it might be better to simplify it a bit.
    You don't need to go into that level of detail.  There is a short
    page coloring explanation at the end of my VM article which might
    be more suitable to a man page:

	http://www.daemonnews.org/200001/freebsd_vm.html

						-Matt

    (quoted from the article):

    Ok, so now onto page coloring: All modern memory caches are what are 
    known as *physical* caches. They cache physical memory addresses, not
    virtual memory addresses. This allows the cache to be left alone across
    a process context switch, which is very important. 

    But in the UNIX world you are dealing with virtual address spaces, not
    physical address spaces. Any program you write will see the virtual
    address space given to it. The actual *physical* pages underlying that
    virtual address space are not necessarily physically contiguous! In
    fact, you might have two pages that are side by side in a processes
    address space which wind up being at offset 0 and offset 128K in
    *physical* memory. 

    A program normally assumes that two side-by-side pages will be 
    optimally cached. That is, that you can access data objects in both
    pages without having them blow away each other's cache entry. But this
    is only true if the physical pages underlying the virtual address
    space are contiguous (insofar as the cache is concerned). 

    This is what Page coloring does. Instead of assigning *random*
    physical pages to virtual addresses, which may result in non-optimal
    cache performance , Page coloring assigns *reasonably-contiguous*
    physical pages to virtual addresses. Thus programs can be written
    under the assumption that the characteristics of the underlying
    hardware cache are the same for their virtual address space as they
    would be if the program had been run directly in a physical address
    space. 

    Note that I say 'reasonably' contiguous rather than simply 'contiguous'.
    From the point of view of a 128K direct mapped cache, the physical
    address 0 is the same as the physical address 128K. So two side-by-side
    pages in your virtual address space may wind up being offset 128K and
    offset 132K in physical memory, but could also easily be offset 128K
    and offset 4K in physical memory and still retain the same cache
    performance characteristics. So page-coloring does *NOT* have to assign
    truely contiguous pages of physical memory to contiguous pages of
    virtual memory, it just needs to make sure it assigns contiguous pages
    from the point of view of cache performance and operation. 


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108051920.f75JKa581920>