Module: Mesa Branch: main Commit: 5f3e50b27cfaeff09cd242c39c28f3a241fef5b7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f3e50b27cfaeff09cd242c39c28f3a241fef5b7
Author: Chia-I Wu <[email protected]> Date: Wed Feb 9 15:48:36 2022 -0800 venus: trace vn_ring_wait_space It is good to know that we run out of ring space and have to wait. This happens easily with fossilize-replay because encoding a vkCreateGraphicsPipeline takes microseconds while executing it can take milliseconds, >100ms sometimes. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14966> --- src/virtio/vulkan/vn_ring.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/virtio/vulkan/vn_ring.c b/src/virtio/vulkan/vn_ring.c index fc821cfc338..39f77925780 100644 --- a/src/virtio/vulkan/vn_ring.c +++ b/src/virtio/vulkan/vn_ring.c @@ -101,19 +101,40 @@ vn_ring_wait_seqno(const struct vn_ring *ring, uint32_t seqno) } while (true); } +static bool +vn_ring_has_space(const struct vn_ring *ring, + uint32_t size, + uint32_t *out_head) +{ + const uint32_t head = vn_ring_load_head(ring); + if (likely(ring->cur + size - head <= ring->buffer_size)) { + *out_head = head; + return true; + } + + return false; +} + static uint32_t vn_ring_wait_space(const struct vn_ring *ring, uint32_t size) { assert(size <= ring->buffer_size); - /* see the reasoning in vn_ring_wait_seqno */ - uint32_t iter = 0; - do { - const uint32_t head = vn_ring_load_head(ring); - if (ring->cur + size - head <= ring->buffer_size) - return head; - vn_relax(&iter, "ring space"); - } while (true); + uint32_t head; + if (likely(vn_ring_has_space(ring, size, &head))) + return head; + + { + VN_TRACE_FUNC(); + + /* see the reasoning in vn_ring_wait_seqno */ + uint32_t iter = 0; + do { + vn_relax(&iter, "ring space"); + if (vn_ring_has_space(ring, size, &head)) + return head; + } while (true); + } } void
