aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/coccinelle.txt5
-rwxr-xr-xscripts/coccicheck31
2 files changed, 33 insertions, 3 deletions
diff --git a/Documentation/coccinelle.txt b/Documentation/coccinelle.txt
index 18de78599dd4..408439d07889 100644
--- a/Documentation/coccinelle.txt
+++ b/Documentation/coccinelle.txt
@@ -91,6 +91,11 @@ To enable verbose messages set the V= variable, for example:
91 91
92 make coccicheck MODE=report V=1 92 make coccicheck MODE=report V=1
93 93
94By default, coccicheck tries to run as parallel as possible. To change
95the parallelism, set the J= variable. For example, to run across 4 CPUs:
96
97 make coccicheck MODE=report J=4
98
94 99
95 Using Coccinelle with a single semantic patch 100 Using Coccinelle with a single semantic patch
96~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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"