Re: [External] [PATCH 2/3] mm: Charge active memcg when no mm is set

From: Shakeel Butt
Date: Mon Mar 29 2021 - 17:00:35 EST


On Mon, Mar 29, 2021 at 9:13 AM Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
>
> On Mon, Mar 29, 2021 at 10:49 PM Dan Schatzberg
> <schatzberg.dan@xxxxxxxxx> wrote:
[...]
>
> Since remote memcg must hold a reference, we do not
> need to do something like get_active_memcg() does.
> Just use css_get to obtain a ref, it is simpler. Just
> Like below.
>
> + if (unlikely(!mm)) {
> + memcg = active_memcg();
> + if (unlikely(memcg)) {
> + /* remote memcg must hold a ref. */
> + css_get(memcg);
> + return memcg;
> + }
>

I second Muchun's suggestion.