CHROMIUM: low-mem: work with swap enabled
Without this patch, the notifier triggers too early, when no or
little swap space is used.
We add a contribution from the swap to the "available memory" concept
by introducing a "RAM vs. swap weight". We can't just add them
together because 1. using swap costs us RAM; and 2. freeing RAM by
swapping its content out takes longer than using already free
RAM.
Experiment on an Alex with 2Gb of RAM show that with a weight of
4 and a 50Mb threshold, the system does not thrash or OOM. (The
experiments are not a complete guarantee.)
BUG=chromium-os:32322
TEST=tested with a memory pressure autotest which I am not allowed to commit
Signed-off-by: Luigi Semenzato <semenzato@chromium.org>
Change-Id: I614aa3e1ab1186ccc715bd23a082e7f9379b181c
Reviewed-on: https://gerrit.chromium.org/gerrit/26616
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>