!203 [sync] PR-199: 同步openEuler仓库补丁

From: @openeuler-sync-bot 
Reviewed-by: @wu-changsheng 
Signed-off-by: @wu-changsheng
This commit is contained in:
openeuler-ci-bot 2022-12-17 11:17:48 +00:00 committed by Gitee
commit 37eeecde2a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 312 additions and 1 deletions

View File

@ -0,0 +1,195 @@
From 850f4dced20b3bcbb838239037ac230d99576e4f Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Fri, 16 Dec 2022 17:31:41 +0800
Subject: [PATCH] stack thread params default val
---
src/common/gazelle_opt.h | 2 +
src/lstack/core/lstack_cfg.c | 82 ++++++++++++++++++++----------------
src/lstack/lstack.conf | 6 +--
3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
index 7e55422..94f274d 100644
--- a/src/common/gazelle_opt.h
+++ b/src/common/gazelle_opt.h
@@ -49,6 +49,8 @@
#define RXTX_NB_MBUF_DEFAULT (128 * 2000) /* mbuf per connect * connect num. size of mbuf is 2536 Byte */
#define RXTX_NB_MBUF_MAX (2560 * 2000)
+#define STACK_THREAD_DEFAULT 4
+#define STACK_NIC_READ_DEFAULT 128
#define MBUF_MAX_DATA_LEN 1460
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index 9c23115..55d16f9 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -222,29 +222,29 @@ static int32_t get_param_idx(int32_t argc, char **argv, const char *param)
static bool have_corelist_arg(int32_t argc, char **argv)
{
- for (uint32_t i = 0; i < argc; i++) {
- if (strncmp(argv[i], OPT_BIND_CORELIST, strlen(OPT_BIND_CORELIST)) == 0) {
- return true;
- }
-
- if (strncmp(argv[i], "--lcores", strlen("--lcores")) == 0) {
- return true;
- }
+ for (uint32_t i = 0; i < argc; i++) {
+ if (strncmp(argv[i], OPT_BIND_CORELIST, strlen(OPT_BIND_CORELIST)) == 0) {
+ return true;
+ }
- if (strncmp(argv[i], "-c", strlen("-c")) == 0) {
- return true;
- }
+ if (strncmp(argv[i], "--lcores", strlen("--lcores")) == 0) {
+ return true;
+ }
+
+ if (strncmp(argv[i], "-c", strlen("-c")) == 0) {
+ return true;
+ }
- if (strncmp(argv[i], "-s", strlen("-s")) == 0) {
- return true;
- }
+ if (strncmp(argv[i], "-s", strlen("-s")) == 0) {
+ return true;
+ }
- if (strncmp(argv[i], "-S", strlen("-S")) == 0) {
- return true;
- }
- }
+ if (strncmp(argv[i], "-S", strlen("-S")) == 0) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
static int32_t parse_stack_cpu_number(void)
@@ -733,7 +733,9 @@ static int32_t parse_send_connect_number(void)
arg = config_lookup(&g_config, "send_connect_number");
if (arg == NULL) {
- return -EINVAL;
+ g_config_params.send_connect_number = STACK_THREAD_DEFAULT;
+ LSTACK_PRE_LOG(LSTACK_ERR, "use default send_connect_number %d.\n", STACK_THREAD_DEFAULT);
+ return 0;
}
int32_t val = config_setting_get_int(arg);
@@ -753,7 +755,9 @@ static int32_t parse_read_connect_number(void)
arg = config_lookup(&g_config, "read_connect_number");
if (arg == NULL) {
- return -EINVAL;
+ g_config_params.read_connect_number = STACK_THREAD_DEFAULT;
+ LSTACK_PRE_LOG(LSTACK_ERR, "use default read_connect_number %d.\n", STACK_THREAD_DEFAULT);
+ return 0;
}
int32_t val = config_setting_get_int(arg);
@@ -773,7 +777,9 @@ static int32_t parse_rpc_number(void)
arg = config_lookup(&g_config, "rpc_number");
if (arg == NULL) {
- return -EINVAL;
+ g_config_params.rpc_number = STACK_THREAD_DEFAULT;
+ LSTACK_PRE_LOG(LSTACK_ERR, "use default rpc_number %d.\n", STACK_THREAD_DEFAULT);
+ return 0;
}
int32_t val = config_setting_get_int(arg);
@@ -793,7 +799,9 @@ static int32_t parse_nic_read_number(void)
arg = config_lookup(&g_config, "nic_read_number");
if (arg == NULL) {
- return -EINVAL;
+ g_config_params.nic_read_number = STACK_NIC_READ_DEFAULT;
+ LSTACK_PRE_LOG(LSTACK_ERR, "use default nic_read_number %d.\n", STACK_NIC_READ_DEFAULT);
+ return 0;
}
int32_t val = config_setting_get_int(arg);
@@ -922,15 +930,15 @@ static int32_t parse_unix_prefix(void)
int32_t ret = 0;
ret = memset_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
- 0, sizeof(g_config_params.unix_socket_filename));
+ 0, sizeof(g_config_params.unix_socket_filename));
if (ret != EOK) {
- return ret;
+ return ret;
}
ret = strncpy_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
- GAZELLE_RUN_DIR, strlen(GAZELLE_RUN_DIR) + 1);
+ GAZELLE_RUN_DIR, strlen(GAZELLE_RUN_DIR) + 1);
if (ret != EOK) {
- return ret;
+ return ret;
}
unix_prefix = config_lookup(&g_config, "unix_prefix");
@@ -938,21 +946,21 @@ static int32_t parse_unix_prefix(void)
if (unix_prefix) {
args = config_setting_get_string(unix_prefix);
- if (filename_check(args)) {
- return -EINVAL;
- }
+ if (filename_check(args)) {
+ return -EINVAL;
+ }
- ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
- args, strlen(args) + 1);
- if (ret != EOK) {
- return ret;
- }
+ ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
+ args, strlen(args) + 1);
+ if (ret != EOK) {
+ return ret;
+ }
}
ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
- GAZELLE_REG_SOCK_FILENAME, strlen(GAZELLE_REG_SOCK_FILENAME) + 1);
+ GAZELLE_REG_SOCK_FILENAME, strlen(GAZELLE_REG_SOCK_FILENAME) + 1);
if (ret != EOK) {
- return ret;
+ return ret;
}
return 0;
diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf
index ee96d4d..47140ad 100644
--- a/src/lstack/lstack.conf
+++ b/src/lstack/lstack.conf
@@ -21,11 +21,11 @@ mbuf_pool_size = 256000
#protocol stack thread per loop params
#send connect to nic
-send_connect_number = 8
+send_connect_number = 4
#read data form protocol stack into recv_ring
-read_connect_number = 8
+read_connect_number = 4
#process rpc msg number
-rpc_number = 8
+rpc_number = 4
#read nic pkts number
nic_read_number = 128
--
2.23.0

