* [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
@ 2026-02-24 21:39 Zi Yan
2026-02-25 2:18 ` SeongJae Park
2026-02-25 2:19 ` Zi Yan
0 siblings, 2 replies; 6+ messages in thread
From: Zi Yan @ 2026-02-24 21:39 UTC (permalink / raw)
To: Andrew Morton
Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Kefeng Wang, Zi Yan, linux-mm, linux-kernel, Ron Economos
When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
with side effect inside it is incorrect. Move put_page_testzero() out and
check its return value in VM_WARN_ON. Add __maybe_unused to the return
value for when CONFIG_DEBUG_VM is not set.
Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
Reported-by: Ron Economos <re@w6rz.net>
Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
Alternatively, we can use WARN_ON instead. Let me know.
mm/cma.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mm/cma.c b/mm/cma.c
index 94b5da468a7d..a9fe6e9a9215 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);
+ }
__cma_release_frozen(cma, cmr, pages, count);
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
2026-02-24 21:39 [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release() Zi Yan
@ 2026-02-25 2:18 ` SeongJae Park
2026-02-25 2:20 ` SeongJae Park
2026-02-25 2:19 ` Zi Yan
1 sibling, 1 reply; 6+ messages in thread
From: SeongJae Park @ 2026-02-25 2:18 UTC (permalink / raw)
To: Zi Yan
Cc: SeongJae Park, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Kefeng Wang, linux-mm,
linux-kernel, Ron Economos
On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <ziy@nvidia.com> wrote:
> When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
> with side effect inside it is incorrect. Move put_page_testzero() out and
> check its return value in VM_WARN_ON. Add __maybe_unused to the return
> value for when CONFIG_DEBUG_VM is not set.
>
> Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
> Reported-by: Ron Economos <re@w6rz.net>
> Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
> Signed-off-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
2026-02-25 2:18 ` SeongJae Park
@ 2026-02-25 2:20 ` SeongJae Park
2026-02-25 2:21 ` Zi Yan
0 siblings, 1 reply; 6+ messages in thread
From: SeongJae Park @ 2026-02-25 2:20 UTC (permalink / raw)
To: SeongJae Park
Cc: Zi Yan, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Kefeng Wang, linux-mm,
linux-kernel, Ron Economos
On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <sj@kernel.org> wrote:
> On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <ziy@nvidia.com> wrote:
>
> > When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
> > with side effect inside it is incorrect. Move put_page_testzero() out and
> > check its return value in VM_WARN_ON. Add __maybe_unused to the return
> > value for when CONFIG_DEBUG_VM is not set.
> >
> > Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
> > Reported-by: Ron Economos <re@w6rz.net>
> > Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
I forgot asking this, sorry.
Should we Cc stable@ ?
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
2026-02-25 2:20 ` SeongJae Park
@ 2026-02-25 2:21 ` Zi Yan
2026-02-25 2:41 ` SeongJae Park
0 siblings, 1 reply; 6+ messages in thread
From: Zi Yan @ 2026-02-25 2:21 UTC (permalink / raw)
To: SeongJae Park
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Kefeng Wang, linux-mm,
linux-kernel, Ron Economos
On 24 Feb 2026, at 21:20, SeongJae Park wrote:
> On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <sj@kernel.org> wrote:
>
>> On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <ziy@nvidia.com> wrote:
>>
>>> When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
>>> with side effect inside it is incorrect. Move put_page_testzero() out and
>>> check its return value in VM_WARN_ON. Add __maybe_unused to the return
>>> value for when CONFIG_DEBUG_VM is not set.
>>>
>>> Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
>>> Reported-by: Ron Economos <re@w6rz.net>
>>> Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
>
> I forgot asking this, sorry.
>
> Should we Cc stable@ ?
The commit is just in 7.0-rc1. Nothing is needed for stable.
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
2026-02-25 2:21 ` Zi Yan
@ 2026-02-25 2:41 ` SeongJae Park
0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2026-02-25 2:41 UTC (permalink / raw)
To: Zi Yan
Cc: SeongJae Park, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Kefeng Wang, linux-mm,
linux-kernel, Ron Economos
On Tue, 24 Feb 2026 21:21:55 -0500 Zi Yan <ziy@nvidia.com> wrote:
> On 24 Feb 2026, at 21:20, SeongJae Park wrote:
>
> > On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <sj@kernel.org> wrote:
> >
> >> On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <ziy@nvidia.com> wrote:
> >>
> >>> When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
> >>> with side effect inside it is incorrect. Move put_page_testzero() out and
> >>> check its return value in VM_WARN_ON. Add __maybe_unused to the return
> >>> value for when CONFIG_DEBUG_VM is not set.
> >>>
> >>> Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
> >>> Reported-by: Ron Economos <re@w6rz.net>
> >>> Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
> >
> > I forgot asking this, sorry.
> >
> > Should we Cc stable@ ?
>
> The commit is just in 7.0-rc1. Nothing is needed for stable.
Ack.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
2026-02-24 21:39 [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release() Zi Yan
2026-02-25 2:18 ` SeongJae Park
@ 2026-02-25 2:19 ` Zi Yan
1 sibling, 0 replies; 6+ messages in thread
From: Zi Yan @ 2026-02-25 2:19 UTC (permalink / raw)
To: Andrew Morton
Cc: David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Kefeng Wang, Zi Yan, linux-mm, linux-kernel, Ron Economos
On 24 Feb 2026, at 16:39, Zi Yan wrote:
> When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement
> with side effect inside it is incorrect. Move put_page_testzero() out and
> check its return value in VM_WARN_ON. Add __maybe_unused to the return
> value for when CONFIG_DEBUG_VM is not set.
>
> Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
> Reported-by: Ron Economos <re@w6rz.net>
> Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> Alternatively, we can use WARN_ON instead. Let me know.
>
> mm/cma.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
Kefeng suggested a better solution[1]. Will update this one soon.
[1] https://lore.kernel.org/all/4b219cd0-9391-4edb-83c0-b6a1c60d0790@huawei.com
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-25 2:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-24 21:39 [PATCH] mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release() Zi Yan
2026-02-25 2:18 ` SeongJae Park
2026-02-25 2:20 ` SeongJae Park
2026-02-25 2:21 ` Zi Yan
2026-02-25 2:41 ` SeongJae Park
2026-02-25 2:19 ` Zi Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox