turns out that prioritizing pages beyond LRU does not improve
performance at all -- really hurts performance.
Also making the OOM target a bit smaller so that the system
feels a bit more responsive between OOM events.
In this situation, we enter the OOM with the hardware address
space vs the process space inconsistent (the hardware address
space was transitioned in anticipation of mapping a block into it).
This patch reverts our address space to the original space then
runs the OOM routine, and then puts us back where we were.
Found a case where this is actually "legal" - when you have
a piece of memory that is allocated without going to swap,
then lent, then swapped, then released before being read back
into memory. In this case, the release will clear the page without
notifying the swapper of such an event.
This case is mostly harmless -- the biggest problem is that we
leak swap due to pages that are released while swapped. This
tends to happen mostly with memory messages, and there is a high
re-use of addresses in this situation so I think the leakage
is not bad.
However, we continue to print the warning. If it turns out
that the leakage is cumulative, we'll have to come up with a
way to report this situation back to the swapper -- but it's
fairly disruptive, because it also forces us to do a full PT
walk and check on release plus send a message to the swap context
which is another chunk of code and syscall.
My working theory is this will be a "couple of pages" that circulate
around in a messaging pool inside swap memory, which is fine because
it doesn't impact main memory usage and swap memory is fairly
ample.
previously we could re-enter into a process through a divergent
call into the swapper. Now, we only ever re-enter as a syscall
through the syscall interface.
in order to make this happen we had to store all the thread and
stack state for the handler so we can do a re-entrant syscall, but
I think this is worth it. makes the code so much better.
- makes retrieve_page in-lineable into existing kernel routines
without a divergence issue on the call return
- reduces code duplication
- fixes a hairy bug on interrupt restore timing. With the previous
method, the interrupts would have to un-gate just before the
syscall executes its return to normalcy; this can cause a race
condition between a hardware interrupt and that return context
switch which can lead to the return context being corrupted.
By making this re-entrant, we can make the IRQ pause/restore
point happen outside of any fancy system context footwork, which
makes the interrupt via hardware source work again.