Skip to content

Commit f4073b0

Browse files
committed
checkpatch: check for __smp outside barrier.h
Introduction of __smp barriers cleans up a bunch of duplicate code, but it gives people an additional handle onto a "new" set of barriers - just because they're prefixed with __* unfortunately doesn't stop anyone from using it (as happened with other arch stuff before.) Add a checkpatch test so it will trigger a warning. Reported-by: Russell King <linux@arm.linux.org.uk> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Julian Calaby <julian.calaby@gmail.com> Acked-by: Joe Perches <joe@perches.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
1 parent 402c255 commit f4073b0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scripts/checkpatch.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5143,6 +5143,16 @@ sub process {
51435143
}
51445144
}
51455145

5146+
my $underscore_smp_barriers = qr{__smp_(?:$barrier_stems)}x;
5147+
5148+
if ($realfile !~ m@^include/asm-generic/@ &&
5149+
$realfile !~ m@/barrier\.h$@ &&
5150+
$line =~ m/\b(?:$underscore_smp_barriers)\s*\(/ &&
5151+
$line !~ m/^.\s*\#\s*define\s+(?:$underscore_smp_barriers)\s*\(/) {
5152+
WARN("MEMORY_BARRIER",
5153+
"__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr);
5154+
}
5155+
51465156
# check for waitqueue_active without a comment.
51475157
if ($line =~ /\bwaitqueue_active\s*\(/) {
51485158
if (!ctx_has_comment($first_line, $linenr)) {

0 commit comments

Comments
 (0)