mm/debug: optimize once judgment with clang
Subsystems (2)
PATCH 1/1 mm/debug: optimize once judgment with clang
commit 242b872239f6a7deacbc ("include/linux/once_lite.h: fix judgment in WARN_ONCE with clang") helps optimize performance and size under the clang compiler, but the modification is not complete.
Port the modification to VM_WARN_ON_ONCE_PAGE(), VM_WARN_ON_ONCE_FOLIO(), VM_WARN_ON_ONCE_MM() and VM_WARN_ON_ONCE_VMA().
--- include/linux/mmdebug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/mmdebug.h +4 -4
@@ -60,7 +60,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \ dump_page(page, "VM_WARN_ON_ONCE_PAGE(" __stringify(cond)")");\ __warned = true; \WARN_ON (1 ); \
@@ -80,7 +80,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \ dump_page(&folio->page, "VM_WARN_ON_ONCE_FOLIO(" __stringify(cond)")");\ __warned = true; \WARN_ON (1 ); \
@@ -91,7 +91,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \dump_mm (mm); \ __warned = true; \WARN_ON (1 ); \
@@ -102,7 +102,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \dump_vma (vma); \ __warned = true; \WARN_ON (1 ); \
Signature · 1 line
2.53.0
[email protected]
reviewerQuoted 11 lines · Xie Yuanbin
commit
242b872239f6a7deacbc("include/linux/once_lite.h: fix judgment inWARN_ONCEwith clang") helps optimize performance and size under the clang compiler, but the modification is not complete.Port the modification to
VM_WARN_ON_ONCE_PAGE(),VM_WARN_ON_ONCE_FOLIO(),VM_WARN_ON_ONCE_MM()andVM_WARN_ON_ONCE_VMA().Cc Mike Rapoport <[email protected]>Cc David Laight <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Xie Yuanbin <[email protected]>
We don't need to make debug code (hence perf doesn't matter there) more ugly just for clang's sake, I think.
Quoted 44 lines
--- include/linux/mmdebug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)include/linux/mmdebug.h +4
-4@@ -60,7 +60,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \ dump_page(page, "VM_WARN_ON_ONCE_PAGE(" __stringify(cond)")");\ __warned = true; \WARN_ON (1 ); \@@ -80,7 +80,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \ dump_page(&folio->page, "VM_WARN_ON_ONCE_FOLIO(" __stringify(cond)")");\ __warned = true; \WARN_ON (1 ); \@@ -91,7 +91,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \dump_mm (mm); \ __warned = true; \WARN_ON (1 ); \@@ -102,7 +102,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); static bool __section(".data..once") __warned; \int __ret_warn_once = !!(cond); \ \ -if (unlikely (__ret_warn_once && !__warned)) { \ +if (unlikely (__ret_warn_once) &&unlikely (!__warned)) { \dump_vma (vma); \ __warned = true; \WARN_ON (1 ); \