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

Re: [PoC] coccinelle: make Coccinelle-related make targets more fine-grained

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 3, 2018, 06:44 UTC
Message-ID
<20180803064419.GC237521@aiede.svl.corp.google.com>
In-Reply-To
<alpine.DEB.2.20.1808030755350.2446@hadrien>
Hi,
Julia Lawall wrote:
Show 5 quoted lines
> This was already possible.  Make coccicheck is not supposed to be used
> with -j, but rather with J=n.  That tells Coccinelle to parallelize the
> treatment of the files internally.  In this case, the semantic patch is
> only parsed once, and then n worker processes are forked to treat the
> different files.
Thanks for this hint.

I wonder if we can make this happen automatically under suitable conditions. We can parse -j<num> out of MAKEFLAGS and convert it into a J=<num> argument, but that only solves half the problem: the "make" parent process would think that the coccinelle run only deserves to occupy one job slot.

Technically we could do all this using a wrapper that pretends to be a submake <https://www.gnu.org/software/make/manual/html_node/Job-Slots.html> (prefixing the command with '+', parsing jobserver options from the MAKEFLAGS envvar) but it gets ugly.

It's likely that the best we can do is just to advertise J more prominently.

[...]
>> On Thu, Aug 02 2018, Jeff King wrote:
Show 9 quoted lines
>>>   cat contrib/coccinelle/*.cocci >mega.cocci
>>>   make -j40 coccicheck COCCI_SEM_PATCHES=mega.cocci
>
> There was already a COCCI=foo.cocci argument to focus on a single semantic
> patch.
>
> 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.

Yes, Git's semantic patches (in contrib/coccinelle) tend to be relatively undemanding.

>       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.
... oh!  You're thinking of the Linux kernel.

It looks like Linux's scripts/coccicheck has a lot we can crib from. That's where the J envvar and automatic parallelism you mentioned are implemented, too.

So it sounds to me like at a minimum we should use all of that. ;-)
Thanks again for the pointers.

Sincerely, Jonathan

Previous: Julia LawallNext: Julia Lawall
Message 29 of 31 in “Misc Coccinelle-related improvements”
  1. 0/5 Misc Coccinelle-related improvementsSZEDER Gábor, Jul 23, 2018
  2. 1/5 coccinelle: mark the 'coccicheck' make target as .PHONYSZEDER Gábor, Jul 23, 2018
  3. Derrick StoleeJul 23, 2018
  4. Junio C HamanoJul 23, 2018
  5. 2/5 coccinelle: use $(addsuffix) in 'coccicheck' make targetSZEDER Gábor, Jul 23, 2018
  6. Junio C HamanoJul 23, 2018
  7. 3/5 coccinelle: exclude sha1dc source files from static analysisSZEDER Gábor, Jul 23, 2018
  8. Eric SunshineJul 23, 2018
  9. SZEDER GáborJul 23, 2018
  10. Eric SunshineJul 23, 2018
  11. 4/5 coccinelle: put sane filenames into output patchesSZEDER Gábor, Jul 23, 2018
  12. Derrick StoleeJul 23, 2018
  13. 5/5 coccinelle: extract dedicated make target to clean Coccinelle's resultsSZEDER Gábor, Jul 23, 2018
  14. Derrick StoleeJul 23, 2018
  15. Duy NguyenJul 23, 2018
  16. René ScharfeJul 23, 2018
  17. Junio C HamanoJul 23, 2018
  18. [PoC] coccinelle: make Coccinelle-related make targets more fine-grainedSZEDER Gábor, Aug 2, 2018
  19. René ScharfeAug 2, 2018
  20. Jeff KingAug 2, 2018
  21. Jeff KingAug 2, 2018
  22. Jonathan NiederAug 3, 2018
  23. Jeff KingAug 3, 2018
  24. Jonathan NiederAug 5, 2018
  25. Eric SunshineAug 2, 2018
  26. Jeff KingAug 2, 2018
  27. Ævar Arnfjörð BjarmasonAug 2, 2018
  28. Julia LawallAug 3, 2018
  29. Jonathan NiederAug 3, 2018
  30. Julia LawallAug 3, 2018
  31. Julia LawallAug 3, 2018

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.