public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coccinelle: flags.cocci: reorganize patterns to improve efficiency
@ 2017-11-12 16:08 Julia Lawall
  2017-11-15 14:46 ` Masahiro Yamada
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2017-11-12 16:08 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kernel, Michal Marek, Nicolas Palix, cocci

An initial rule just matching a function call makes it possible to focus
on one all at a time, which improves performance in complex functions with
multiple locking calls.  Using a constraint expression lock2 != pre.lock1;
makes it possible to eliminate the double matching of the lock, lock
sequence.

Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>

---

diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci
index debd70e..33f29a5 100644
--- a/scripts/coccinelle/locks/flags.cocci
+++ b/scripts/coccinelle/locks/flags.cocci
@@ -12,9 +12,9 @@ virtual context
 virtual org
 virtual report

-@r exists@
-expression lock1,lock2,flags;
-position p1,p2;
+@pre exists@
+expression lock1,flags;
+position p1;
 @@

 (
@@ -24,25 +24,12 @@ read_lock_irqsave@p1(lock1,flags)
 |
 write_lock_irqsave@p1(lock1,flags)
 )
-... when != flags
-(
-spin_lock_irqsave(lock1,flags)
-|
-read_lock_irqsave(lock1,flags)
-|
-write_lock_irqsave(lock1,flags)
-|
-spin_lock_irqsave@p2(lock2,flags)
-|
-read_lock_irqsave@p2(lock2,flags)
-|
-write_lock_irqsave@p2(lock2,flags)
-)

-@d exists@
-expression f <= r.flags;
-expression lock1,lock2,flags;
-position r.p1, r.p2;
+@r exists@
+expression lock2 != pre.lock1;
+expression f <= pre.flags;
+expression pre.lock1,pre.flags;
+position pre.p1,p2;
 @@

 (
@@ -63,16 +50,16 @@ position r.p1, r.p2;

 // ----------------------------------------------------------------------

-@script:python depends on d && org@
-p1 << r.p1;
+@script:python depends on org@
+p1 << pre.p1;
 p2 << r.p2;
 @@

 cocci.print_main("original lock",p1)
 cocci.print_secs("nested lock+irqsave that reuses flags",p2)

-@script:python depends on d && report@
-p1 << r.p1;
+@script:python depends on report@
+p1 << pre.p1;
 p2 << r.p2;
 @@

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-16  7:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-12 16:08 [PATCH] coccinelle: flags.cocci: reorganize patterns to improve efficiency Julia Lawall
2017-11-15 14:46 ` Masahiro Yamada
2017-11-15 14:51   ` Julia Lawall
2017-11-15 15:26     ` Masahiro Yamada
2017-11-15 15:29       ` Julia Lawall
2017-11-15 21:55       ` Julia Lawall
2017-11-15 22:02         ` Joe Perches
2017-11-16  0:02           ` Masahiro Yamada
2017-11-16  7:31           ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox