mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: optimize duplicate buffer lookup in case of fixed offsets
In gk20a_vm_map_duplicate_locked(), we always do a linear search in rb-tree to find a duplicate entry of the buffer In case NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET is set, we first traverse whole rb-tree linearly and then compare offset_align with the address searched from rb-tree If size of rb-tree is very large this linear lookup takes upto 7mS and causes huge delays Hence in case of NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET, we can use offset_align to perform a binary search on rb-tree and then verify that dmabuf and kind match with the node obtained from the search This saves a lot of time per-lookup Bug 1874516 Change-Id: Ia4924b64d66e586c14341ae2e2283beac394bf6f Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: http://git-master/r/1309343 Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
09504cdbc3
commit
64e1782aee
@@ -2061,19 +2061,26 @@ static u64 gk20a_vm_map_duplicate_locked(struct vm_gk20a *vm,
|
||||
struct gk20a *g = gk20a_from_vm(vm);
|
||||
struct mapped_buffer_node *mapped_buffer = NULL;
|
||||
|
||||
mapped_buffer =
|
||||
find_mapped_buffer_reverse_locked(&vm->mapped_buffers,
|
||||
if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) {
|
||||
mapped_buffer = find_mapped_buffer_locked(&vm->mapped_buffers,
|
||||
offset_align);
|
||||
if (!mapped_buffer)
|
||||
return 0;
|
||||
|
||||
if (mapped_buffer->dmabuf != dmabuf ||
|
||||
mapped_buffer->kind != (u32)kind)
|
||||
return 0;
|
||||
} else {
|
||||
mapped_buffer =
|
||||
find_mapped_buffer_reverse_locked(&vm->mapped_buffers,
|
||||
dmabuf, kind);
|
||||
if (!mapped_buffer)
|
||||
return 0;
|
||||
if (!mapped_buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mapped_buffer->flags != flags)
|
||||
return 0;
|
||||
|
||||
if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET &&
|
||||
mapped_buffer->addr != offset_align)
|
||||
return 0;
|
||||
|
||||
BUG_ON(mapped_buffer->vm != vm);
|
||||
|
||||
/* mark the buffer as used */
|
||||
|
||||
Reference in New Issue
Block a user