OSDN Git Service

simple_lmk: Fix broken multicopy atomicity for victims_to_kill
authorSultan Alsawaf <sultan@kerneltoast.com>
Mon, 4 Nov 2019 18:49:21 +0000 (10:49 -0800)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:46 +0000 (04:42 +0800)
commit206abc80489280335e2b5d037ad2a8f016c8fa62
tree62f9c2b44363e84d64242a34c9601ba94ba5d8c1
parente1b6ddf1ff9b9c0bfb3e2f420f37ff4040ae1853
simple_lmk: Fix broken multicopy atomicity for victims_to_kill

When the reclaim thread writes to victims_to_kill on one CPU, it expects
the updated value to be immediately reflected on all CPUs in order for
simple_lmk_mm_freed() to work correctly. Due to the lack of memory
barriers to guarantee multicopy atomicity, simple_lmk_mm_freed() can be
given a victim's mm without knowing the correct victims_to_kill value,
which can cause the reclaim thread to remain stuck waiting forever for
all victims to be freed. This scenario, despite being rare, has been
observed.

Fix this by using proper atomic helpers with memory barriers.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
drivers/android/simple_lmk.c