aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-06-18 17:49:29 -0400
committerMichal Marek <mmarek@suse.cz>2013-07-03 09:26:29 -0400
commit90d06a46835ba73deffb483970fdc2bffa4bb274 (patch)
tree2d0537539192b7db1fe186e50cdad37fc6bd8ec2 /scripts
parent61cb48c3f93adee633f996dd40ff5267fae55b3a (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-xscripts/coccicheck31
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
3SPATCH="`which ${SPATCH:=spatch}`" 3SPATCH="`which ${SPATCH:=spatch}`"
4 4
5trap kill_running SIGTERM SIGINT
6declare -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
8if [ -n "$V" -a "$V" != "0" ]; then 11if [ -n "$V" -a "$V" != "0" ]; then
9 VERBOSE=1 12 VERBOSE="$V"
10else 13else
11 VERBOSE=0 14 VERBOSE=0
12fi 15fi
13 16
17if [ -z "$J" ]; then
18 NPROC=$(getconf _NPROCESSORS_ONLN)
19else
20 NPROC="$J"
21fi
22
14FLAGS="$SPFLAGS -very_quiet" 23FLAGS="$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
69fi 78fi
70 79
71run_cmd() { 80run_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
95kill_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
79coccinelle () { 104coccinelle () {
80 COCCI="$1" 105 COCCI="$1"