View File

@ -0,0 +1,72 @@
From bad6066508dcefeabac220df948d7505c3191b66 Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Fri, 16 Dec 2022 20:13:57 +0800
Subject: [PATCH 2/2] optimite net type
---
src/lstack/core/lstack_lwip.c | 2 +-
src/lstack/netif/lstack_vdev.c | 28 +++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 0aaae30..d4e2d9c 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -935,7 +935,7 @@ void read_recv_list(struct protocol_stack *stack, uint32_t max_num)
list_for_each_safe(node, temp, list) {
sock = container_of(node, struct lwip_sock, recv_list);
- if (++read_num >= max_num) {
+ if (++read_num > max_num) {
/* list head move to next send */
list_del_node(&stack->recv_list);
list_add_node(&sock->recv_list, &stack->recv_list);
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 5bdaf63..f6e7a1a 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -40,6 +40,11 @@
#define INUSE_TX_PKTS_WATERMARK (VDEV_TX_QUEUE_SZ >> 2)
#define USED_RX_PKTS_WATERMARK (FREE_RX_QUEUE_SZ >> 2)
+#define IPV4_MASK (0xf0)
+#define IPV4_VERION (0x40)
+
+#define TCP_HDR_LEN(tcp_hdr) ((tcp_hdr->data_off & 0xf0) >> 2)
+
static uint32_t ltran_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkts, uint32_t max_mbuf)
{
uint32_t rcvd_pkts;
@@ -78,11 +83,24 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt
}
for (uint32_t i = 0; i < pkt_num; i++) {
- struct rte_net_hdr_lens hdr_lens;
- pkts[i]->packet_type = rte_net_get_ptype(pkts[i], &hdr_lens, RTE_PTYPE_ALL_MASK);
- pkts[i]->l2_len = hdr_lens.l2_len;
- pkts[i]->l3_len = hdr_lens.l3_len;
- pkts[i]->l4_len = hdr_lens.l4_len;
+ struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(pkts[i], struct rte_ether_hdr *);
+ if (unlikely(RTE_BE16(RTE_ETHER_TYPE_IPV4) != ethh->ether_type)) {
+ continue;
+ }
+ pkts[i]->l2_len = sizeof(struct rte_ether_hdr);
+
+ struct rte_ipv4_hdr *iph = rte_pktmbuf_mtod_offset(pkts[i], struct rte_ipv4_hdr *,
+ sizeof(struct rte_ether_hdr));
+ if (unlikely((iph->version_ihl & IPV4_MASK) != IPV4_VERION)) {
+ continue;
+ }
+ pkts[i]->l3_len = sizeof(struct rte_ipv4_hdr);
+
+ struct rte_tcp_hdr *tcp_hdr = rte_pktmbuf_mtod_offset(pkts[i], struct rte_tcp_hdr *,
+ sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));
+ pkts[i]->l4_len = TCP_HDR_LEN(tcp_hdr);
+
+ pkts[i]->packet_type = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP;
}
return rte_gro_reassemble_burst(pkts, pkt_num, &gro_param);
}
--
2.8.4.windows.1

