diff options
author | Joe Perches <joe@perches.com> | 2015-06-25 18:02:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 20:00:41 -0400 |
commit | cb426e99ff9225e94fb56bd4c5cfcce8b78a3904 (patch) | |
tree | a7e47c66d32182613e9c9735ae32e48421b24b2e /scripts | |
parent | cbdc281019b8c5c905ef597511471b18e0fd4a15 (diff) |
checkpatch: check for uncommented waitqueue_active()
Linus sayeth:
: Pretty much every single time people use this "if
: (waitqueue_active())" model, it tends to be a bug, because it means
: that there is zero serialization with people who are just about to go
: to sleep. It's fundamentally racy against all the "wait_event()" loops
: that carefully do memory barriers between testing conditions and going
: to sleep, because the memory barriers now don't exist on the waking
: side.
:
: So I'm making a new rule: if you use waitqueue_active(), I want an
: explanation for why it's not racy with the waiter. A big comment about
: the memory ordering, or about higher-level locks that are held by the
: caller, or something.
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c5ec977b9c37..3f2ff26c631c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -4898,6 +4898,13 @@ sub process { | |||
4898 | "memory barrier without comment\n" . $herecurr); | 4898 | "memory barrier without comment\n" . $herecurr); |
4899 | } | 4899 | } |
4900 | } | 4900 | } |
4901 | # check for waitqueue_active without a comment. | ||
4902 | if ($line =~ /\bwaitqueue_active\s*\(/) { | ||
4903 | if (!ctx_has_comment($first_line, $linenr)) { | ||
4904 | WARN("WAITQUEUE_ACTIVE", | ||
4905 | "waitqueue_active without comment\n" . $herecurr); | ||
4906 | } | ||
4907 | } | ||
4901 | # check of hardware specific defines | 4908 | # check of hardware specific defines |
4902 | if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) { | 4909 | if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) { |
4903 | CHK("ARCH_DEFINES", | 4910 | CHK("ARCH_DEFINES", |