mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 06:34:12 +08:00
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>
This commit is contained in:
parent
61cb48c3f9
commit
90d06a4683
@ -91,6 +91,11 @@ To enable verbose messages set the V= variable, for example:
|
|||||||
|
|
||||||
make coccicheck MODE=report V=1
|
make coccicheck MODE=report V=1
|
||||||
|
|
||||||
|
By default, coccicheck tries to run as parallel as possible. To change
|
||||||
|
the parallelism, set the J= variable. For example, to run across 4 CPUs:
|
||||||
|
|
||||||
|
make coccicheck MODE=report J=4
|
||||||
|
|
||||||
|
|
||||||
Using Coccinelle with a single semantic patch
|
Using Coccinelle with a single semantic patch
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -2,15 +2,24 @@
|
|||||||
|
|
||||||
SPATCH="`which ${SPATCH:=spatch}`"
|
SPATCH="`which ${SPATCH:=spatch}`"
|
||||||
|
|
||||||
|
trap kill_running SIGTERM SIGINT
|
||||||
|
declare -a SPATCH_PID
|
||||||
|
|
||||||
# The verbosity may be set by the environmental parameter V=
|
# The verbosity may be set by the environmental parameter V=
|
||||||
# as for example with 'make V=1 coccicheck'
|
# as for example with 'make V=1 coccicheck'
|
||||||
|
|
||||||
if [ -n "$V" -a "$V" != "0" ]; then
|
if [ -n "$V" -a "$V" != "0" ]; then
|
||||||
VERBOSE=1
|
VERBOSE="$V"
|
||||||
else
|
else
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$J" ]; then
|
||||||
|
NPROC=$(getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROC="$J"
|
||||||
|
fi
|
||||||
|
|
||||||
FLAGS="$SPFLAGS -very_quiet"
|
FLAGS="$SPFLAGS -very_quiet"
|
||||||
|
|
||||||
# spatch only allows include directories with the syntax "-I include"
|
# spatch only allows include directories with the syntax "-I include"
|
||||||
@ -69,12 +78,28 @@ if [ "$ONLINE" = "0" ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
run_cmd() {
|
run_cmd() {
|
||||||
|
local i
|
||||||
if [ $VERBOSE -ne 0 ] ; then
|
if [ $VERBOSE -ne 0 ] ; then
|
||||||
echo "Running: $@"
|
echo "Running ($NPROC in parallel): $@"
|
||||||
fi
|
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 () {
|
coccinelle () {
|
||||||
COCCI="$1"
|
COCCI="$1"
|
||||||
|
Loading…
Reference in New Issue
Block a user