linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
	 muchun.song@linux.dev, akpm@linux-foundation.org,
	cgroups@vger.kernel.org,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH 2/2] memcg/hugetlb: Deprecate hugetlb memcg try-commit-cancel charging
Date: Thu, 7 Nov 2024 10:07:01 -0500	[thread overview]
Message-ID: <CAN+CAwPkcLgnrd4qVj-BAv_KYTakTsp3UwmBqs==vGdfaZan=A@mail.gmail.com> (raw)
In-Reply-To: <o7dpwewfztqpkidrhvpdm57ikid4yswygag5gkjplfwdfkl54l@bs6oh2t4jp7z>

On Wed, Nov 6, 2024 at 6:50 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> >
> > -int mem_cgroup_hugetlb_try_charge(struct mem_cgroup *memcg, gfp_t gfp,
> > -             long nr_pages);
> > +int mem_cgroup_charge_hugetlb(struct folio *folio, gfp_t gfp);
>
> Please cleanup mem_cgroup_cancel_charge() and mem_cgroup_commit_charge()
> as well as there will be no users after this patch.
>
> >       /*
> >        * Processes that did not create the mapping will have no
> > @@ -3056,6 +3044,12 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
> >               /* Fall through */
> >       }
> >
> > +     ret = mem_cgroup_charge_hugetlb(folio, gfp);
>
> You can not call this with hugetlb_lock held.
>
> >  {
> > -     /*
> > -      * If hugetlb memcg charging is not enabled, do not fail hugetlb allocation,
> > -      * but do not attempt to commit charge later (or cancel on error) either.
> > -      */
> > -     if (mem_cgroup_disabled() || !memcg ||
> > -             !cgroup_subsys_on_dfl(memory_cgrp_subsys) || !memcg_accounts_hugetlb())
> > +     struct mem_cgroup *memcg = get_mem_cgroup_from_current();
>
> Leaking the above reference in error paths.
>

Hello Shakeel,

Thank you for your feedback on this patch. I will implement the changes you
mentioned in both patches. As for the comment on the other patch about
replacing the accounting check in mem_cgroup_hugetlb_try_charge,
I think this makes more sense. I will move the code from this patch to
the first.

Thank you again, have a great day!
Joshua


  reply	other threads:[~2024-11-07 15:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 22:14 [PATCH 0/2] memcg/hugetlb: Rework memcg hugetlb charging Joshua Hahn
2024-11-06 22:14 ` [PATCH 1/2] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
2024-11-06 23:17   ` Shakeel Butt
2024-11-07  0:21   ` SeongJae Park
2024-11-07 15:07     ` Joshua Hahn
2024-11-06 22:14 ` [PATCH 2/2] memcg/hugetlb: Deprecate hugetlb memcg try-commit-cancel charging Joshua Hahn
2024-11-06 23:50   ` Shakeel Butt
2024-11-07 15:07     ` Joshua Hahn [this message]
2024-11-07 18:27     ` Joshua Hahn
2024-11-07 18:58       ` Shakeel Butt
2024-11-07 19:28         ` Joshua Hahn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN+CAwPkcLgnrd4qVj-BAv_KYTakTsp3UwmBqs==vGdfaZan=A@mail.gmail.com' \
    --to=joshua.hahnjy@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox