From 84a53de76ceccb85835eb03c626be846f9b06095 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 29 Apr 2022 21:08:55 +0000 Subject: [PATCH] venus: add VN_RELAX_BASE_SLEEP_US env var for tuning cpu utils Cap the minimum to the current base sleep us 10. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_common.c | 8 +++++++- src/virtio/vulkan/vn_common.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c index 435e7cedd85..a0190cfff2d 100644 --- a/src/virtio/vulkan/vn_common.c +++ b/src/virtio/vulkan/vn_common.c @@ -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; diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h index a7db1fcdadb..b8079949bcd 100644 --- a/src/virtio/vulkan/vn_common.h +++ b/src/virtio/vulkan/vn_common.h @@ -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;