git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 00/11] cocci: make "incremental" possible + a ccache-like tool

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 17, 2022, 18:36 UTC
Message-ID
<221017.86czaqjnhy.gmgdl@evledraar.gmail.com>
In-Reply-To
<Y02V0E0JRSNa4Sb9@coredump.intra.peff.net>
On Mon, Oct 17 2022, Jeff King wrote:
Show 26 quoted lines
> On Fri, Oct 14, 2022 at 05:31:16PM +0200, Ævar Arnfjörð Bjarmason wrote:
>
>> The big change in this belated v3 is that we now run against a
>> concatenated version of all our *.cocci files. This is something I
>> discussed with Jeff King at Git Merge, after having confirmed the
>> viability of that approach on the cocci mailing list.
>
> Is that safe? The last time it was brought up on this list (AFAIK) was
> in:
>
>   https://lore.kernel.org/git/alpine.DEB.2.20.1808030755350.2446@hadrien/
>
> where Julia said:
>
>   I'm surprised that the above cat command would work.  Semantic patch rules
>   have names, and Coccinelle will not be happy isf two rules have the same
>   name.  Some may also have variables declared in initializers, although
>   perhaps the ones in the kernel don't do this.  Causing these variables to
>   be shared would not have a good effect.
>
>   Putting everything together can also go counter to the optimizations that
>   Coccinelle provides. [...]
>
> Maybe we don't do any of the things that could trigger problems in our
> spatch rules. But it's not clear to me what we're risking. Do you have a
> link for further discussion?

I think 10/11's commit message should answer your question: https://lore.kernel.org/git/patch-v3-10.11-52177ea2a68-20221014T152553Z-avarab@gmail.com/

The tl;dr is that it's not safe in the general case, as noted in the post you & the more recent one I linked to in 10/11.

So, with this series doing:
	perl -pi -e 's/swap/preincrement/g' contrib/coccinelle/swap.cocci

Will error it if you run it with "SPATCH_CONCAT_COCCI=Y", but not with "SPATCH_CONCAT_COCCI=", as the rule names conflict in the ALL.cocci.

But as 10/11 notes we can just avoid this by not picking conflicting names, which doesn't seem like an undue burden.

AFAICT we have 5 named rules, and seemingly only 1/4 actually needs its
name, the rest are apparently only using it for self-documentation, and
we could either remove the name, or accomplish the same with a comment:
	
	diff --git a/contrib/coccinelle/hashmap.cocci b/contrib/coccinelle/hashmap.cocci
	index d69e120ccff..c5dbb4557b5 100644
	--- a/contrib/coccinelle/hashmap.cocci
	+++ b/contrib/coccinelle/hashmap.cocci
	@@ -1,4 +1,4 @@
	-@ hashmap_entry_init_usage @
	+@@
	 expression E;
	 struct hashmap_entry HME;
	 @@
	diff --git a/contrib/coccinelle/preincr.cocci b/contrib/coccinelle/preincr.cocci
	index 7fe1e8d2d9a..ae42cb07302 100644
	--- a/contrib/coccinelle/preincr.cocci
	+++ b/contrib/coccinelle/preincr.cocci
	@@ -1,4 +1,4 @@
	-@ preincrement @
	+@@
	 identifier i;
	 @@
	 - ++i > 1
	diff --git a/contrib/coccinelle/strbuf.cocci b/contrib/coccinelle/strbuf.cocci
	index 0970d98ad72..5f06105df6d 100644
	--- a/contrib/coccinelle/strbuf.cocci
	+++ b/contrib/coccinelle/strbuf.cocci
	@@ -1,4 +1,4 @@
	-@ strbuf_addf_with_format_only @
	+@@
	 expression E;
	 constant fmt !~ "%";
	 @@
	diff --git a/contrib/coccinelle/swap.cocci b/contrib/coccinelle/swap.cocci
	index a0934d1fdaf..522177afb66 100644
	--- a/contrib/coccinelle/swap.cocci
	+++ b/contrib/coccinelle/swap.cocci
	@@ -1,4 +1,4 @@
	-@ swap_with_declaration @
	+@@
	 type T;
	 identifier tmp;
	 T a, b;
	
