currently able to trigger an eviction and it seems like some of
the pages actually go out, but there is some imprecision in the
syscall implementation for eviction that is causing the userspace
code to re-enter in a bad state after a few iterations of
the call.
checking code in as an intermediate checkpoint.
some thought needs to go into when and how we call oom_doom
but let's test more core functionality of the swapper before we
worry about that. I can think of several places where we could
use that call, the main tricky bit is that oom_doom diverges
and so wherever we patch it has to be able to resume. If we put
it into e.g. somewhere in the main memory alloc loop, the trouble
is we would have to track all of the multiple places that we
could have arrived there...ideally we can find a single spot
to patch this, with a clean entry and exit path.
trying to condense most of the RPT API into the loader so
that the userspace can use a single dependency for this.
We can't condense the kernel API into the loader unfortunately,
because the kernel actually uses a different type for representing
a process. This is probably a mistake, and is something that
may be fixed later so we can merge the representations.
instead of sending scalar messages on every page alloc/free, which
is a lot of traffic, introduce an API where the swapper can request
a snapshot of the alloc status by mapping the kernel's alloc
table as a read-only structure into the swapper's memory space,
and then invoking the swapper in its interrupt context to read that out.
The structure is unmapped on return from the context.
additionally, a running tally of free space is now maintained
and this can be queried with a fast syscall.
Thus, the normal workflow is the swapper would have a timer that
periodically queries the kernel's free space level, and when it
falls below a critical amount, it will invoke the expensive snapshot.
this can also be extended so that the kernel can call into
the swapper's interrupt context with a "help, OOM imminent"
message down the road.
this is allocated by the loader for the swapper. This should
be the last big piece of state we need to get the swapper to work...
honestly, it's already a pretty heavy bit of code :( we should
probably optimize out the RPT hand-off to not include all of
the non-swappable memory pages, which is quite substantial in
the case of some SoCs.
also refactor to use the loader's computation function for
the MAC offset in swap, instead of copying this hairy bit of
logic like....8 times over throughout the code base, yeaaach!