diff options
author | Kees Cook <keescook@chromium.org> | 2013-06-18 17:49:29 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2013-07-03 09:26:29 -0400 |
commit | 90d06a46835ba73deffb483970fdc2bffa4bb274 (patch) | |
tree | 2d0537539192b7db1fe186e50cdad37fc6bd8ec2 /scripts | |
parent | 61cb48c3f93adee633f996dd40ff5267fae55b3a (diff) |
coccicheck: span checks across CPUs
This adds parallelism by default to the "coccicheck" target using
spatch's "-max" and "-index" arguments.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/coccicheck | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/scripts/coccicheck b/scripts/coccicheck index 9d8780cdbcd4..ad8e8ffd3c7e 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck | |||
@@ -2,15 +2,24 @@ | |||
2 | 2 | ||
3 | SPATCH="`which ${SPATCH:=spatch}`" | 3 | SPATCH="`which ${SPATCH:=spatch}`" |
4 | 4 | ||
5 | trap kill_running SIGTERM SIGINT | ||
6 | declare -a SPATCH_PID | ||
7 | |||
5 | # The verbosity may be set by the environmental parameter V= | 8 | # The verbosity may be set by the environmental parameter V= |
6 | # as for example with 'make V=1 coccicheck' | 9 | # as for example with 'make V=1 coccicheck' |
7 | 10 | ||
8 | if [ -n "$V" -a "$V" != "0" ]; then | 11 | if [ -n "$V" -a "$V" != "0" ]; then |
9 | VERBOSE=1 | 12 | VERBOSE="$V" |
10 | else | 13 | else |
11 | VERBOSE=0 | 14 | VERBOSE=0 |
12 | fi | 15 | fi |
13 | 16 | ||
17 | if [ -z "$J" ]; then | ||
18 | NPROC=$(getconf _NPROCESSORS_ONLN) | ||
19 | else | ||
20 | NPROC="$J" | ||
21 | fi | ||
22 | |||
14 | FLAGS="$SPFLAGS -very_quiet" | 23 | FLAGS="$SPFLAGS -very_quiet" |
15 | 24 | ||
16 | # spatch only allows include directories with the syntax "-I include" | 25 | # spatch only allows include directories with the syntax "-I include" |
@@ -69,12 +78,28 @@ if [ "$ONLINE" = "0" ] ; then | |||
69 | fi | 78 | fi |
70 | 79 | ||
71 | run_cmd() { | 80 | run_cmd() { |
81 | local i | ||
72 | if [ $VERBOSE -ne 0 ] ; then | 82 | if [ $VERBOSE -ne 0 ] ; then |
73 | echo "Running: $@" | 83 | echo "Running ($NPROC in parallel): $@" |
74 | fi | 84 | fi |
75 | eval $@ | 85 | for i in $(seq 0 $(( NPROC - 1)) ); do |
86 | eval "$@ -max $NPROC -index $i &" | ||
87 | SPATCH_PID[$i]=$! | ||
88 | if [ $VERBOSE -eq 2 ] ; then | ||
89 | echo "${SPATCH_PID[$i]} running" | ||
90 | fi | ||
91 | done | ||
92 | wait | ||
76 | } | 93 | } |
77 | 94 | ||
95 | kill_running() { | ||
96 | for i in $(seq $(( NPROC - 1 )) ); do | ||
97 | if [ $VERBOSE -eq 2 ] ; then | ||
98 | echo "Killing ${SPATCH_PID[$i]}" | ||
99 | fi | ||
100 | kill ${SPATCH_PID[$i]} 2>/dev/null | ||
101 | done | ||
102 | } | ||
78 | 103 | ||
79 | coccinelle () { | 104 | coccinelle () { |
80 | COCCI="$1" | 105 | COCCI="$1" |