Layer rmap, balance, page and freelist so that reference and dereference calls are properly paired in every case.
Reduce the width of the mm interface and the number of moving parts.
Provide a simpler API that will be easier to analyze.
Reduce recorded information in order to keep potentially out of date state from accumulating.
Things I now know
balance.c and freelist.c
MapCount is now added to ReferenceCount, since dereference on a mapped page is not legal.
ReferenceCount must be at least one if .Flags.Type is MM_PHYSICAL_PAGE_USED and zero if .Flags.Type is MM_PHYSICAL_PAGE_FREE. Suggestion: roll these states into ReferenceCount and make MM_PHYSICAL_PAGE_BIOS a flag.
Pages start free and are freed by the Trim functions called by the balance manager. Pages can have ownership transferred, but we should remove this early optimization and focus on correctness.
Several functions now ignore out of bounds accesses to the MmPageArray. We need to make those bugcheck and catch the offenders.
There's got to be a better data structure for this.
Rmap is disjoint from both page.c and freelist, and yet models some of the same information.