summaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2020-04-01 21:07:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-04-02 09:35:29 -0700
commitc3d532008661da197997fc6d8098190eef9344ad (patch)
treec8ce41c0a1244c279675a4ac01c7f06eb190ee49 /mm/memcontrol.c
parentf86b810c2610b08afc82218068d1dfeef02dd0a1 (diff)
downloadlinux-c3d532008661da197997fc6d8098190eef9344ad.tar.bz2
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,