Re: [PATCH bpf-next 05/15] bpf: Fix incorrect mem_cgroup_put

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx>
> Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
> ---
>  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!




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux