Skip to contentSkip to conversation

Coccinelle: api: Optimise disjunction in SmPL script “pm_runtime.cocci”

PATCH New Markus Elfring 1 participant 1 message Oct 25, 2020 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Coccinelle: api: Optimise disjunction in SmPL script “pm_runtime.cocci”

From: Markus Elfring <[email protected]>
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.

---
 scripts/coccinelle/api/pm_runtime.cocci | 40 +++++++++++++------------
 1 file changed, 21 insertions(+), 19 deletions(-)
scripts/coccinelle/api/pm_runtime.cocci +21 -19
index 1ccce3fd00b8..7d9908cf0803 100644
@@ -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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci