cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Performance issue with quite simple patch?
@ 2021-01-13  9:48 Maxime Ripard
  2021-01-13 10:58 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Ripard @ 2021-01-13  9:48 UTC (permalink / raw)
  To: cocci


[-- Attachment #1.1: Type: text/plain, Size: 1088 bytes --]

Hi!

I've been trying to get a patch to rename any variable called "state" in
a given set of callbacks.

This is the patch that I've come up with:

@ plane_atomic_func @
identifier helpers;
identifier func;
@@

(
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_check = func,
	...,
 };
|
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_disable = func,
	...,
 };
|
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_update = func,
	...,
 };
)

@@
identifier plane_atomic_func.func;
symbol state;
expression e;
type T;
@@

 func(...)
 {
 	...
-	T state = e;
+	T plane_state = e;
 	<+...
-	state
+	plane_state
 	...+>
 }

However, it seems like at least on a file (in Linux,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c), it takes quite big
performance hit with one CPU running at 100% until the timeout is hit.

Replacing <+... by ... makes it work instantly, but doesn't really do
what I'm expecting, so I guess it's a matter of the patch being
subobtimal?

Is there a more optimal way of doing it?

Thanks!
Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

end of thread, other threads:[~2021-01-14 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  9:48 [Cocci] Performance issue with quite simple patch? Maxime Ripard
2021-01-13 10:58 ` Julia Lawall
2021-01-14 13:24   ` Maxime Ripard

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