Skip to contentSkip to conversation

drm/amdgpu: optimize out a spin lock (v2)

PATCH In review Alex Xie 2 participants 2 messages Jun 22, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Alex Xie

author
#0 lore raw

PATCH 1/1 drm/amdgpu: optimize out a spin lock (v2)

Use atomic instead of spin lock.
v2: Adjust commit message

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 110 +++++++++++++++++++----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   1 -
 3 files changed, 76 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -3
index 7caf514..21d318b 100644
@@ -1588,9 +1588,8 @@ struct amdgpu_device {
 
 	/* data for buffer migration throttling */
 	struct {
-		spinlock_t		lock;
-		s64			last_update_us;
-		s64			accum_us; /* accumulated microseconds */
+		atomic64_t		last_update_us;
+		atomic64_t		accum_us; /* accumulated microseconds */
 		u32			log2_max_MBps;
 	} mm_stats;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +74 -36

136 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
index ff90f78..9e9d592 100644
@@ -2117,7 +2117,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	spin_lock_init(&adev->didt_idx_lock);
 	spin_lock_init(&adev->gc_cac_idx_lock);
 	spin_lock_init(&adev->audio_endpt_idx_lock);
-	spin_lock_init(&adev->mm_stats.lock);
 
 	INIT_LIST_HEAD(&adev->shadow_list);
 	mutex_init(&adev->shadow_list_lock);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1498099554-31861-1-git-send-email-AlexBin.Xie-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 4 lines · Alex Xie

Use atomic instead of spin lock.
v2: Adjust commit message

The shortlog should be more specific, e.g. something like "drm/amdgpu:
Drop spinlock from mm_stats".

It's important for the Git commit shortlog to be as specific as possible because in many cases only the shortlogs of commits are visible.

I'll leave it to others to judge whether the conversion from spinlock to atomics is safe / an overall win.

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) · line 326

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -3
 	/* This returns 0 if the driver is in debt to disallow (optional)
 	 * buffer moves.
 	 */
-	max_bytes = us_to_bytes(adev, adev->mm_stats.accum_us);
-
-	spin_unlock(&adev->mm_stats.lock);
+	max_bytes = us_to_bytes(adev, accum_us);
 	return max_bytes;
 }

You can just make this

	return us_to_bytes(adev, accum_us);

and remove the max_bytes local.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx