From: Julia Lawall <julia.lawall@inria.fr>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Coccinelle ML <cocci@inria.fr>
Subject: Re: [cocci] Optimizing *.cocci rules by concat'ing them
Date: Thu, 1 Sep 2022 17:19:18 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2209011715290.33128@hadrien> (raw)
In-Reply-To: <220901.8635dbjfko.gmgdl@evledraar.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2764 bytes --]
On Thu, 1 Sep 2022, Ævar Arnfjörð Bjarmason wrote:
> Are there reasons for why $subject is a generally bad idea, i.e. given a
> set of *.cocci rules in a directory instead of something like:
>
> for c in cocci/*.cocci
> do
> spatch --sp-file $c --patch . *.c
> done
>
> Doing:
>
> cat cocci/*.cocci >ALL.cocci
> spatch --sp-file ALL.cocci --patch . *.c
>
> I'm aware that rules in general may rely on previous transformations,
> such that the 3rd rule in a file might not fire unless the other 2 have
> previously changed the code.
I think that the main problem is the opposite of what you suggest. Two
.cocci files might define rules that have the same names.
I don't see any other problems offhand. If one rule makes a change that
somehow affects a later semantic patch, then that should be ok, assuming
that the change made by the first rule was actually a fix.
Another issue is that you can't mix rules that make changes with rules
that just search (*). You need at least some command line options, like
-D patch in make coccicheck, to keep them apart.
julia
>
> But aside from any such undeclared dependencies, which surely I'll have
> trouble with either way. I.e. I'd get to the 2nd rule in A.cocci, apply
> that to my sources, and only then on a second run would the 1st rule in
> B.cocci fire, but it should have been in A.cocci to begin with, and
> depending on the 2nd rule in that file.
>
> Are there reasons for why this is a Bad Idea?
>
> The motivation here (and this is probably burying the lede) is that I
> implemented a "spatchcache", which can cache previous runs of "spatch"
> in a local Redis (or with a custom command, if you don't have Redis, I
> started out with a dumb FS-based cache).
>
> It uses the approach of piggy-backing on GCC and Clang's ability to dump
> a full list of all the files that a given *.c file depends on.
>
> This is usually used to drive better incremental "make" support, but I'm
> (ab)using it to implement an "spatchcache". If the hash of a the target
> file *and* everything it depends on *and* spatch's path, flags etc. is
> the same I can cache the output of "spatch".
>
> See [1] for a series to implement this for git.git. I'd previously mused
> on this list in [2] about this approach (but hadn't finished it up until
> now).
>
> But even then git's fairly slow in running "make coccicheck", and of
> course it does nothing to speed up an initial run. So concat'ing the
> *.cocci files we use seems like a viable option. But I thought I'd ask
> first in case I'm running into somewell-known caveat.
>
> Thanks!
>
> 1. https://lore.kernel.org/git/cover-v2-0.9-00000000000-20220831T205130Z-avarab@gmail.com/
> 2. https://lore.kernel.org/cocci/211116.86lf1op65q.gmgdl@evledraar.gmail.com/
>
next prev parent reply other threads:[~2022-09-01 15:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 15:00 [cocci] Optimizing *.cocci rules by concat'ing them Ævar Arnfjörð Bjarmason
2022-09-01 15:19 ` Julia Lawall [this message]
2022-09-01 18:12 ` [cocci] Checking consequences from concatenation of SmPL rules Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.22.394.2209011715290.33128@hadrien \
--to=julia.lawall@inria.fr \
--cc=avarab@gmail.com \
--cc=cocci@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).