lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.20.1711121704350.10412@hadrien>
Date:   Sun, 12 Nov 2017 17:08:26 +0100 (CET)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
cc:     linux-kernel@...r.kernel.org,
        Michal Marek <michal.lkml@...kovi.net>,
        Nicolas Palix <nicolas.palix@...g.fr>, cocci@...teme.lip6.fr
Subject: [PATCH] coccinelle: flags.cocci: reorganize patterns to improve
 efficiency

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@...6.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;

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

-@...ipt:python depends on d && org@
-p1 << r.p1;
+@...ipt: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)

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