All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: make dma_fence structure a bit smaller
@ 2019-08-08 13:14 Christian König
  0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2019-08-08 13:14 UTC (permalink / raw)
  To: dri-devel, intel-gfx, linaro-mm-sig

We clear the callback list on kref_put so that by the time we
release the fence it is unused. No one should be adding to the cb_list
that they don't themselves hold a reference for.

This small change is actually making the structure 16% smaller.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 include/linux/dma-fence.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 05d29dbc7e62..3985c72cd0c2 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -65,8 +65,10 @@ struct dma_fence_cb;
 struct dma_fence {
 	struct kref refcount;
 	const struct dma_fence_ops *ops;
-	struct rcu_head rcu;
-	struct list_head cb_list;
+	union {
+		struct rcu_head rcu;
+		struct list_head cb_list;
+	};
 	spinlock_t *lock;
 	u64 context;
 	u64 seqno;
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] dma-buf: make dma_fence structure a bit smaller
  2019-08-07 14:01 ` Chris Wilson
@ 2019-08-07 21:11   ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2019-08-07 21:11 UTC (permalink / raw)
  To: Chris Wilson; +Cc: linaro-mm-sig, Christian König, intel-gfx, dri-devel

On Wed, Aug 07, 2019 at 03:01:59PM +0100, Chris Wilson wrote:
> Quoting Christian König (2019-08-07 14:54:05)
> > The ruc and cb_list are never used at the same time.
> > This smal change is actually making the structure 16% smaller.
> (Trivial pair of typos)
> 
> Yes. We clear the callback list on kref_put so that by the time we
> release the fence it is unused. No one should be adding to the cb_list
> that they don't themselves hold a reference for, this only now makes for
> a much more spectacular use-after-free. :)

^^ stuff the above as an inline kerneldoc comment into the patch? And into
the commit message too pls. We need better docs for all this scorcery :-)

Thanks, Daniel

> 
> > Signed-off-by: Christian König <christian.koenig@amd.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> -Chris
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] dma-buf: make dma_fence structure a bit smaller
  2019-08-07 13:54 Christian König
@ 2019-08-07 14:01 ` Chris Wilson
  2019-08-07 21:11   ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2019-08-07 14:01 UTC (permalink / raw)
  To: Christian König, dri-devel, intel-gfx, linaro-mm-sig

Quoting Christian König (2019-08-07 14:54:05)
> The ruc and cb_list are never used at the same time.
> This smal change is actually making the structure 16% smaller.
(Trivial pair of typos)

Yes. We clear the callback list on kref_put so that by the time we
release the fence it is unused. No one should be adding to the cb_list
that they don't themselves hold a reference for, this only now makes for
a much more spectacular use-after-free. :)

> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] dma-buf: make dma_fence structure a bit smaller
@ 2019-08-07 13:54 Christian König
  2019-08-07 14:01 ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2019-08-07 13:54 UTC (permalink / raw)
  To: intel-gfx, linaro-mm-sig, dri-devel, chris

The ruc and cb_list are never used at the same time.
This smal change is actually making the structure 16% smaller.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 include/linux/dma-fence.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 05d29dbc7e62..3985c72cd0c2 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -65,8 +65,10 @@ struct dma_fence_cb;
 struct dma_fence {
 	struct kref refcount;
 	const struct dma_fence_ops *ops;
-	struct rcu_head rcu;
-	struct list_head cb_list;
+	union {
+		struct rcu_head rcu;
+		struct list_head cb_list;
+	};
 	spinlock_t *lock;
 	u64 context;
 	u64 seqno;
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-08-08 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 13:14 [PATCH] dma-buf: make dma_fence structure a bit smaller Christian König
  -- strict thread matches above, loose matches on Subject: below --
2019-08-07 13:54 Christian König
2019-08-07 14:01 ` Chris Wilson
2019-08-07 21:11   ` Daniel Vetter

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.