summaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2020-04-02 06:07:27 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2020-04-02 18:35:29 +0200
commitc3d532008661da197997fc6d8098190eef9344ad (patch)
treec8ce41c0a1244c279675a4ac01c7f06eb190ee49 /mm/memcontrol.c
parentmm, memcg: prevent memory.low load/store tearing (diff)
downloadlinux-c3d532008661da197997fc6d8098190eef9344ad.tar.xz
linux-c3d532008661da197997fc6d8098190eef9344ad.zip
mm, memcg: prevent memory.min load/store tearing
This can be set concurrently with reads, which may cause the wrong value to be propagated. Signed-off-by: Chris Down <chris@chrisdown.name> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Roman Gushchin <guro@fb.com> Cc: Tejun Heo <tj@kernel.org> Link: http://lkml.kernel.org/r/e809b4e6b0c1626dac6945970de06409a180ee65.1584034301.git.chris@chrisdown.name Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f7af5aea0054..dc28afa149ef 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6389,7 +6389,7 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
return MEMCG_PROT_NONE;
if (parent == root) {
- memcg->memory.emin = memcg->memory.min;
+ memcg->memory.emin = READ_ONCE(memcg->memory.min);
memcg->memory.elow = memcg->memory.low;
goto out;
}
@@ -6397,7 +6397,8 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
parent_usage = page_counter_read(&parent->memory);
memcg->memory.emin = effective_protection(usage, parent_usage,
- memcg->memory.min, READ_ONCE(parent->memory.emin),
+ READ_ONCE(memcg->memory.min),
+ READ_ONCE(parent->memory.emin),
atomic_long_read(&parent->memory.children_min_usage));
memcg->memory.elow = effective_protection(usage, parent_usage,