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

From
Yafang Shao <hidden>
Date
2022-08-11 02:49:52
Also in
bpf, linux-mm
Reply to
Shakeel Butt, 2022-08-10
On Thu, Aug 11, 2022 at 1:07 AM Shakeel Butt [off-list ref] wrote:
On Wed, Aug 10, 2022 at 03:18:30PM +0000, Yafang Shao wrote:
quoted
The memcg may be the root_mem_cgroup, in which case we shouldn't put it.
No, it is ok to put root_mem_cgroup. css_put already handles the root
cgroups.
Ah, this commit log doesn't describe the issue clearly. I should improve it.
The issue is that in bpf_map_get_memcg() it doesn't get the objcg if
map->objcg is NULL (that can happen if the map belongs to the root
memcg), so we shouldn't put the objcg if map->objcg is NULL neither in
bpf_map_put_memcg().
Maybe the change below would be more reasonable ?

+static void bpf_map_put_memcg(const struct bpf_map *map, struct
mem_cgroup *memcg)
+{
+       if (map->objcg)
+           mem_cgroup_put(memcg);
+}

-- 
Regards
Yafang
Thread (33 messages) 33 messages, 5 authors, last reply 2022-08-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help