Skip to content

Commit 6795fc8

Browse files
committed
Merge branch 'jk/cocci-batch'
Optionally "make coccicheck" can feed multiple source files to spatch, gaining performance while spending more memory. * jk/cocci-batch: coccicheck: make batch size of 0 mean "unlimited" coccicheck: optionally batch spatch invocations
2 parents 82dca95 + bcb4edf commit 6795fc8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,11 @@ PTHREAD_CFLAGS =
11711171
SPARSE_FLAGS ?=
11721172
SP_EXTRA_FLAGS =
11731173

1174-
# For the 'coccicheck' target
1174+
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
1175+
# usually result in less CPU usage at the cost of higher peak memory.
1176+
# Setting it to 0 will feed all files in a single spatch invocation.
11751177
SPATCH_FLAGS = --all-includes --patch .
1178+
SPATCH_BATCH_SIZE = 1
11761179

11771180
include config.mak.uname
11781181
-include config.mak.autogen
@@ -2807,12 +2810,14 @@ endif
28072810

28082811
%.cocci.patch: %.cocci $(COCCI_SOURCES)
28092812
@echo ' ' SPATCH $<; \
2810-
ret=0; \
2811-
for f in $(COCCI_SOURCES); do \
2812-
$(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \
2813-
{ ret=$$?; break; }; \
2814-
done >$@+ 2>$@.log; \
2815-
if test $$ret != 0; \
2813+
if test $(SPATCH_BATCH_SIZE) = 0; then \
2814+
limit=; \
2815+
else \
2816+
limit='-n $(SPATCH_BATCH_SIZE)'; \
2817+
fi; \
2818+
if ! echo $(COCCI_SOURCES) | xargs $$limit \
2819+
$(SPATCH) --sp-file $< $(SPATCH_FLAGS) \
2820+
>$@+ 2>$@.log; \
28162821
then \
28172822
cat $@.log; \
28182823
exit 1; \

0 commit comments

Comments
 (0)