CHROMIUM: low-mem: work with swap enabled
authorLuigi Semenzato <semenzato@chromium.org>
Mon, 2 Jul 2012 23:15:39 +0000 (16:15 -0700)
committerGerrit <chrome-bot@google.com>
Fri, 13 Jul 2012 01:41:19 +0000 (18:41 -0700)
commit945bfe9bd18bd87606245a5c70b647b8dcc2fa9e
tree3ada78ba7e4c699273ffd068a311f70c5b1bf280
parent6f3a0095b38b9d30be4e089542ff43f25df6e762
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>
include/linux/low-mem-notify.h