drm/amdgpu: improve the userq seq BO free bit lookup
Subsystems (2)
PATCH 1/1 drm/amdgpu: improve the userq seq BO free bit lookup
Use find_next_zero_bit() to locate the next free seq slot bit instead of the current walk, for more efficient bitmap scanning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +5 -4
@@ -175,14 +175,15 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va, {unsigned long bit_pos; -for (;;) { - bit_pos =find_first_zero_bit (adev->seq64.used, adev->seq64.num_sem); +do { + bit_pos =find_next_zero_bit (adev->seq64.used, + adev->seq64.num_sem, bit_pos);if (bit_pos >= adev->seq64.num_sem)return -ENOSPC ; -if (!test_and_set_bit (bit_pos, adev->seq64.used))break ; - } + bit_pos++; + }while (1 ); *va = bit_pos *sizeof (u64) +amdgpu_seq64_get_va_base (adev);
Signature · 1 line
2.34.1
Christian König
maintainerQuoted 13 lines · Prike Liang
Use
find_next_zero_bit()to locate the next free seq slot bit instead of the current walk, for more efficient bitmap scanning.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va, · line 180
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +3
-2@@ -175,14 +175,15 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va, {unsigned long bit_pos; -for (;;) { - bit_pos =find_first_zero_bit (adev->seq64.used, adev->seq64.num_sem); + do { + bit_pos = find_next_zero_bit(adev->seq64.used, + adev->seq64.num_sem, bit_pos);
bit_pos is uninitialized for the first look here.
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +2
-2if (bit_pos >= adev->seq64.num_sem)return -ENOSPC ; -if (!test_and_set_bit (bit_pos, adev->seq64.used))break ; - } + bit_pos++; + }while (1 ); *va = bit_pos *sizeof (u64) +amdgpu_seq64_get_va_base (adev);
Public
Regards,
Prike
Quoted 27 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, May 26, 2026 4:15 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: improve the userq seq BO free bit lookupQuoted 17 lines · Prike Liang
Use
find_next_zero_bit()to locate the next free seq slot bit instead of the current walk, for more efficient bitmap scanning.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +0
-0@@ -175,14 +175,15 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va, {unsigned long bit_pos;
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va, · line 180
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +3
-2-for (;;) { - bit_pos =find_first_zero_bit (adev->seq64.used, adev- seq64.num_sem); + do { + bit_pos = find_next_zero_bit(adev->seq64.used, + adev->seq64.num_sem, bit_pos);
bit_posis uninitialized for the first look here.
Thanks, will fix it in the v2 version.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c +2
-2if (bit_pos >= adev->seq64.num_sem)return -ENOSPC ; -if (!test_and_set_bit (bit_pos, adev->seq64.used))break ; - } + bit_pos++; + }while (1 ); *va = bit_pos *sizeof (u64) +amdgpu_seq64_get_va_base (adev);