Subject: VM/pmap question - how to throw away mappings?
To: None <email@example.com>
From: Gordon W. Ross <firstname.lastname@example.org>
Date: 12/03/1994 18:24:51
> Date: Sat, 3 Dec 1994 03:51:02 -0500
> From: "Charles M. Hannum" <email@example.com>
> I don't completely understand this. In the Sun 3 pmap, how does
> pmap_remove_all() know which pmaps have a page mapped so that it can
> be removed?
I assume you mean pv_remove_all(), called by pmap_page_protect().
When I said the pmap module does not allocate memory to store
mappings, I meant "forward" mappings (virtual to physical) which
are stored ONLY in the MUU. The pmap DOES still need to store
"reverse" mappings using the typical per-page array of list heads
so you can go find all virtual mappings to any physical page.
> When you say the `oldest' mapping is thrown away, do you mean `oldest'
> as in `first to be created' or in the sense of a LRU list? If the
> former, you almost certainly don't want the VM system to deactive the
> pages prematurely, because they're probably for something like
> libc.so, which you don't really want to page out in most cases.
Every mapping requires a chunk of MMU hardware called a PMEG (sun
terminology for Page Map Entry Group) There are a fixed number
of these PMEGs which are constantly fought over by the pmap as
faults are handled (very much like TLB entries). Every time a
fault cause a PMEG to be reloaded with mappings, that PMEG is
moved to the tail of the "active" list. When there are no free
PMEGS, we "steal" one from the head of the "active" list which
will be the one that was "faulted in" the longest ago. So yes,
every mapping is likely to loose its PMEG every so often, and
will need to be faulted back in if it is still needed.
My concern about throwing away mappings is that the VM code may
in some cases be able to benefit from knowlede of the fact that
some mapping is no longer installed. The pmap code could check
to see if it is removing the last mapping to some physical page
and only then tell the VM code "hey, this page is now dead."
This would be done merely as an optimization, doing work that
will eventually be done by the pageout daemon: See if the page
has been referenced, write out modifications, put it on the inactive
list (where it can of course be reclaimed if not re-allocated).
So, is there a convenient way to do this?