Re: [PATCH 1/2] mm/slub: preserve no-lock freeing after memcg charge failure

From: Karl Mehltretter

Date: Fri Oct 09 2026 - 03:08:32 EST


On Wed, Oct 07, 2026 at 07:40:17PM +0100, Harry Yoo wrote:
> >
> > Use kfree_nolock() when the allocation flags disallow spinning. This
> > keeps the SLUB object rollback on the no-lock free path. The failed
> > allocation continues to return NULL.
>
> When this happens, the object is not charged by memcg.
>
> The kernel should not invoke memcg_slab_free_hook() (called by
> kfree_nolock()) for a slab object that is not charged by memcg.
>

Agreed. I'll avoid the memcg free hook on charge abort.

One question: kfree_nolock() currently skips init_on_free, while the
existing charge-abort path honors it. Was that intentional? I couldn't
find it discussed in the introduction threads.

If kfree_nolock() should honor init_on_free, I'll include that fix as
the first patch in the revised series. The charge-abort fix will then
reuse the shared initialization helper.

Karl