diff options
author | Kees Cook <keescook@chromium.org> | 2013-06-18 14:49:29 -0700 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2013-07-03 15:26:29 +0200 |
commit | 90d06a46835ba73deffb483970fdc2bffa4bb274 (patch) | |
tree | 2d0537539192b7db1fe186e50cdad37fc6bd8ec2 /scripts/coccicheck | |
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/coccicheck')
-rwxr-xr-x | scripts/coccicheck | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/scripts/coccicheck b/scripts/coccicheck index 9d8780cdbcd..ad8e8ffd3c7 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -2,15 +2,24 @@ SPATCH="`which ${SPATCH:=spatch}`" +trap kill_running SIGTERM SIGINT +declare -a SPATCH_PID + # The verbosity may be set by the environmental parameter V= # as for example with 'make V=1 coccicheck' if [ -n "$V" -a "$V" != "0" ]; then - VERBOSE=1 + VERBOSE="$V" else VERBOSE=0 fi +if [ -z "$J" ]; then + NPROC=$(getconf _NPROCESSORS_ONLN) +else + NPROC="$J" +fi + FLAGS="$SPFLAGS -very_quiet" # spatch only allows include directories with the syntax "-I include" @@ -69,12 +78,28 @@ if [ "$ONLINE" = "0" ] ; then fi run_cmd() { + local i if [ $VERBOSE -ne 0 ] ; then - echo "Running: $@" + echo "Running ($NPROC in parallel): $@" fi - eval $@ + for i in $(seq 0 $(( NPROC - 1)) ); do + eval "$@ -max $NPROC -index $i &" + SPATCH_PID[$i]=$! + if [ $VERBOSE -eq 2 ] ; then + echo "${SPATCH_PID[$i]} running" + fi + done + wait } +kill_running() { + for i in $(seq $(( NPROC - 1 )) ); do + if [ $VERBOSE -eq 2 ] ; then + echo "Killing ${SPATCH_PID[$i]}" + fi + kill ${SPATCH_PID[$i]} 2>/dev/null + done +} coccinelle () { COCCI="$1" |