]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dma-buf: make dma_fence structure a bit smaller v2
authorChristian König <christian.koenig@amd.com>
Wed, 7 Aug 2019 10:31:48 +0000 (12:31 +0200)
committerChristian König <christian.koenig@amd.com>
Sat, 10 Aug 2019 10:30:07 +0000 (12:30 +0200)
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.

v2: add the comment to the code as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/322916/
include/linux/dma-fence.h

index 05d29dbc7e62c12b7d99bb8d4d4e5cccf2e46461..bea1d05cf51eb2aac4751da1ff6b63f3468df886 100644 (file)
@@ -65,8 +65,14 @@ 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;
+       /* 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.
+        */
+       union {
+               struct rcu_head rcu;
+               struct list_head cb_list;
+       };
        spinlock_t *lock;
        u64 context;
        u64 seqno;