From: Harry Yoo <harry@kernel.org>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Alexei Starovoitov <ast@kernel.org>, Hao Li <hao.li@linux.dev>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
kernel-team@meta.com, cgroups@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH for-next-fixes v2 1/5] mm/memcontrol: defer obj_cgroup_release() to irq_work
Date: Wed, 4 Nov 2026 12:00:01 +0000 [thread overview]
Message-ID: <ausdFvI5XyDNrrR0@thinkstation> (raw)
In-Reply-To: <b181dade-ffa1-4b58-9927-8a2429a59ac1@kernel.org>
On Wed, Nov 04, 2026 at 12:02:55PM +0100, Vlastimil Babka (SUSE) wrote:
> On 11/3/26 15:47, Harry Yoo (Meta) wrote:
> > obj_cgroup_put() can be called from any context.
> > __memcg_slab_free_hook() puts a per-object reference on
> > every accounted free, and draining a per-cpu objcg stock slot puts
> > the cached reference. When it drops the last reference,
> > obj_cgroup_release() takes objcg_lock, frees percpu memory
> > (pcpu_lock, via percpu_ref_exit()) and calls kfree_rcu(). Each of
> > these can deadlock when the current context interrupted a holder of
> > the respective lock.
> >
> > Defer the release to irq_work. llist_add() and irq_work_queue() are
> > NMI-safe, and the irq_work runs in a context where acquiring a
> > spinlock is allowed.
> >
> > Add a separate llist_node instead of reusing the list/rcu union
> > because the list stays linked until the deferred release. struct
> > obj_cgroup grows from 56 to 64 bytes, but both are served from
> > kmalloc-64, so no memory is additionally consumed.
> >
> > Closes: https://lore.kernel.org/20261001044056.75079-3-kmehltretter@gmail.com
> > Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
> > Signed-off-by: Harry Yoo (Meta) <harry@kernel.org>
>
> I guess releasing objcg isn't too frequent, so it won't matter that we make
> all cases use the defered work
Yeah, objcg release itself uses a global spinlock (objcg_lock),
so I think this is fine.
> instead of somehow trying to do that only in
> contexts that would really need it.
... and this is not easy as the percpu refcount callback
doesn't know the current context.
> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Thanks!
> since memcg tree will be used from the next cycle, we can just keep this as
> part of the series in the slab tree?
Ah, I see. Will do.
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-11-04 12:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 14:47 [PATCH for-next-fixes v2 0/5] memcg,slab: kmalloc_nolock() fixes Harry Yoo (Meta)
2026-11-03 14:47 ` [PATCH for-next-fixes v2 1/5] mm/memcontrol: defer obj_cgroup_release() to irq_work Harry Yoo (Meta)
2026-11-04 11:02 ` Vlastimil Babka (SUSE)
2026-11-04 12:00 ` Harry Yoo [this message]
2026-11-03 14:47 ` [PATCH for-next-fixes v2 2/5] mm/slab: handle allow_spin in slab_free_hook() instead of open coding Harry Yoo (Meta)
2026-11-04 13:54 ` Vlastimil Babka (SUSE)
2026-11-03 14:47 ` [PATCH for-next-fixes v2 3/5] mm/slab: call debug_locks and KCSAN checks in kfree_nolock() Harry Yoo (Meta)
2026-11-03 14:47 ` [PATCH for-next-fixes v2 4/5] mm/slab: fix a deadlock in memcg_alloc_abort_single() Harry Yoo (Meta)
2026-11-03 18:40 ` Alexei Starovoitov
2026-11-03 20:21 ` Harry Yoo
2026-11-03 21:11 ` Alexei Starovoitov
2026-11-04 15:35 ` Vlastimil Babka (SUSE)
2026-11-04 16:46 ` Alexei Starovoitov
2026-11-03 14:47 ` [PATCH for-next-fixes v2 5/5] mm/slab: serialize deferred_work_barrier() Harry Yoo (Meta)
2026-11-04 16:24 ` Vlastimil Babka (SUSE)
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=ausdFvI5XyDNrrR0@thinkstation \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=cgroups@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=clrkwllms@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=vbabka@kernel.org \
/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
all inboxes | Powered by JetHome®