View File

@ -0,0 +1,36 @@
From ccfc2e04ee98ee843c1c5365bfa0e0ddfe5bf108 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Sat, 17 Dec 2022 15:09:31 +0800
Subject: [PATCH] app bind numa when epoll/poll create
---
src/lstack/api/lstack_epoll.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index 4ea6474..605984f 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -204,6 +204,9 @@ int32_t lstack_do_epoll_create(int32_t fd)
update_epoll_max_stack(wakeup);
change_epollfd_kernel_thread(wakeup, wakeup->bind_stack, wakeup->max_stack);
wakeup->bind_stack = wakeup->max_stack;
+ if (get_global_cfg_params()->app_bind_numa) {
+ bind_to_stack_numa(wakeup->bind_stack);
+ }
return fd;
}
@@ -545,6 +548,9 @@ static int32_t init_poll_wakeup_data(struct wakeup_poll *wakeup)
uint16_t bind_id = find_max_cnt_stack(stack_count, stack_group->stack_num, wakeup->bind_stack);
change_epollfd_kernel_thread(wakeup, wakeup->bind_stack, stack_group->stacks[bind_id]);
wakeup->bind_stack = stack_group->stacks[bind_id];
+ if (get_global_cfg_params()->app_bind_numa) {
+ bind_to_stack_numa(wakeup->bind_stack);
+ }
return 0;
}
--
2.23.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.1
Release: 34
Release: 35
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -173,6 +173,9 @@ Patch9155: 0155-stack-thread-parms-config-by-conf.patch
Patch9156: 0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch
Patch9157: 0157-move-select_thread_path-after-posix_api_init.patch
Patch9158: 0158-add-RXTX_NB_MBUF_MAX-to-limit-mbuf_pool_size-to-its-.patch
Patch9159: 0159-stack-thread-params-default-val.patch
Patch9160: 0160-optimite-net-type.patch
Patch9161: 0161-app-bind-numa-when-epoll-poll-create.patch
%description
%{name} is a high performance user-mode stack.
@ -213,6 +216,11 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Sat Dec 17 2022 jiangheng <jiangheng14@huawei.com> - 1.0.1-35
- optimite net type
app bind numa when epoll/poll create
stack thread params set dafult value
* Sat Dec 17 2022 kircher <majun65@huawei.com> - 1.0.1-34
- add RXTX_NB_MBUF_MAX to limit mbuf_pool_size to its range