Previous: Jeff KingNext: Junio C Hamano
Message 37 of 72 in “cocci: make "incremental" possible + a ccache-like tool”
  1. 0/5 cocci: make "incremental" possible + a ccache-like toolÆvar Arnfjörð Bjarmason, Aug 25, 2022
  2. 1/5 Makefile: add ability to TAB-complete cocci *.patch rulesÆvar Arnfjörð Bjarmason, Aug 25, 2022
  3. 2/5 Makefile: have "coccicheck" re-run if flags changeÆvar Arnfjörð Bjarmason, Aug 25, 2022
  4. SZEDER GáborAug 25, 2022
  5. 4/5 cocci: make incremental compilation even fasterÆvar Arnfjörð Bjarmason, Aug 25, 2022
  6. 3/5 cocci: make "coccicheck" rule incrementalÆvar Arnfjörð Bjarmason, Aug 25, 2022
  7. SZEDER GáborAug 25, 2022
  8. Ævar Arnfjörð BjarmasonAug 25, 2022
  9. SZEDER GáborAug 26, 2022
  10. 5/5 spatchcache: add a ccache-alike for "spatch"Ævar Arnfjörð Bjarmason, Aug 25, 2022
  11. 0/9 cocci: make "incremental" possible + a ccache-like toolÆvar Arnfjörð Bjarmason, Aug 31, 2022
  12. 2/9 Makefile: add ability to TAB-complete cocci *.patch rulesÆvar Arnfjörð Bjarmason, Aug 31, 2022
  13. 3/9 Makefile: have "coccicheck" re-run if flags changeÆvar Arnfjörð Bjarmason, Aug 31, 2022
  14. 1/9 cocci rules: remove unused "F" metavariable from pending ruleÆvar Arnfjörð Bjarmason, Aug 31, 2022
  15. 4/9 Makefile: split off SPATCH_BATCH_SIZE comment from "cocci" headingÆvar Arnfjörð Bjarmason, Aug 31, 2022
  16. 5/9 cocci: split off include-less "tests" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Aug 31, 2022
  17. 6/9 cocci: split off "--all-includes" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Aug 31, 2022
  18. 8/9 cocci: optimistically use COMPUTE_HEADER_DEPENDENCIESÆvar Arnfjörð Bjarmason, Aug 31, 2022
  19. 7/9 cocci: make "coccicheck" rule incrementalÆvar Arnfjörð Bjarmason, Aug 31, 2022
  20. SZEDER GáborSep 1, 2022
  21. Ævar Arnfjörð BjarmasonSep 1, 2022
  22. 9/9 spatchcache: add a ccache-alike for "spatch"Ævar Arnfjörð Bjarmason, Aug 31, 2022
  23. 00/11 cocci: make "incremental" possible + a ccache-like toolÆvar Arnfjörð Bjarmason, Oct 14, 2022
  24. 01/11 Makefile + shared.mak: rename and indent $(QUIET_SPATCH_T)Ævar Arnfjörð Bjarmason, Oct 14, 2022
  25. 02/11 cocci rules: remove unused "F" metavariable from pending ruleÆvar Arnfjörð Bjarmason, Oct 14, 2022
  26. 05/11 Makefile: split off SPATCH_BATCH_SIZE comment from "cocci" headingÆvar Arnfjörð Bjarmason, Oct 14, 2022
  27. Taylor BlauOct 14, 2022
  28. 03/11 Makefile: add ability to TAB-complete cocci *.patch rulesÆvar Arnfjörð Bjarmason, Oct 14, 2022
  29. 07/11 cocci: split off "--all-includes" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Oct 14, 2022
  30. 04/11 Makefile: have "coccicheck" re-run if flags changeÆvar Arnfjörð Bjarmason, Oct 14, 2022
  31. 06/11 cocci: split off include-less "tests" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Oct 14, 2022
  32. 08/11 cocci: make "coccicheck" rule incrementalÆvar Arnfjörð Bjarmason, Oct 14, 2022
  33. 09/11 cocci: optimistically use COMPUTE_HEADER_DEPENDENCIESÆvar Arnfjörð Bjarmason, Oct 14, 2022
  34. 11/11 spatchcache: add a ccache-alike for "spatch"Ævar Arnfjörð Bjarmason, Oct 14, 2022
  35. 10/11 cocci: run against a generated ALL.cocciÆvar Arnfjörð Bjarmason, Oct 14, 2022
  36. Jeff KingOct 17, 2022
  37. Ævar Arnfjörð BjarmasonOct 17, 2022
  38. Junio C HamanoOct 17, 2022
  39. Jeff KingOct 17, 2022
  40. 00/12 cocci: make "incremental" possible + a ccache-like toolÆvar Arnfjörð Bjarmason, Oct 26, 2022
  41. 01/12 Makefile + shared.mak: rename and indent $(QUIET_SPATCH_T)Ævar Arnfjörð Bjarmason, Oct 26, 2022
  42. 02/12 cocci rules: remove unused "F" metavariable from pending ruleÆvar Arnfjörð Bjarmason, Oct 26, 2022
  43. 03/12 Makefile: add ability to TAB-complete cocci *.patch rulesÆvar Arnfjörð Bjarmason, Oct 26, 2022
  44. 04/12 Makefile: have "coccicheck" re-run if flags changeÆvar Arnfjörð Bjarmason, Oct 26, 2022
  45. 05/12 Makefile: split off SPATCH_BATCH_SIZE comment from "cocci" headingÆvar Arnfjörð Bjarmason, Oct 26, 2022
  46. 07/12 cocci: split off "--all-includes" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Oct 26, 2022
  47. 06/12 cocci: split off include-less "tests" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Oct 26, 2022
  48. 08/12 cocci: make "coccicheck" rule incrementalÆvar Arnfjörð Bjarmason, Oct 26, 2022
  49. 09/12 cocci: optimistically use COMPUTE_HEADER_DEPENDENCIESÆvar Arnfjörð Bjarmason, Oct 26, 2022
  50. 10/12 cocci rules: remove <id>'s from rules that don't need themÆvar Arnfjörð Bjarmason, Oct 26, 2022
  51. 11/12 cocci: run against a generated ALL.cocciÆvar Arnfjörð Bjarmason, Oct 26, 2022
  52. SZEDER GáborOct 28, 2022
  53. 12/12 spatchcache: add a ccache-alike for "spatch"Ævar Arnfjörð Bjarmason, Oct 26, 2022
  54. 00/13 cocci: make "incremental" possible + a ccache-like toolÆvar Arnfjörð Bjarmason, Nov 1, 2022
  55. 01/13 Makefile + shared.mak: rename and indent $(QUIET_SPATCH_T)Ævar Arnfjörð Bjarmason, Nov 1, 2022
  56. 02/13 cocci rules: remove unused "F" metavariable from pending ruleÆvar Arnfjörð Bjarmason, Nov 1, 2022
  57. 03/13 Makefile: add ability to TAB-complete cocci *.patch rulesÆvar Arnfjörð Bjarmason, Nov 1, 2022
  58. 04/13 Makefile: have "coccicheck" re-run if flags changeÆvar Arnfjörð Bjarmason, Nov 1, 2022
  59. 06/13 cocci: split off include-less "tests" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Nov 1, 2022
  60. 05/13 Makefile: split off SPATCH_BATCH_SIZE comment from "cocci" headingÆvar Arnfjörð Bjarmason, Nov 1, 2022
  61. 07/13 cocci: split off "--all-includes" from SPATCH_FLAGSÆvar Arnfjörð Bjarmason, Nov 1, 2022
  62. 08/13 cocci: make "coccicheck" rule incrementalÆvar Arnfjörð Bjarmason, Nov 1, 2022
  63. SZEDER GáborNov 9, 2022
  64. 10/13 Makefile: copy contrib/coccinelle/*.cocci to build/Ævar Arnfjörð Bjarmason, Nov 1, 2022
  65. SZEDER GáborNov 9, 2022
  66. Ævar Arnfjörð BjarmasonNov 9, 2022
  67. Makefile: don't create a ".build/.build/" for cocci, fix outputÆvar Arnfjörð Bjarmason, Nov 10, 2022
  68. Taylor BlauNov 11, 2022
  69. 09/13 cocci: optimistically use COMPUTE_HEADER_DEPENDENCIESÆvar Arnfjörð Bjarmason, Nov 1, 2022
  70. 11/13 cocci rules: remove <id>'s from rules that don't need themÆvar Arnfjörð Bjarmason, Nov 1, 2022
  71. 12/13 cocci: run against a generated ALL.cocciÆvar Arnfjörð Bjarmason, Nov 1, 2022
  72. 13/13 spatchcache: add a ccache-alike for "spatch"Ævar Arnfjörð Bjarmason, Nov 1, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.