coccinelle: mini_lock: improve performance when searching loops
authorSang-Heon Jeon <ekffu200098@gmail.com>
Mon, 27 Jul 2026 13:52:44 +0000 (22:52 +0900)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sun, 23 Aug 2026 20:12:10 +0000 (22:12 +0200)
commita53cbd149844cbde80f6adfc7f4233b8f230f664
tree3afbe34474251cb8de55173f0d5d34db40fd9935
parentb64acacd5429ff3fe7c38cb3cf959bbd3a9fb30f
coccinelle: mini_lock: improve performance when searching loops

The 'looped' rule collects the returns inside a for loop to
prevent 'err' from reporting them. It searches every for loop in
the file, and on files with large loop bodies the search explodes.

For example, kernel/bpf/verifier.c runs for over 200 seconds,
almost entirely in 'looped' according to --profile. Since the
kernel .cocciconfig sets a 200 second timeout, coccicheck silently
skips the file.

To avoid this, collect the candidate returns first, so that
'looped' checks only those positions. 'err' then excludes what
'looped' found.

Every return that 'err' can report is also a candidate, so the
same returns are excluded as before and the output does not change.
A report-mode run over every .c file in the tree produces identical
output.

So verifier.c now finishes well within the timeout, in a few
seconds.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
scripts/coccinelle/locks/mini_lock.cocci