[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YvUy5IA+XJp7ylIC@P9FQF9L96D.corp.robot.car>
Date: Thu, 11 Aug 2022 09:48:36 -0700
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Yafang Shao <laoar.shao@...il.com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org, sdf@...gle.com,
haoluo@...gle.com, jolsa@...nel.org, hannes@...xchg.org,
mhocko@...nel.org, shakeelb@...gle.com, songmuchun@...edance.com,
akpm@...ux-foundation.org, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH bpf-next 05/15] bpf: Fix incorrect mem_cgroup_put
On Wed, Aug 10, 2022 at 03:18:30PM +0000, Yafang Shao wrote:
> The memcg may be the root_mem_cgroup, in which case we shouldn't put it.
> So a new helper bpf_map_put_memcg() is introduced to pair with
> bpf_map_get_memcg().
>
> Fixes: 4201d9ab3e42 ("bpf: reparent bpf maps on memcg offlining")
> Cc: Roman Gushchin <roman.gushchin@...ux.dev>
> Cc: Shakeel Butt <shakeelb@...gle.com>
> Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> ---
> kernel/bpf/syscall.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 83c7136..51ab8b1 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -441,6 +441,14 @@ static struct mem_cgroup *bpf_map_get_memcg(const struct bpf_map *map)
> return root_mem_cgroup;
> }
>
> +static void bpf_map_put_memcg(struct mem_cgroup *memcg)
> +{
> + if (mem_cgroup_is_root(memcg))
> + return;
> +
> + mem_cgroup_put(memcg);
> +}
+1 to what Shakeel said. mem_cgroup_put(root_mem_cgroup) is totally valid.
So this change does absolutely nothing.
The fixes tag assumes there is a bug in the existing code. If so, please,
describe the problem and how to reproduce it.
Also, if it's not related to the rest of the patchset, please, send it
separately.
Thanks!
Powered by blists - more mailing lists