[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200316145923.GR11482@dhcp22.suse.cz>
Date: Mon, 16 Mar 2020 15:59:23 +0100
From: Michal Hocko <mhocko@...nel.org>
To: Chris Down <chris@...isdown.name>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Tejun Heo <tj@...nel.org>, Roman Gushchin <guro@...com>,
linux-mm@...ck.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-team@...com
Subject: Re: [PATCH 6/6] mm, memcg: Prevent mem_cgroup_protected store tearing
On Thu 12-03-20 17:33:16, Chris Down wrote:
> The read side of this is all protected, but we can still tear if
> multiple iterations of mem_cgroup_protected are going at the same time.
>
> There's some intentional racing in mem_cgroup_protected which is ok, but
> load/store tearing should be avoided.
>
> Signed-off-by: Chris Down <chris@...isdown.name>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Roman Gushchin <guro@...com>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: linux-mm@...ck.org
> Cc: cgroups@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> Cc: kernel-team@...com
Acked-by: Michal Hocko <mhocko@...e.com>
> ---
> mm/memcontrol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 57048a38c75d..e9af606238ab 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -6301,8 +6301,8 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
> }
>
> exit:
> - memcg->memory.emin = emin;
> - memcg->memory.elow = elow;
> + WRITE_ONCE(memcg->memory.emin, emin);
> + WRITE_ONCE(memcg->memory.elow, elow);
>
> if (usage <= emin)
> return MEMCG_PROT_MIN;
> --
> 2.25.1
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists