mm: avoid memory thrashing caused by mismatched free memory calculation
authorSung-hun Kim <sfoon.kim@samsung.com>
Tue, 8 Sep 2020 12:44:30 +0000 (21:44 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Tue, 8 Sep 2020 12:44:30 +0000 (21:44 +0900)
commit48f25ce00a8ded160de613d78259822e0d6aef73
treeb55733a2511b8f24aaa8402e8bbc2acf0ecb1de5
parentc574d1c74096eeab487296ed3afed630f2ae1a05
mm: avoid memory thrashing caused by mismatched free memory calculation

Previously, the kernel calculates system's free memory by including cma free memory.
Unfortunately, the kernel doesn't use cma free memory for allocating unmovable pages.

In Tizen, GEM memory is allocated in unmovable pages by using shmem allocation. Because
of that, the kernel suffers from lack of free unmovable pages. To deal with it, the kernel
tries to steal movable pages and reclaim pages to make free unmovable pages. If user-level
daemon can take care of it in a proper way (e.g., call sigkill to make free memory), this
problem can be mitigated. But, they cannot catch the problem because system's free memory
always include cma free memory. As a result, the kernel repeatedly shrinks its page cache
and slab cache and reads files to launch an app, and finally it makes a catastrophic
thrashing problem.

This patch decouples page allocation of movable pages and calculation of free memory from
cma free memory pool. Thanks to Marek Szyprowski for his patches, the idea looks so feasible
to our system environment. This patch more generalized version of his patch (see the below link).

https://review.tizen.org/gerrit/#/c/platform/kernel/linux-rpi/+/243485/
https://review.tizen.org/gerrit/#/c/platform/kernel/linux-rpi/+/243486/

Change-Id: Idf4d8a0cc120363f8c8f340e0bac85783c530509
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
include/linux/vmstat.h
mm/Kconfig
mm/compaction.c
mm/page_alloc.c