Projects
Eulaceura:Mainline:GA
libwd
_service:obs_scm:0050-util-optimize-for-wd_hand...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0050-util-optimize-for-wd_handle_msg_sync.patch of Package libwd
From f36aa5f7e8f82a90aa0cb729bf00cc51f76970d5 Mon Sep 17 00:00:00 2001 From: Wenkai Lin <linwenkai6@hisilicon.com> Date: Fri, 29 Mar 2024 17:01:03 +0800 Subject: [PATCH 50/52] util: optimize for wd_handle_msg_sync 1. Separate rx_cnt auto-increment and judgment. 2. Reduce the condition judgment in the case of eagain. Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> Signed-off-by: Qi Tao <taoqi10@huawei.com> --- wd_util.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/wd_util.c b/wd_util.c index 2635dc3..0744ff0 100644 --- a/wd_util.c +++ b/wd_util.c @@ -1822,24 +1822,28 @@ int wd_handle_msg_sync(struct wd_alg_driver *drv, struct wd_msg_handle *msg_hand do { if (epoll_en) { ret = wd_ctx_wait(ctx, POLL_TIME); - if (ret < 0) + if (unlikely(ret < 0)) WD_ERR("wd ctx wait timeout(%d)!\n", ret); } ret = msg_handle->recv(drv, ctx, msg); - if (ret == -WD_EAGAIN) { - if (unlikely(rx_cnt++ >= timeout)) { - WD_ERR("failed to recv msg: timeout!\n"); - return -WD_ETIMEDOUT; + if (ret != -WD_EAGAIN) { + if (unlikely(ret < 0)) { + WD_ERR("failed to recv msg: error = %d!\n", ret); + return ret; } + break; + } - if (balance && *balance > WD_BALANCE_THRHD) - usleep(1); - } else if (unlikely(ret < 0)) { - WD_ERR("failed to recv msg: error = %d!\n", ret); - return ret; + rx_cnt++; + if (unlikely(rx_cnt >= timeout)) { + WD_ERR("failed to recv msg: timeout!\n"); + return -WD_ETIMEDOUT; } - } while (ret < 0); + + if (balance && *balance > WD_BALANCE_THRHD) + usleep(1); + } while (1); if (balance) *balance = rx_cnt; -- 2.25.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2