All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: Don't memcmp equivalent pointers
@ 2024-03-28 19:07 Ian Forbes
  2024-03-29  1:22 ` Zack Rusin
  2024-04-05 15:02 ` [PATCH v2] " Ian Forbes
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Forbes @ 2024-03-28 19:07 UTC (permalink / raw)
  To: dri-devel
  Cc: bcm-kernel-feedback-list, zack.rusin, martin.krastev,
	maaz.mombasawala, Ian Forbes

These pointers are frequently the same and memcmp does not compare the pointers
before comparing their contents so this was wasting cycles comparing 16 KiB of
memory which will always be equal.

Fixes: bb6780aa5a1d9 ("drm/vmwgfx: Diff cursors when using cmds")
Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index cd4925346ed4..fbcce84e2f4c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -216,7 +216,7 @@ static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
 	new_image = vmw_du_cursor_plane_acquire_image(new_vps);
 
 	changed = false;
-	if (old_image && new_image)
+	if (old_image && new_image && (old_image != new_image))
 		changed = memcmp(old_image, new_image, size) != 0;
 
 	return changed;
-- 
2.34.1


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

* Re: [PATCH] drm/vmwgfx: Don't memcmp equivalent pointers
  2024-03-28 19:07 [PATCH] drm/vmwgfx: Don't memcmp equivalent pointers Ian Forbes
@ 2024-03-29  1:22 ` Zack Rusin
  2024-04-05 15:02 ` [PATCH v2] " Ian Forbes
  1 sibling, 0 replies; 3+ messages in thread
From: Zack Rusin @ 2024-03-29  1:22 UTC (permalink / raw)
  To: Ian Forbes
  Cc: dri-devel, bcm-kernel-feedback-list, martin.krastev, maaz.mombasawala

On Thu, Mar 28, 2024 at 3:31 PM Ian Forbes <ian.forbes@broadcom.com> wrote:
>
> These pointers are frequently the same and memcmp does not compare the pointers
> before comparing their contents so this was wasting cycles comparing 16 KiB of
> memory which will always be equal.
>
> Fixes: bb6780aa5a1d9 ("drm/vmwgfx: Diff cursors when using cmds")
> Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index cd4925346ed4..fbcce84e2f4c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -216,7 +216,7 @@ static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
>         new_image = vmw_du_cursor_plane_acquire_image(new_vps);
>
>         changed = false;
> -       if (old_image && new_image)
> +       if (old_image && new_image && (old_image != new_image))
>                 changed = memcmp(old_image, new_image, size) != 0;
>
>         return changed;
> --
> 2.34.1
>

The patch looks good but please use "dim checkpatch" and fix the
issues it found. For the "Fixes:" line you also want to use "dim
fixes".

z

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

* [PATCH v2] drm/vmwgfx: Don't memcmp equivalent pointers
  2024-03-28 19:07 [PATCH] drm/vmwgfx: Don't memcmp equivalent pointers Ian Forbes
  2024-03-29  1:22 ` Zack Rusin
@ 2024-04-05 15:02 ` Ian Forbes
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Forbes @ 2024-04-05 15:02 UTC (permalink / raw)
  To: dri-devel
  Cc: bcm-kernel-feedback-list, zack.rusin, martin.krastev,
	maaz.mombasawala, Ian Forbes, stable

These pointers are frequently the same and memcmp does not compare the
pointers before comparing their contents so this was wasting cycles
comparing 16 KiB of memory which will always be equal.

Fixes: bb6780aa5a1d ("drm/vmwgfx: Diff cursors when using cmds")
Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
Cc: <stable@vger.kernel.org> # v6.2+
---
v2: Fix code and commit message formatting.
--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index cd4925346ed4..ef0af10c4968 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -216,7 +216,7 @@ static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
 	new_image = vmw_du_cursor_plane_acquire_image(new_vps);
 
 	changed = false;
-	if (old_image && new_image)
+	if (old_image && new_image && old_image != new_image)
 		changed = memcmp(old_image, new_image, size) != 0;
 
 	return changed;
-- 
2.34.1


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

end of thread, other threads:[~2024-04-05 15:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 19:07 [PATCH] drm/vmwgfx: Don't memcmp equivalent pointers Ian Forbes
2024-03-29  1:22 ` Zack Rusin
2024-04-05 15:02 ` [PATCH v2] " Ian Forbes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.