代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lwip 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 01be1587c5e6771da95d6cf8d387c0b5ba15c275 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Wed, 27 Dec 2023 10:19:34 +0800
Subject: [PATCH] fix rte_ring_create time consuming
---
src/api/sockets.c | 2 +-
src/api/sys_arch.c | 63 ++++++++++++++++++++++++++++---------
src/include/arch/sys_arch.h | 4 +++
3 files changed, 54 insertions(+), 15 deletions(-)
diff --git a/src/api/sockets.c b/src/api/sockets.c
index 0cff4c4..d4cae53 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -2844,7 +2844,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
#endif
break;
case NETCONN_EVT_ERROR:
- if (conn->pending_err != ERR_OK) {
+ if ((conn->pending_err != ERR_OK) && (conn->pending_err != ERR_RST)) {
LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d, fd=%d\n", conn->pending_err, conn->socket));
}
sock->errevent = 1;
diff --git a/src/api/sys_arch.c b/src/api/sys_arch.c
index 1bc3aee..b80c0a8 100644
--- a/src/api/sys_arch.c
+++ b/src/api/sys_arch.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <rte_memzone.h>
+#include <rte_malloc.h>
#include "lwip/err.h"
#include "lwip/mem.h"
@@ -89,9 +90,50 @@ static int mbox_wait_func(void)
return eth_dev_poll();
}
+struct rte_ring *gazelle_ring_create_fast(const char *name, uint32_t size, uint32_t flags)
+{
+ ssize_t ring_size;
+ char ring_name[RTE_MEMZONE_NAMESIZE] = {0};
+ struct rte_ring *ring;
+
+ ring_size = rte_ring_get_memsize(size);
+ if (ring_size < 0) {
+ RTE_LOG(ERR, EAL, "rte_ring_get_memszie failed\n");
+ return NULL;
+ }
+
+ /*
+ * rte_ring_create is not used because it calls memzone_lookup_thread_unsafe function
+ * time consuming when there are many rings
+ */
+ ring = rte_malloc_socket(NULL, ring_size, RTE_CACHE_LINE_SIZE, rte_socket_id());
+ if (ring == NULL) {
+ RTE_LOG(ERR, EAL, "cannot create rte_ring for mbox\n");
+ return NULL;
+ }
+
+ if (snprintf(ring_name, sizeof(ring_name), "%s""%"PRIXPTR, name, (uintptr_t)ring) < 0) {
+ rte_free(ring);
+ RTE_LOG(ERR, EAL, "snprintf failed\n");
+ return NULL;
+ }
+
+ if (rte_ring_init(ring, ring_name, size, flags) != 0) {
+ rte_free(ring);
+ RTE_LOG(ERR, EAL, "cannot init rte_ring for mbox\n");
+ return NULL;
+ }
+
+ return ring;
+}
+
+void gazelle_ring_free_fast(struct rte_ring *ring)
+{
+ rte_free(ring);
+}
+
err_t sys_mbox_new(struct sys_mbox **mb, int size)
{
- int ret;
struct sys_mbox *mbox;
mbox = (struct sys_mbox *)memp_malloc(MEMP_SYS_MBOX);
@@ -100,21 +142,15 @@ err_t sys_mbox_new(struct sys_mbox **mb, int size)
}
mbox->flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
-
- ret = snprintf(mbox->name, sizeof(mbox->name), MBOX_NAME_PREFIX"%"PRIXPTR, (uintptr_t)mbox);
- if (ret < 0) {
- memp_free(MEMP_SYS_MBOX, mbox);
- return ERR_VAL;
- }
-
mbox->size = size;
mbox->socket_id = rte_socket_id();
- mbox->ring = rte_ring_create(mbox->name, mbox->size, mbox->socket_id, mbox->flags);
- if (!mbox->ring) {
- RTE_LOG(ERR, EAL, "cannot create rte_ring for mbox\n");
- memp_free(MEMP_SYS_MBOX, mbox);
+
+ mbox->ring = gazelle_ring_create_fast(MBOX_NAME_PREFIX, mbox->size, mbox->flags);
+ if (mbox->ring == NULL) {
+ sys_mbox_free(&mbox);
return ERR_MEM;
}
+
mbox->wait_fn = mbox_wait_func;
*mb = mbox;
@@ -125,7 +161,7 @@ void sys_mbox_free(struct sys_mbox **mb)
{
struct sys_mbox *mbox = *mb;
if (mbox->ring != NULL) {
- rte_ring_free(mbox->ring);
+ gazelle_ring_free_fast(mbox->ring);
mbox->ring = NULL;
}
memp_free(MEMP_SYS_MBOX, mbox);
diff --git a/src/include/arch/sys_arch.h b/src/include/arch/sys_arch.h
index 5e95f3d..bf7e437 100644
--- a/src/include/arch/sys_arch.h
+++ b/src/include/arch/sys_arch.h
@@ -123,6 +123,10 @@ static __rte_always_inline uint32_t gazelle_st_ring_dequeue_burst(struct rte_rin
return n;
}
+
+void gazelle_ring_free_fast(struct rte_ring *ring);
+struct rte_ring *gazelle_ring_create_fast(const char *name, uint32_t size, uint32_t flags);
+
#endif
void sys_calibrate_tsc(void);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。