venus: add VN_RELAX_BASE_SLEEP_US env var for tuning cpu utils
authorYiwei Zhang <zzyiwei@chromium.org>
Fri, 29 Apr 2022 21:08:55 +0000 (21:08 +0000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 2 May 2022 20:20:43 +0000 (20:20 +0000)
Cap the minimum to the current base sleep us 10.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16256>

src/virtio/vulkan/vn_common.c
src/virtio/vulkan/vn_common.h

index 435e7ce..a0190cf 100644 (file)
@@ -19,6 +19,8 @@
 #include "venus-protocol/vn_protocol_driver_info.h"
 #include "vk_enum_to_str.h"
 
+#define VN_RELAX_MIN_BASE_SLEEP_US (10)
+
 static const struct debug_control vn_debug_options[] = {
    { "init", VN_DEBUG_INIT },
    { "result", VN_DEBUG_RESULT },
@@ -48,6 +50,10 @@ vn_env_init_once(void)
       debug_get_num_option("VN_DRAW_CMD_BATCH_LIMIT", UINT32_MAX);
    if (!vn_env.draw_cmd_batch_limit)
       vn_env.draw_cmd_batch_limit = UINT32_MAX;
+   vn_env.relax_base_sleep_us = debug_get_num_option(
+      "VN_RELAX_BASE_SLEEP_US", VN_RELAX_MIN_BASE_SLEEP_US);
+   vn_env.relax_base_sleep_us =
+      MAX2(vn_env.relax_base_sleep_us, VN_RELAX_MIN_BASE_SLEEP_US);
 }
 
 void
@@ -101,7 +107,7 @@ vn_relax(uint32_t *iter, const char *reason)
     * keep doubling both sleep length and count.
     */
    const uint32_t busy_wait_order = 4;
-   const uint32_t base_sleep_us = 10;
+   const uint32_t base_sleep_us = vn_env.relax_base_sleep_us;
    const uint32_t warn_order = 12;
    const uint32_t abort_order = 14;
 
index a7db1fc..b807994 100644 (file)
@@ -183,6 +183,7 @@ struct vn_env {
    uint64_t perf;
    /* zero will be overridden to UINT32_MAX as no limit */
    uint32_t draw_cmd_batch_limit;
+   uint32_t relax_base_sleep_us;
 };
 extern struct vn_env vn_env;