From: SeongJae Park <sj@kernel.org>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: SeongJae Park <sj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-mm@kvack.org,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] memcg: damon: get memcg reference before access
Date: Wed, 24 Dec 2025 07:37:30 -0800 [thread overview]
Message-ID: <20251224153731.69411-1-sj@kernel.org> (raw)
In-Reply-To: <peusxpenpbjdnhr5nkgvqtiuuofmc6khsxsxxvj3k3eyledkft@kgvgid53zbbg>
On Tue, 23 Dec 2025 23:51:55 -0800 Shakeel Butt <shakeel.butt@linux.dev> wrote:
> On Tue, Dec 23, 2025 at 09:21:47PM -0800, SeongJae Park wrote:
> > On Tue, 23 Dec 2025 19:45:27 -0800 Shakeel Butt <shakeel.butt@linux.dev> wrote:
[...]
> > > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > > index 4ad5f290d382..89982e0229f0 100644
> > > --- a/mm/damon/core.c
> > > +++ b/mm/damon/core.c
> > > @@ -2051,13 +2051,15 @@ static unsigned long damos_get_node_memcg_used_bp(
> > >
> > > rcu_read_lock();
> > > memcg = mem_cgroup_from_id(goal->memcg_id);
> > > - rcu_read_unlock();
> > > - if (!memcg) {
> > > + if (!memcg || !mem_cgroup_tryget(memcg)) {
> >
> > For this part, I was thinking '!memcg' part seems not technically needed
> > because mem_cgroup_tryget() does the check. But I think that's just trivial,
> > so this also looks good to me.
> >
>
> Hmm !memcg check inside mem_cgroup_tryget() is a weird one. It makes
> mem_cgroup_tryget() to return true for NULL parameter. We can not use
> mem_cgroup_tryget() as is alone here.
Oh, you're right. I should have read it more carefully. Thank you for
enlightening me :)
Thanks,
SJ
[...]
prev parent reply other threads:[~2025-12-24 15:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 3:45 Shakeel Butt
2025-12-24 5:21 ` SeongJae Park
2025-12-24 7:51 ` Shakeel Butt
2025-12-24 15:37 ` SeongJae Park [this message]
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=20251224153731.69411-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=damon@lists.linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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