This patch adds a simple low-memory notification mechanism. I took a recent
proposal by Minchan Kim and adapted it to our (Chromium OS) needs.
A process requests a low-memory notification by polling /dev/low-mem
(this name could change). The kernel checks for low-memory conditions in
the allocator fast path and wakes up the poll queue when such conditions
occur. Low-memory conditions are also checked when a process enters
the poll function, to ensure that any freeing done by the process is
noticed.
Low memory condition is defined as the ratio of "free memory" to total memory
being lower than a given margin. The margin is 10% by default and can be
changed via /sys/kernel/mm/low_mem/margin (this name could change).
Free memory is computed as an approximation as described in the code.
This patch also contains a test program in tools/mm/low-mem-test.c.
BUG=chromium-os:20086
TEST=see enclosed test program. Test team: verify that /dev/low-mem exists.
Signed-off-by: Luigi Semenzato <semenzato@chromium.org>
Change-Id: Iec1eb499d1482e818b491bacf1d48f53a5d9e191
Reviewed-on: https://gerrit.chromium.org/gerrit/14635
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Conflicts:
mm/page_alloc.c
[anush: fixes for 3.3]
Signed-off-by: Anush Elangovan <anush@chromium.org>
[benzh: 3.14 rebase. "oldmem" memdev has beem removed. Fixed mm/Kconfig whitespace]
Signed-off-by: Ben Zhang <benzh@chromium.org>