mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Harry Yoo <harry.yoo@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>, Hao Ge <hao.ge@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Hao Ge <gehao@kylinos.cn>
Subject: Re: [PATCH v5] slab: reset obj_ext when it is not actually valid during freeing
Date: Thu, 16 Oct 2025 15:18:36 +0200	[thread overview]
Message-ID: <d64db373-cb98-4142-ba44-1aa5ccbdcb45@suse.cz> (raw)
In-Reply-To: <aPDud4tUzZ_NxE_R@hyeyoo>

On 10/16/25 15:09, Harry Yoo wrote:
>> ----8<----
>> From 8151384e5baf34db5812ed51e2e463796ab6e973 Mon Sep 17 00:00:00 2001
>> From: Hao Ge <gehao@kylinos.cn>
>> Date: Wed, 15 Oct 2025 22:16:42 +0800
>> Subject: [PATCH] slab: reset slab->obj_ext when freeing and it is
>>  OBJEXTS_ALLOC_FAIL
>> 
>> If obj_exts allocation failed, slab->obj_exts is set to OBJEXTS_ALLOC_FAIL,
>> But we do not clear it when freeing the slab. Since OBJEXTS_ALLOC_FAIL and
>> MEMCG_DATA_OBJEXTS currently share the same bit position, during the
>> release of the associated folio,
> 
>> a VM_BUG_ON_FOLIO() check in
>> folio_memcg_kmem() is triggered because it was mistakenly assumed that
>> a valid folio->memcg_data was not cleared before freeing the folio.
> 
> nit: maybe this can be massaged as "a VM_BUG_ON_FOLIO() check in folio_memcg_kmem()
> is triggered because the OBJEXTS_ALLOC_FAIL flag was not cleared,
> causing it to be interpreted as a kmem folio (non-slab) with
> MEMCG_OBJEXTS_DATA flag set, which is invalid because MEMCG_OBJEXTS_DATA
> is supposed to be set only on slabs."

Thanks, applied

>> Another problem that predates sharing the OBJEXTS_ALLOC_FAIL and
>> MEMCG_DATA_OBJEXTS bits is that on configurations with
>> is_check_pages_enabled(), the non-cleared bit in page->memcg_data will
>> trigger a free_page_is_bad() failure "page still charged to cgroup"
>>
>> When freeing a slab, we clear slab->obj_exts if the obj_ext array has
>> been successfully allocated. So let's clear it also when the allocation
>> has failed.
>> 
>> Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations")
>> Link: https://lore.kernel.org/all/20251015141642.700170-1-hao.ge@linux.dev/
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Hao Ge <gehao@kylinos.cn>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
> 
> Looks good to me,
> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>

and this too.


      reply	other threads:[~2025-10-16 13:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 14:16 Hao Ge
2025-10-15 16:29 ` Suren Baghdasaryan
2025-10-15 16:37   ` Vlastimil Babka
2025-10-15 16:51     ` Suren Baghdasaryan
2025-10-15 16:44   ` Vlastimil Babka
2025-10-15 16:52     ` Suren Baghdasaryan
2025-10-16 13:09     ` Harry Yoo
2025-10-16 13:18       ` Vlastimil Babka [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=d64db373-cb98-4142-ba44-1aa5ccbdcb45@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=cl@gentwo.org \
    --cc=gehao@kylinos.cn \
    --cc=hao.ge@linux.dev \
    --cc=harry.yoo@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    /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®