Skip to contentSkip to conversation

Best way to run coccinelle in a CI?

cocci Julia Lawall 3 participants 10 messages Nov 3, 2021 – Nov 4, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20211103124001.68e76017@kicinski-fedora-PC1C0HJN

#1 lore raw
Quoted 7 lines · Jakub Kicinski

Hi folks!

I'd like to run coccicheck on all patches before they are committed to Linux networking trees. Is there a recommended way of doing that?

I'm looking for a way to run the checks only on files which were touched and in the fastest way possible..

I had an intern who worked on an extension to Coccinelle to take a patch and then only apply spatch to that file. Perhaps I can resurrect that code.

[Note the new mailing list: [email protected]]

julia

#2 lore raw
Quoted 6 lines · On Wed, 3 Nov 2021 21:37:07 +0100 (CET) Julia Lawall wrote:
Quoted 5 lines · Jakub Kicinski

Hi folks!

I'd like to run coccicheck on all patches before they are committed to Linux networking trees. Is there a recommended way of doing that?

Quoted 6 lines
Quoted 2 lines

I'm looking for a way to run the checks only on files which were touched and in the fastest way possible..

I had an intern who worked on an extension to Coccinelle to take a patch and then only apply spatch to that file. Perhaps I can resurrect that code.

That'd be quite useful, thanks! Would it have any impact on the performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I could run the check on all patches in a series to speed things up. Would it be possible to feed it a git range?

Quoted 1 line

[Note the new mailing list: [email protected]]

Thanks, FWIW I was going by addresses in MAINTAINERS in Linus's tree.

#3 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Wed, 3 Nov 2021 21:37:07 +0100 (CET) Julia Lawall wrote:
Quoted 7 lines · Jakub Kicinski

Hi folks!

I'd like to run coccicheck on all patches before they are committed to Linux networking trees. Is there a recommended way of doing that?

I'm looking for a way to run the checks only on files which were touched and in the fastest way possible..

Quoted 7 lines
Quoted 3 lines

I had an intern who worked on an extension to Coccinelle to take a patch and then only apply spatch to that file. Perhaps I can resurrect that code.

That'd be quite useful, thanks! Would it have any impact on the performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I think it should be helpful. If most files are completely ignored, the performance should improve. On the other hand, I don't known if it would be practical to treat diferent patches in parallel. So the speedup might not be that great. It depends on how many files are actually being parsed,

Quoted 6 lines

I could run the check on all patches in a series to speed things up. Would it be possible to feed it a git range?

Quoted 1 line

[Note the new mailing list: [email protected]]

Thanks, FWIW I was going by addresses in MAINTAINERS in Linus's tree.

Yeah, I need to send him a pull request...

julia

#4 lore raw
Quoted 6 lines
Quoted 3 lines

… Would it have any impact on the
performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I think it should be helpful. If most files are completely ignored, the performance should improve.

The selection of affected files has got a significant influence for desirable data processing.

Quoted 2 lines

On the other hand, I don't known if it would be practical to treat diferent patches in parallel.

I hope that additional computation technologies and resources will improve the situation in some ways.

Quoted 1 line

So the speedup might not be that great.

I guess that further options can be taken better into account.

Quoted 1 line

It depends on how many files are actually being parsed,

The analysed files vary in the sizes and code mixtures as usual.

Regards,
Markus

#5 lore raw
In reply to Jakub Kicinski
Quoted 14 lines · Jakub Kicinski
Quoted 6 lines · On Wed, 3 Nov 2021 21:37:07 +0100 (CET) Julia Lawall wrote:
Quoted 5 lines · Jakub Kicinski

Hi folks!

I'd like to run coccicheck on all patches before they are committed to Linux networking trees. Is there a recommended way of doing that?

Quoted 6 lines
Quoted 2 lines

I'm looking for a way to run the checks only on files which were touched and in the fastest way possible..

I had an intern who worked on an extension to Coccinelle to take a patch and then only apply spatch to that file. Perhaps I can resurrect that code.

Quoted 6 lines

That'd be quite useful, thanks! Would it have any impact on the performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I could run the check on all patches in a series to speed things up. Would it be possible to feed it a git range?

There are now two new options:

--use-diff
There should also be the name of a directory on the command line. This will run the semantic patches only on the files that have changed in that directory

--use-patch-diff commit
This will run spatch only on the files that have changed in commit.

--use-patch-diff commit1..commit2
This will run spatch only on the files that have changed between commit1 and commit2. In recent versions of git, this uses the --merge-base option.

