linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Zi Yan <ziy@nvidia.com>, Ron Economos <re@w6rz.net>,
	"David Hildenbrand (Arm)" <david@kernel.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<linux-riscv@lists.infradead.org>, <jackmanb@google.com>,
	<jane.chu@oracle.com>, <hannes@cmpxchg.org>,
	<willy@infradead.org>, <muchun.song@linux.dev>,
	<osalvador@suse.de>, <sidhartha.kumar@oracle.com>,
	<vbabka@suse.cz>, <claudiu.beznea.uj@bp.renesas.com>,
	Mark Brown <broonie@kernel.org>, <akpm@linux-foundation.org>,
	<pjw@kernel.org>
Subject: Re: mm: Regression with v7.0-rc1 on RISC-V
Date: Wed, 25 Feb 2026 09:58:35 +0800	[thread overview]
Message-ID: <4b219cd0-9391-4edb-83c0-b6a1c60d0790@huawei.com> (raw)
In-Reply-To: <272A58BA-445F-46F9-8DAB-D82E43D7771A@nvidia.com>



On 2026/2/25 1:29, Zi Yan wrote:
> On 24 Feb 2026, at 12:17, Zi Yan wrote:

...

>>>>
>>>> Thinking again without my computer at hand … isn‘t the call completely optimized out without CONFIG_DEBUG_VM?
>>>>
>>>>
>>>>
>>>> At least that’s what I remember.
>>>
>>> Right. Without CONFIG_DEBUG_VM=y, VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn)))
>>> and is_check_pages_enabled(), which leads to free_page_is_bad()’s
>>> “page dumped because: nonzero _refcount”, are disabled.
>>>
>>> It seems to me that someone else bump the page refcount between
>>> VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn))) and free_page_is_bad().
>>>
>>
>> Merging Ron’s reply from another thread[1]:
>>
>> “Something strange is going on. I enabled CONFIG_DEBUG_VM by itself and
>> the issue went away. Let me try CONFIG_DEBUG_PAGE_REF.”
>>
>> Looks like something is racy, since it is reproducible reliably.
>>
>> [1] https://lore.kernel.org/all/30dd1efc-9bd9-4664-999e-610d181600f9@w6rz.net/
> 
> VM_WARN_ON() is BUILD_BUG_ON_INVALID() when CONFIG_DEBUG_VM is off. Only
> the validity of the expression is checked and no code is generated.
> So that put_page_testzero() becomes a NOP.

Indeed...

> 
> Hi Ron,
> 
> Can you check if the patch below fix the issue without CONFIG_DEBUG_VM?
> 
> diff --git a/mm/cma.c b/mm/cma.c
> index 94b5da468a7d..96be62eb3713 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -1020,8 +1020,11 @@ bool cma_release(struct cma *cma, const struct page *pages,
>   		return false;
> 
>   	pfn = page_to_pfn(pages);
> -	for (i = 0; i < count; i++, pfn++)
> -		VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn)));
> +	for (i = 0; i < count; i++, pfn++) {
> +		int __maybe_unused ret = put_page_testzero(pfn_to_page(pfn));
> +
> +		VM_WARN_ON(!ret);
> +	}

Maybe we only warn once by adding back the original check?

diff --git a/mm/cma.c b/mm/cma.c
index 94b5da468a7d..a73a22d34232 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -1014,14 +1014,17 @@ bool cma_release(struct cma *cma, const struct 
page *pages,
  {
         struct cma_memrange *cmr;
         unsigned long i, pfn;
+       int ret = 0;

         cmr = find_cma_memrange(cma, pages, count);
         if (!cmr)
                 return false;

         pfn = page_to_pfn(pages);
-       for (i = 0; i < count; i++, pfn++)
-               VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn)));
+       for (i = 0; i < count; i++, pfn++) {
+               ret + = put_page_testzero(pfn_to_page(pfn));
+
+       WARN(ret != 0, "%lu pages are still in use!\n", ret);

         __cma_release_frozen(cma, cmr, pages, count);



> 
>   	__cma_release_frozen(cma, cmr, pages, count);
> 
> 
> 
> Best Regards,
> Yan, Zi
> 



  parent reply	other threads:[~2026-02-25  1:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  8:37 Ron Economos
2026-02-24 11:00 ` David Hildenbrand (Arm)
     [not found]   ` <1966378802.577797.1771952827516@app.mailbox.org>
2026-02-24 17:14     ` Zi Yan
2026-02-24 17:17       ` Zi Yan
2026-02-24 17:29         ` Zi Yan
2026-02-24 20:55           ` Ron Economos
2026-02-25  1:58           ` Kefeng Wang [this message]
2026-02-25  2:15             ` Zi Yan
2026-02-24 17:21     ` Mark Brown
2026-02-24 12:58 ` Kefeng Wang
2026-02-24 13:25   ` Ron Economos

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=4b219cd0-9391-4edb-83c0-b6a1c60d0790@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=jane.chu@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    --cc=pjw@kernel.org \
    --cc=re@w6rz.net \
    --cc=sidhartha.kumar@oracle.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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