Subject: VM/pmap question - how to throw away mappings?
To: None <mycroft@gnu.ai.mit.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: tech-kern
Date: 12/04/1994 14:02:57
> Date: Sun, 4 Dec 1994 07:56:34 -0500
> From: "Charles M. Hannum" <mycroft@gnu.ai.mit.edu>
> 
> Actually, this:
> 
> 	m = &vm_page_array[pmap_page_index(addr) - first_page];
> 
> should probably be written as:
> 
> 	m = &vm_page_array[PHYS_TO_VM_PAGE(addr)];
> 
> But this reminds me of somethign else.  In the MACHINE_NONCONTIG case,
> should we assume that pmap_page_index() already adjusts for
> first_page, so we can avoid the extra arithmetic on machines that
> don't need it?

I wondered about that too when I saw the macro:

	#define PHYS_TO_VM_PAGE(pa) \
	        (&vm_page_array[pmap_page_index(pa) - first_page])

It is true that the subtraction could be saved if the port doesn't
need it, though as you pointed out, this is not actually called all
that much unless one has compiled with -DDEBUG (like I did).  Given
that, I'd suggest leaving it as it is for backward compatibility
with old pmap implementations.

Also, if a port defines pmap_page_index as a macro, i.e.:

	#define pmap_page_index(pa) sun3_btop(pa)

then it doesn't really matter who is responsible for the subtraction
because the code will end up being the same in either case (with the
subtraction either in the macro or at the site of its use).

Gordon