[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6172ddd8c3f59_82a7f208e4@john-XPS-13-9370.notmuch>
Date: Fri, 22 Oct 2021 08:50:48 -0700
From: John Fastabend <john.fastabend@...il.com>
To: Roman Gushchin <guro@...com>,
Michal Koutný <mkoutny@...e.com>
Cc: quanyang.wang@...driver.com, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Johannes Weiner <hannes@...xchg.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Jens Axboe <axboe@...nel.dk>, Ming Lei <ming.lei@...hat.com>,
cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH] cgroup: fix memory leak caused by missing
cgroup_bpf_offline
Roman Gushchin wrote:
> On Mon, Oct 11, 2021 at 06:21:28PM +0200, Michal Koutny wrote:
> > Hello.
> >
> > On Thu, Oct 07, 2021 at 08:16:03PM +0800, quanyang.wang@...driver.com wrote:
> > > This is because that root_cgrp->bpf.refcnt.data is allocated by the
> > > function percpu_ref_init in cgroup_bpf_inherit which is called by
> > > cgroup_setup_root when mounting, but not freed along with root_cgrp
> > > when umounting.
> >
> > Good catch!
>
> +1
>
> >
> > > Adding cgroup_bpf_offline which calls percpu_ref_kill to
> > > cgroup_kill_sb can free root_cgrp->bpf.refcnt.data in umount path.
> >
> > That is sensible.
> >
> > > Fixes: 2b0d3d3e4fcfb ("percpu_ref: reduce memory footprint of percpu_ref in fast path")
> >
> > Why this Fixes:? Is the leak absent before the percpu_ref refactoring?
>
> I agree, the "fixes" tag looks dubious to me.
>
> > I guess the embedded data are free'd together with cgroup. Makes me
> > wonder why struct cgroup_bpf has a separate percpu_ref counter from
> > struct cgroup...
>
> This is because a cgroup can stay a long time (sometimes effectively forever)
> in a dying state, so we want to release bpf structures earlier.
>
> Thanks!
Other than whitespace LGTM.
Acked-by: John Fastabend <john.fastabend@...il.com>
Powered by blists - more mailing lists