User:Lone Rifle/Page Replacement Policy

From ReactOS Wiki
Jump to: navigation, search
[20:49] <@arty> MmTrimUserMemory
[20:50] <@arty> replace MmGetLRUFirstUserPage/MmGetLRUNextUserPage with anything you like
[20:50] <@arty> since that list now contains all evictable pages
[20:50] <@arty> basically
[20:50] <@arty> you'd need to collect some data too
[20:51] <@arty> there are various ways to collect addresses for page aging
[20:51] <@arty> i've been thinking about this
[20:51] <@arty> and a sneaky way might be to inspect the registers during KiSwapThread
[20:52] <@arty> and slightly de-age any page that's referenced in one of the registers
[20:53] <+Lone_Rifle> arty, so how do you go about collecting data again...?
[20:53] <@arty> Lone_Rifle: it depends on what you want to accomplish
[20:54] <@arty> the simple scheme used in ancient unices was to have a set number of pages to check per clock tick
[20:55] <@arty> and set a nybble counter n[Page] = ACCESS_BIT(Page) << 3 | n[Page] >> 1;
[20:55] <@arty> so recently active pages appear to have high counter values
[20:55] <@arty> Lone_Rifle: that's one way
[20:58] <@arty> the other one i suggested was to inspect the registers on KiSwapThread
[20:58] <@arty> and treat any address-like values as addresses
[20:58] <@arty> and don't age the pages referenced

[21:05] <@arty> Lone_Rifle: MmTrimUserMemory controls the algorithm
[21:05] <@arty> it currently calls MmGetLRUFirstPage/MmGetLRUNextPage
[21:06] <+Lone_Rifle> AH. that's clearer. thanks. sorry. slow on the uptake
[21:06] <@arty> it should call MmGetFirstPageToEvictAccordingToLoneRifile and MmGetNextPageToEvictAccordingToLoneRifle
[21:06] <@arty> for whatever you want it to really do
[21:06] <@arty> also, you should hook either the timer tick, the idle loop, or KiSwapThread to update the page ages
[21:06] <@arty> (in whatever way satisfies the algorithm you want)
[21:07] <@arty> so you can make informed choices