Note that the file names are taken from the commits, but Coccinelle doesn't run on the files at the time of the commits. Coccinelle always runs on the current snapshot of the indicated file or directory. For old commits, this may lead to messages about files that don't exist.

Let me know if this is useful.

julia

#6 lore raw
Quoted 23 lines · On Thu, 4 Nov 2021 16:16:09 +0100 (CET) Julia Lawall wrote:
Quoted 6 lines · Jakub Kicinski

That'd be quite useful, thanks! Would it have any impact on the performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I could run the check on all patches in a series to speed things up. Would it be possible to feed it a git range?

There are now two new options:

--use-diff
There should also be the name of a directory on the command line. This will run the semantic patches only on the files that have changed in that directory

--use-patch-diff commit
This will run spatch only on the files that have changed in commit.

--use-patch-diff commit1..commit2
This will run spatch only on the files that have changed between commit1 and commit2. In recent versions of git, this uses the --merge-base option.

Quoted 6 lines

Note that the file names are taken from the commits, but Coccinelle doesn't run on the files at the time of the commits. Coccinelle always runs on the current snapshot of the indicated file or directory. For old commits, this may lead to messages about files that don't exist.

Let me know if this is useful.

Great, sounds like the exact thing I need.

And I would pass these to coccicheck as

SPFLAGS="--use-patch-diff $hash1..$hash2"

?

#7 lore raw
Quoted 29 lines · Jakub Kicinski
Quoted 28 lines · On Thu, 4 Nov 2021 16:16:09 +0100 (CET) Julia Lawall wrote:
Quoted 6 lines · Jakub Kicinski

That'd be quite useful, thanks! Would it have any impact on the performance as well? I see running coccicheck M=net/core/ takes 2 minutes now, for a 15 patch series that adds up quickly.

I could run the check on all patches in a series to speed things up. Would it be possible to feed it a git range?

There are now two new options:

--use-diff
There should also be the name of a directory on the command line. This will run the semantic patches only on the files that have changed in that directory

--use-patch-diff commit
This will run spatch only on the files that have changed in commit.

--use-patch-diff commit1..commit2
This will run spatch only on the files that have changed between commit1 and commit2. In recent versions of git, this uses the --merge-base option.

Note that the file names are taken from the commits, but Coccinelle doesn't run on the files at the time of the commits. Coccinelle always runs on the current snapshot of the indicated file or directory. For old commits, this may lead to messages about files that don't exist.

Quoted 7 lines
Quoted 1 line

Let me know if this is useful.

Great, sounds like the exact thing I need.

And I would pass these to coccicheck as

SPFLAGS="--use-patch-diff $hash1..$hash2"

That looks like a reasonable guess. I'm not sure how it will interact with what make coccicheck wants to do though.

julia

#8 lore raw
Quoted 8 lines · On Thu, 4 Nov 2021 18:30:10 +0100 (CET) Julia Lawall wrote:
Quoted 5 lines

Great, sounds like the exact thing I need.

And I would pass these to coccicheck as

SPFLAGS="--use-patch-diff $hash1..$hash2"

That looks like a reasonable guess. I'm not sure how it will interact with what make coccicheck wants to do though.

In terms of what make does? So running ./scripts/coccicheck directly would be better?

#9 lore raw
Quoted 5 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 4 Nov 2021 18:30:10 +0100 (CET) Julia Lawall wrote:
Quoted 4 lines

Great, sounds like the exact thing I need.

And I would pass these to coccicheck as

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

SPFLAGS="--use-patch-diff $hash1..$hash2"

That looks like a reasonable guess. I'm not sure how it will interact with what make coccicheck wants to do though.

In terms of what make does? So running ./scripts/coccicheck directly would be better?

Not sure. Basically, the ideal thing would be if spatch sees the directory of your git tree. Because it is going to be picking the files it wants to consider by itself out of the commit. But it might be fine.

julia

#10 lore raw
In reply to Julia Lawall
Quoted 8 lines
Quoted 5 lines

I'd like to run coccicheck on all patches before they are committed to Linux networking trees. Is there a recommended way of doing that?

I'm looking for a way to run the checks only on files which were touched and in the fastest way possible..

I had an intern who worked on an extension to Coccinelle to take a patch and then only apply spatch to that file.

Thanks for such background information.

Quoted 1 line

Perhaps I can resurrect that code.

Does anything hinder the integration of corresponding software extensions?

Regards,
Markus