Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/56113/?format=api
http://patches.dpdk.org/api/patches/56113/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1562309267-65831-1-git-send-email-xuanziyang2@huawei.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1562309267-65831-1-git-send-email-xuanziyang2@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1562309267-65831-1-git-send-email-xuanziyang2@huawei.com", "date": "2019-07-05T06:47:47", "name": "[v2,1/1] net/hinic: use mutex replace spin lock", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "c77d58afc0ccc7db8b38ae5244d59601244575c3", "submitter": { "id": 1321, "url": "http://patches.dpdk.org/api/people/1321/?format=api", "name": "Ziyang Xuan", "email": "xuanziyang2@huawei.com" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1562309267-65831-1-git-send-email-xuanziyang2@huawei.com/mbox/", "series": [ { "id": 5349, "url": "http://patches.dpdk.org/api/series/5349/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5349", "date": "2019-07-05T06:47:47", "name": "[v2,1/1] net/hinic: use mutex replace spin lock", "version": 2, "mbox": "http://patches.dpdk.org/series/5349/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/56113/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/56113/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7017F4C99;\n\tFri, 5 Jul 2019 08:35:26 +0200 (CEST)", "from huawei.com (szxga04-in.huawei.com [45.249.212.190])\n\tby dpdk.org (Postfix) with ESMTP id 0506C44C3\n\tfor <dev@dpdk.org>; Fri, 5 Jul 2019 08:35:24 +0200 (CEST)", "from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59])\n\tby Forcepoint Email with ESMTP id C738B211307827D97226\n\tfor <dev@dpdk.org>; Fri, 5 Jul 2019 14:35:21 +0800 (CST)", "from tester.localdomain (10.175.119.39) by\n\tDGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP\n\tServer id 14.3.439.0; Fri, 5 Jul 2019 14:35:14 +0800" ], "From": "Ziyang Xuan <xuanziyang2@huawei.com>", "To": "<dev@dpdk.org>", "CC": "<ferruh.yigit@intel.com>, <cloud.wangxiaoyun@huawei.com>,\n\t<luoxianjun@huawei.com>, <tanya.brokhman@huawei.com>, Ziyang Xuan\n\t<xuanziyang2@huawei.com>", "Date": "Fri, 5 Jul 2019 14:47:47 +0800", "Message-ID": "<1562309267-65831-1-git-send-email-xuanziyang2@huawei.com>", "X-Mailer": "git-send-email 1.8.3.1", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.175.119.39]", "X-CFilter-Loop": "Reflected", "Subject": "[dpdk-dev] [PATCH v2 1/1] net/hinic: use mutex replace spin lock", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Using spin lock to protect critical resources\nof sending mgmt messages. This will make high\nCPU usage for rte_delay_ms when sending mgmt\nmessages frequently. We can use mutex to protect\nthe critical resources and usleep to reduce CPU\nusage while keep functioning properly.\n\nSigned-off-by: Ziyang Xuan <xuanziyang2@huawei.com>\n---\n drivers/net/hinic/Makefile | 1 +\n drivers/net/hinic/base/hinic_compat.h | 25 +++++++++++++++++++++++++\n drivers/net/hinic/base/hinic_pmd_mgmt.c | 19 ++++++++++++-------\n drivers/net/hinic/base/hinic_pmd_mgmt.h | 6 ++----\n 4 files changed, 40 insertions(+), 11 deletions(-)", "diff": "diff --git a/drivers/net/hinic/Makefile b/drivers/net/hinic/Makefile\nindex 123a626..42b4a78 100644\n--- a/drivers/net/hinic/Makefile\n+++ b/drivers/net/hinic/Makefile\n@@ -20,6 +20,7 @@ endif\n LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring\n LDLIBS += -lrte_ethdev -lrte_net -lrte_hash\n LDLIBS += -lrte_bus_pci\n+LDLIBS += -lpthread\n \n EXPORT_MAP := rte_pmd_hinic_version.map\n \ndiff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h\nindex 48643c8..f599947 100644\n--- a/drivers/net/hinic/base/hinic_compat.h\n+++ b/drivers/net/hinic/base/hinic_compat.h\n@@ -7,6 +7,8 @@\n \n #include <stdint.h>\n #include <sys/time.h>\n+#include <unistd.h>\n+#include <pthread.h>\n #include <rte_common.h>\n #include <rte_byteorder.h>\n #include <rte_memzone.h>\n@@ -253,4 +255,27 @@ static inline void hinic_be32_to_cpu(void *data, u32 len)\n \t}\n }\n \n+static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,\n+\t\t\t\t\tconst pthread_mutexattr_t *mattr)\n+{\n+\tint err;\n+\n+\terr = pthread_mutex_init(pthreadmutex, mattr);\n+\tif (unlikely(err))\n+\t\tPMD_DRV_LOG(ERR, \"Fail to initialize mutex, error: %d\", err);\n+\n+\treturn err;\n+}\n+\n+static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)\n+{\n+\tint err;\n+\n+\terr = pthread_mutex_destroy(pthreadmutex);\n+\tif (unlikely(err))\n+\t\tPMD_DRV_LOG(ERR, \"Fail to destroy mutex, error: %d\", err);\n+\n+\treturn err;\n+}\n+\n #endif /* _HINIC_COMPAT_H_ */\ndiff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.c b/drivers/net/hinic/base/hinic_pmd_mgmt.c\nindex bc18765..a18e567 100644\n--- a/drivers/net/hinic/base/hinic_pmd_mgmt.c\n+++ b/drivers/net/hinic/base/hinic_pmd_mgmt.c\n@@ -342,8 +342,9 @@ static int hinic_pf_to_mgmt_init(struct hinic_hwdev *hwdev)\n \thwdev->pf_to_mgmt = pf_to_mgmt;\n \tpf_to_mgmt->hwdev = hwdev;\n \n-\tspin_lock_init(&pf_to_mgmt->async_msg_lock);\n-\tspin_lock_init(&pf_to_mgmt->sync_msg_lock);\n+\terr = hinic_mutex_init(&pf_to_mgmt->sync_msg_lock, NULL);\n+\tif (err)\n+\t\tgoto mutex_init_err;\n \n \terr = alloc_msg_buf(pf_to_mgmt);\n \tif (err) {\n@@ -363,6 +364,9 @@ static int hinic_pf_to_mgmt_init(struct hinic_hwdev *hwdev)\n \tfree_msg_buf(pf_to_mgmt);\n \n alloc_msg_buf_err:\n+\thinic_mutex_destroy(&pf_to_mgmt->sync_msg_lock);\n+\n+mutex_init_err:\n \tkfree(pf_to_mgmt);\n \n \treturn err;\n@@ -378,6 +382,7 @@ static void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev)\n \n \thinic_api_cmd_free(pf_to_mgmt->cmd_chain);\n \tfree_msg_buf(pf_to_mgmt);\n+\thinic_mutex_destroy(&pf_to_mgmt->sync_msg_lock);\n \tkfree(pf_to_mgmt);\n }\n \n@@ -391,7 +396,7 @@ static void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev)\n \tu32 timeo;\n \tint err, i;\n \n-\tspin_lock(&pf_to_mgmt->sync_msg_lock);\n+\tpthread_mutex_lock(&pf_to_mgmt->sync_msg_lock);\n \n \tSYNC_MSG_ID_INC(pf_to_mgmt);\n \trecv_msg = &pf_to_mgmt->recv_resp_msg_from_mgmt;\n@@ -450,7 +455,7 @@ static void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev)\n unlock_sync_msg:\n \tif (err && out_size)\n \t\t*out_size = 0;\n-\tspin_unlock(&pf_to_mgmt->sync_msg_lock);\n+\tpthread_mutex_unlock(&pf_to_mgmt->sync_msg_lock);\n \treturn err;\n }\n \n@@ -497,13 +502,13 @@ int hinic_msg_to_mgmt_no_ack(void *hwdev, enum hinic_mod_type mod, u8 cmd,\n \t\treturn err;\n \t}\n \n-\tspin_lock(&pf_to_mgmt->sync_msg_lock);\n+\tpthread_mutex_lock(&pf_to_mgmt->sync_msg_lock);\n \n \terr = send_msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,\n \t\t\t\t HINIC_MSG_NO_ACK, HINIC_MSG_DIRECT_SEND,\n \t\t\t\t MSG_NO_RESP);\n \n-\tspin_unlock(&pf_to_mgmt->sync_msg_lock);\n+\tpthread_mutex_unlock(&pf_to_mgmt->sync_msg_lock);\n \n \treturn err;\n }\n@@ -713,7 +718,7 @@ int hinic_aeq_poll_msg(struct hinic_eq *eq, u32 timeout, void *param)\n \t\t\t}\n \n \t\t\tif (timeout != 0)\n-\t\t\t\trte_delay_ms(1);\n+\t\t\t\tusleep(1000);\n \t\t} while (time_before(jiffies, end));\n \n \t\tif (err != HINIC_OK) /*poll time out*/\ndiff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.h b/drivers/net/hinic/base/hinic_pmd_mgmt.h\nindex 23951cb..7804708 100644\n--- a/drivers/net/hinic/base/hinic_pmd_mgmt.h\n+++ b/drivers/net/hinic/base/hinic_pmd_mgmt.h\n@@ -81,10 +81,8 @@ enum comm_pf_to_mgmt_event_state {\n struct hinic_msg_pf_to_mgmt {\n \tstruct hinic_hwdev\t\t*hwdev;\n \n-\t/* Async cmd can not be scheduling */\n-\tspinlock_t\t\t\tasync_msg_lock;\n-\t/* spinlock for sync message */\n-\tspinlock_t\t\t\tsync_msg_lock;\n+\t/* mutex for sync message */\n+\tpthread_mutex_t\t\t\tsync_msg_lock;\n \n \tvoid\t\t\t\t*async_msg_buf;\n \tvoid\t\t\t\t*sync_msg_buf;\n", "prefixes": [ "v2", "1/1" ] }{ "id": 56113, "url": "