From 43e9a93fcaaeb5b9bb3fb6b2f69b623fca7cd69a Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 22 Dec 2023 04:02:47 -0800 Subject: [PATCH] iris: Don't search the exec list if BOs have never been added to one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whenever we use a BO in a batch, we need to find its corresponding exec list entry, either to a) record that it's been used, b) update whether it's being written, c) check for cross-batch implicit dependencies. bo->index exists to accelerate these lookups. If a BO is used multiple times by a batch, bo->index is its location in the list. Because the field is global, and a BO can in theory be used concurrently by multiple contexts, we need to double-check whether it's still there. If not, we fall back to a linear search of all BOs in the list, looking to see if our index was simply wrong (but presumably right for another context). However, there's one glaringly obvious case that we missed here. If bo->index is -1, then it's wrong for /all/ contexts, and in fact implies that said BO has never been added to any exec list, ever. This is quite common in fact: a new BO, never been used before, say from the BO cache, or streaming uploaders, gets used for the first time. In this case we can simply conclude that it's not in the list and skip the linear walk through all buffers referenced by the batch. Improves performance on an i7-12700 and A770: - SPECviewperf2020 catiav5test1: 72.9214% +/- 0.312735% (n=45) Cc: mesa-stable Reviewed-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: (cherry picked from commit d55b5d4af5d55a25837d8507840f4ab9b1075ea3) --- .pick_status.json | 2 +- src/gallium/drivers/iris/iris_batch.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index c5fedf38444..f495786d370 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -14,7 +14,7 @@ "description": "iris: Don't search the exec list if BOs have never been added to one", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index d1f75a5981d..293a3b8951d 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -278,6 +278,9 @@ find_exec_index(struct iris_batch *batch, struct iris_bo *bo) { unsigned index = READ_ONCE(bo->index); + if (index == -1) + return -1; + if (index < batch->exec_count && batch->exec_bos[index] == bo) return index;