mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
Subsystems (2)
PATCH 1/1 mm/cma: move put_page_testzero() out of VM_WARN_ON in cma_release()
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.
---
Alternatively, we can use WARN_ON instead. Let me know.
mm/cma.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
mm/cma.c +5 -2
@@ -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);
Signature · 1 line
2.51.0
Quoted 9 lines · On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <[email protected]> wrote:
When
CONFIG_DEBUG_VMis not set,VM_WARN_ONis a NOP. Putting any statement with side effect inside it is incorrect. Moveput_page_testzero()out and check its return value inVM_WARN_ON. Add__maybe_unusedto the return value for whenCONFIG_DEBUG_VMis not set.Fixes 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")Reported-by Ron Economos <[email protected]>Signed-off-by Zi Yan <[email protected]>
Thanks,
SJ
[...]
Quoted 10 lines · On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <[email protected]> wrote:
Quoted 8 lines · On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <[email protected]> wrote:
When
CONFIG_DEBUG_VMis not set,VM_WARN_ONis a NOP. Putting any statement with side effect inside it is incorrect. Moveput_page_testzero()out and check its return value inVM_WARN_ON. Add__maybe_unusedto the return value for whenCONFIG_DEBUG_VMis not set.Fixes 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")Reported-by Ron Economos <[email protected]>
I forgot asking this, sorry.
Should we Cc stable@ ?
Thanks,
SJ
[...]
Quoted 9 lines · SeongJae Park
Quoted 7 lines · On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <[email protected]> wrote:
Quoted 5 lines · On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <[email protected]> wrote:
When
CONFIG_DEBUG_VMis not set,VM_WARN_ONis a NOP. Putting any statement with side effect inside it is incorrect. Moveput_page_testzero()out and check its return value inVM_WARN_ON. Add__maybe_unusedto the return value for whenCONFIG_DEBUG_VMis not set.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Fixes 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")Reported-by Ron Economos <[email protected]>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
Quoted 15 lines · On Tue, 24 Feb 2026 21:21:55 -0500 Zi Yan <[email protected]> wrote:
Quoted 13 lines · SeongJae Park
Quoted 10 lines · On Tue, 24 Feb 2026 18:18:44 -0800 SeongJae Park <[email protected]> wrote:
Quoted 8 lines · On Tue, 24 Feb 2026 16:39:46 -0500 Zi Yan <[email protected]> wrote:
When
CONFIG_DEBUG_VMis not set,VM_WARN_ONis a NOP. Putting any statement with side effect inside it is incorrect. Moveput_page_testzero()out and check its return value inVM_WARN_ON. Add__maybe_unusedto the return value for whenCONFIG_DEBUG_VMis not set.Fixes 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")Reported-by Ron Economos <[email protected]>
Quoted 5 lines
Quoted 3 lines
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
[...]
Quoted 9 lines · Zi Yan
When
CONFIG_DEBUG_VMis not set,VM_WARN_ONis a NOP. Putting any statement with side effect inside it is incorrect. Moveput_page_testzero()out and check its return value inVM_WARN_ON. Add__maybe_unusedto the return value for whenCONFIG_DEBUG_VMis not set.Fixes 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")Reported-by Ron Economos <[email protected]>Signed-off-by Zi Yan <[email protected]>
Quoted 6 lines
---
Alternatively, we can useWARN_ONinstead. 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/[email protected]
Best Regards,
Yan, Zi