All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dma-buf: Expand reservation_list to fill allocation
@ 2019-07-12  8:03 Chris Wilson
  2019-07-12  8:03 ` [PATCH 2/2] dma-buf: Relax the write-seqlock for reallocating the shared fence list Chris Wilson
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Chris Wilson @ 2019-07-12  8:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Michel Dänzer, Christian König

Since kmalloc() will round up the allocation to the next slab size or
page, it will normally return a pointer to a memory block bigger than we
asked for. We can query for the actual size of the allocated block using
ksize() and expand our variable size reservation_list to take advantage
of that extra space.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Christian König <christian.koenig@amd.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/dma-buf/reservation.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index a6ac2b3a0185..80ecc1283d15 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -153,7 +153,9 @@ int reservation_object_reserve_shared(struct reservation_object *obj,
 			RCU_INIT_POINTER(new->shared[j++], fence);
 	}
 	new->shared_count = j;
-	new->shared_max = max;
+	new->shared_max =
+		(ksize(new) - offsetof(typeof(*new), shared)) /
+		sizeof(*new->shared);
 
 	preempt_disable();
 	write_seqcount_begin(&obj->seq);
@@ -169,7 +171,7 @@ int reservation_object_reserve_shared(struct reservation_object *obj,
 		return 0;
 
 	/* Drop the references to the signaled fences */
-	for (i = k; i < new->shared_max; ++i) {
+	for (i = k; i < max; ++i) {
 		struct dma_fence *fence;
 
 		fence = rcu_dereference_protected(new->shared[i],
-- 
2.22.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2019-07-16 20:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12  8:03 [PATCH 1/2] dma-buf: Expand reservation_list to fill allocation Chris Wilson
2019-07-12  8:03 ` [PATCH 2/2] dma-buf: Relax the write-seqlock for reallocating the shared fence list Chris Wilson
2019-07-16  9:21   ` Daniel Vetter
2019-07-16 20:05     ` Chris Wilson
2019-07-12  8:33 ` [PATCH 1/2] dma-buf: Expand reservation_list to fill allocation Michel Dänzer
2019-07-12  8:56 ` ✓ Fi.CI.BAT: success for series starting with [1/2] " Patchwork
2019-07-13 15:38 ` ✓ Fi.CI.IGT: " Patchwork
2019-07-14  7:37 ` [PATCH 1/2] " Koenig, Christian
2019-07-15 10:58   ` Chris Wilson
2019-07-15 11:11 ` Chris Wilson

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.