The patch titled Subject: checkpatch: check for nested (un)?likely() calls has been added to the -mm tree. Its filename is checkpatch-check-for-nested-unlikely-calls.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/checkpatch-check-for-nested-unlikely-calls.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-check-for-nested-unlikely-calls.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Denis Efremov <efremov@xxxxxxxxx> Subject: checkpatch: check for nested (un)?likely() calls IS_ERR(), IS_ERR_OR_NULL(), IS_ERR_VALUE() and WARN*() already contain unlikely() optimization internally. Thus, there is no point in calling these functions and defines under likely()/unlikely(). This check is based on the coccinelle rule developed by Enrico Weigelt https://lore.kernel.org/lkml/1559767582-11081-1-git-send-email-info@xxxxxxxxx/ Link: http://lkml.kernel.org/r/20190829165025.15750-1-efremov@xxxxxxxxx Signed-off-by: Denis Efremov <efremov@xxxxxxxxx> Cc: Joe Perches <joe@xxxxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Anton Altaparmakov <anton@xxxxxxxxxx> Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> Cc: Boris Pismenny <borisp@xxxxxxxxxxxx> Cc: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: Denis Efremov <efremov@xxxxxxxxx> Cc: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxx> Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@xxxxxxxxx> Cc: Juergen Gross <jgross@xxxxxxxx> Cc: Leon Romanovsky <leon@xxxxxxxxxx> Cc: Mike Marciniszyn <mike.marciniszyn@xxxxxxxxx> Cc: Rob Clark <robdclark@xxxxxxxxx> Cc: Saeed Mahameed <saeedm@xxxxxxxxxxxx> Cc: Sean Paul <sean@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) --- a/scripts/checkpatch.pl~checkpatch-check-for-nested-unlikely-calls +++ a/scripts/checkpatch.pl @@ -6529,6 +6529,12 @@ sub process { "Using $1 should generally have parentheses around the comparison\n" . $herecurr); } +# nested likely/unlikely calls + if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) { + WARN("LIKELY_MISUSE", + "nested (un)?likely() calls, $1 already uses unlikely() internally\n" . $herecurr); + } + # whine mightly about in_atomic if ($line =~ /\bin_atomic\s*\(/) { if ($realfile =~ m@^drivers/@) { _ Patches currently in -mm which might be from efremov@xxxxxxxxx are checkpatch-check-for-nested-unlikely-calls.patch drm-msm-remove-unlikely-from-warn_on-conditions.patch net-mlx5e-remove-unlikely-from-warn-condition.patch xen-events-remove-unlikely-from-warn-condition.patch fs-remove-unlikely-from-warn_on-condition.patch wimax-i2400m-remove-unlikely-from-warn-condition.patch xfs-remove-unlikely-from-warn_on-condition.patch ib-hfi1-remove-unlikely-from-is_err-condition.patch udp-remove-unlikely-from-is_err-condition.patch ntfs-remove-unlikely-from-is_err-conditions.patch