cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] [PATCH] Coccinelle: api: Optimise disjunction in SmPL script “pm_runtime.cocci”
@ 2020-10-25 13:25 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-10-25 13:25 UTC (permalink / raw)
  To: Coccinelle, Gilles Muller, Julia Lawall, Michal Marek, Nicolas Palix
  Cc: kernel-janitors, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 25 Oct 2020 14:10:58 +0100

A disjunction is applied by this script for the semantic patch language.
This construct uses short-circuit evaluation. It has got the consequence
that the last element of the specified condition will only be checked
if all previous parts did not match. Such a technical detail leads to
a recommended ordering of condition parts if you would like to care for
optimal run time characteristics of SmPL code.

An usage incidence was determined for the specified identifiers in source
files from the software “Linux next-20201023” by another SmPL script.
This analysis result indicated that a few functions were called more
frequent than others.
Thus reorder the SmPL disjunction items partly according to their
usage incidence.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/pm_runtime.cocci | 40 +++++++++++++------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/scripts/coccinelle/api/pm_runtime.cocci b/scripts/coccinelle/api/pm_runtime.cocci
index 1ccce3fd00b8..7d9908cf0803 100644
--- a/scripts/coccinelle/api/pm_runtime.cocci
+++ b/scripts/coccinelle/api/pm_runtime.cocci
@@ -21,25 +21,27 @@ expression ret;
 position p;
 @@
 (
-ret@p = \(pm_runtime_idle\|
-	pm_runtime_suspend\|
-	pm_runtime_autosuspend\|
-	pm_runtime_resume\|
-	pm_request_idle\|
-	pm_request_resume\|
-	pm_request_autosuspend\|
-	pm_runtime_get\|
-	pm_runtime_get_sync\|
-	pm_runtime_put\|
-	pm_runtime_put_autosuspend\|
-	pm_runtime_put_sync\|
-	pm_runtime_put_sync_suspend\|
-	pm_runtime_put_sync_autosuspend\|
-	pm_runtime_set_active\|
-	pm_schedule_suspend\|
-	pm_runtime_barrier\|
-	pm_generic_runtime_suspend\|
-	pm_generic_runtime_resume\)(...);
+ ret@p =
+(pm_runtime_get_sync
+|pm_runtime_set_active
+|pm_runtime_put_sync_autosuspend
+|pm_runtime_put_sync
+|pm_runtime_get
+|pm_runtime_put
+|pm_generic_runtime_suspend
+|pm_generic_runtime_resume
+|pm_request_autosuspend
+|pm_request_idle
+|pm_request_resume
+|pm_runtime_autosuspend
+|pm_runtime_barrier
+|pm_runtime_idle
+|pm_runtime_put_autosuspend
+|pm_runtime_put_sync_suspend
+|pm_runtime_resume
+|pm_runtime_suspend
+|pm_schedule_suspend
+)(...);
 ...
 IS_ERR_VALUE(ret)
 ...
--
2.29.1

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-25 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-25 13:25 [Cocci] [PATCH] Coccinelle: api: Optimise disjunction in SmPL script “pm_runtime.cocci” Markus Elfring

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).