sync update gazelle max numa nodes 8

(cherry picked from commit 26d5d01d849a92f24bac7fc68b38890f0193908e)
This commit is contained in:
yinbin 2025-03-04 19:41:29 +08:00 committed by openeuler-sync-bot
parent 4df56aade3
commit 71fa5d085f
6 changed files with 335 additions and 1 deletions

View File

@ -0,0 +1,191 @@
From a237d1d8515d602e152546f182b1769fd31fa8b7 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Sat, 18 Jan 2025 21:32:23 +0800
Subject: [PATCH] add xdp tx checksum/tso offload
---
src/lstack/core/lstack_cfg.c | 20 ++++++++++----------
src/lstack/core/lstack_dpdk.c | 21 ++++++---------------
src/lstack/include/lstack_cfg.h | 8 ++++++++
src/lstack/include/lstack_dpdk.h | 1 -
src/lstack/netif/lstack_ethdev.c | 11 +++++++++--
src/lstack/netif/lstack_vdev.c | 2 +-
6 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index 3d49cc3..04ceb89 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -91,7 +91,6 @@ static int32_t parse_flow_bifurcation(void);
static int32_t parse_stack_interrupt(void);
static int32_t parse_stack_num(void);
static int32_t parse_xdp_eth_name(void);
-static bool xdp_eth_enabled(void);
#define PARSE_ARG(_arg, _arg_string, _default_val, _min_val, _max_val, _ret) \
do { \
@@ -1491,6 +1490,7 @@ static int dpdk_dev_get_iface_name(char *vdev_str)
char *iface_value = NULL;
char *next_token = NULL;
char vdev_str_cp[strlen(vdev_str) + 1];
+ int idx = 0;
/* To prevent the original string from being modified, use a copied string. */
if (strcpy_s(vdev_str_cp, sizeof(vdev_str_cp), vdev_str) != 0) {
@@ -1498,7 +1498,15 @@ static int dpdk_dev_get_iface_name(char *vdev_str)
return -1;
}
- token = strtok_s(vdev_str_cp, ",", &next_token);
+ while (vdev_str_cp[idx] == ' ') {
+ idx++;
+ }
+
+ if (strncmp(&vdev_str_cp[idx], "net_af_xdp", strlen("net_af_xdp")) != 0) {
+ return 0;
+ }
+
+ token = strtok_s(&vdev_str_cp[idx], ",", &next_token);
while (token != NULL) {
if (strncmp(token, VDEV_ARG_IFACE, strlen(VDEV_ARG_IFACE)) == 0) {
iface_value = token + strlen(VDEV_ARG_IFACE) + 1;
@@ -1535,11 +1543,3 @@ static int32_t parse_xdp_eth_name(void)
return ret;
}
-
-static bool xdp_eth_enabled(void)
-{
- if (strlen(g_config_params.xdp_eth_name)) {
- return true;
- }
- return false;
-}
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 3023a6c..fcb78ca 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -52,7 +52,6 @@
struct eth_params {
uint16_t port_id;
- bool is_xdp;
uint16_t nb_queues;
uint16_t nb_rx_desc;
@@ -155,7 +154,12 @@ struct rte_mempool *create_pktmbuf_mempool(const char *name, uint32_t nb_mbuf,
}
/* time stamp before pbuf_custom as priv_data */
- uint16_t private_size = RTE_ALIGN(sizeof(struct mbuf_private), RTE_CACHE_LINE_SIZE);
+ uint16_t private_size = sizeof(struct mbuf_private);
+ if (xdp_eth_enabled()) {
+ /* reserved for xdp metadata, see struct xsk_tx_metadata in /usr/include/linux/if_xdp.h */
+ private_size += 24;
+ }
+ private_size = RTE_ALIGN(private_size, RTE_CACHE_LINE_SIZE);
pool = rte_pktmbuf_pool_create(pool_name, nb_mbuf, mbuf_cache_size, private_size, MBUF_SZ, numa_id);
if (pool == NULL) {
LSTACK_LOG(ERR, LSTACK, "cannot create %s pool rte_err=%d\n", pool_name, rte_errno);
@@ -400,16 +404,6 @@ static int eth_params_rss(struct rte_eth_conf *conf, struct rte_eth_dev_info *de
return rss_enable;
}
-bool dpdk_nic_is_xdp(void)
-{
- struct protocol_stack_group *stack_group = get_protocol_stack_group();
- /* eth_params is null in ltran mode */
- if (stack_group->eth_params == NULL) {
- return false;
- }
- return stack_group->eth_params->is_xdp;
-}
-
static int eth_params_init(struct eth_params *eth_params, uint16_t port_id, uint16_t nb_queues, int *rss_enable)
{
struct rte_eth_dev_info dev_info;
@@ -439,9 +433,6 @@ static int eth_params_init(struct eth_params *eth_params, uint16_t port_id, uint
eth_params->conf.intr_conf.rxq = get_global_cfg_params()->stack_interrupt;
eth_params_checksum(&eth_params->conf, &dev_info);
- if (strcmp(dev_info.driver_name, "net_af_xdp") == 0) {
- eth_params->is_xdp = true;
- }
if (!get_global_cfg_params()->tuple_filter) {
*rss_enable = eth_params_rss(&eth_params->conf, &dev_info);
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index 07a97cb..d59407b 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -165,6 +165,14 @@ static inline uint8_t use_ltran(void)
return get_global_cfg_params()->use_ltran;
}
+static inline bool xdp_eth_enabled(void)
+{
+ if (strlen(get_global_cfg_params()->xdp_eth_name)) {
+ return true;
+ }
+ return false;
+}
+
int cfg_init(void);
int gazelle_param_init(int *argc, char **argv);
int gazelle_copy_param(const char *param, bool is_double, int *argc, char argv[][PATH_MAX]);
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
index c2142d6..6251be7 100644
--- a/src/lstack/include/lstack_dpdk.h
+++ b/src/lstack/include/lstack_dpdk.h
@@ -64,7 +64,6 @@ int32_t dpdk_init_lstack_kni(void);
void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id);
void dpdk_nic_features_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id);
-bool dpdk_nic_is_xdp(void);
uint32_t dpdk_pktmbuf_mempool_num(void);
uint32_t dpdk_total_socket_memory(void);
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index 315cced..3b859d2 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -364,14 +364,21 @@ static err_t eth_dev_init(struct netif *netif)
netif->hwaddr_len = ETHER_ADDR_LEN;
- if (dpdk_nic_is_xdp()) {
+ if (xdp_eth_enabled()) {
netif_set_rxol_flags(netif, RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
RTE_ETH_RX_OFFLOAD_IPV4_CKSUM);
+ netif_set_txol_flags(netif, RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO);
+ /* 16: see kernel MAX_SKB_FRAGS define in skbuff.h */
+ netif_set_max_pbuf_frags(netif, 16);
} else {
netif_set_rxol_flags(netif, get_protocol_stack_group()->rx_offload);
+ netif_set_txol_flags(netif, get_protocol_stack_group()->tx_offload);
+ /* 40: dpdk pmd support 40 max segs */
+ netif_set_max_pbuf_frags(netif, 40);
}
- netif_set_txol_flags(netif, get_protocol_stack_group()->tx_offload);
+ netif_set_min_tso_seglen(netif, 256);
+
if (get_global_cfg_params()->stack_mode_rtc) {
netif_set_rtc_mode(netif);
}
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index b1d1a1b..2eaeb1f 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -147,7 +147,7 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt
}
if (get_protocol_stack_group()->rx_offload == 0 || /* skip gro when tcp/ip cksum offloads disable */
- dpdk_nic_is_xdp() || /* kernel has done GRO */
+ xdp_eth_enabled() || /* kernel has done GRO */
(get_global_cfg_params()->vlan_mode >= 0
&& !(get_protocol_stack_group()->rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP))) {
return pkt_num;
--
2.33.0

View File

@ -0,0 +1,35 @@
From 4ad01c9c13f3f0837d19194463d6493ee5f1c243 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Tue, 21 Jan 2025 11:43:02 +0800
Subject: [PATCH] RTC-mode: fix gazellectl can't print connenct info
---
src/lstack/core/lstack_protocol_stack.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index fcc0ad7..cb1b2b8 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -704,6 +704,7 @@ int stack_setup_app_thread(void)
{
static PER_THREAD int first_flags = 1;
static _Atomic uint32_t queue_id = 0;
+ struct protocol_stack *stack;
if (likely(first_flags == 0)) {
return 0;
@@ -723,6 +724,10 @@ int stack_setup_app_thread(void)
free(t_params);
return -1;
}
+
+ stack = get_protocol_stack();
+ stack_set_state(stack, RUNNING);
+
atomic_fetch_add(&g_stack_group.stack_num, 1);
free(t_params);
return 0;
--
2.33.0

View File

@ -0,0 +1,25 @@
From 76c84f12bbcaf36f367252adc0a6da1bfee05de1 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Sat, 15 Feb 2025 16:41:13 +0800
Subject: [PATCH] Connect: fix benchmark_dws connect failed
---
src/lstack/api/lstack_wrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 97e927a..e90c523 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -404,7 +404,7 @@ static int32_t do_connect(int32_t s, const struct sockaddr *addr, socklen_t addr
/* When the socket is POSIX_LWIP_OR_KERNEL, connect to lwip first and then connect to kernel. */
ret = g_wrap_api->connect_fn(s, addr, addrlen);
- if (ret == 0 || (ret != 0 && errno == EINPROGRESS)) {
+ if (ret == 0 || (ret != 0 && (errno == EINPROGRESS || errno == EISCONN))) {
POSIX_SET_TYPE(sock, POSIX_LWIP);
} else {
ret = posix_api->connect_fn(s, addr, addrlen);
--
2.33.0

View File

@ -0,0 +1,33 @@
From 3619605574d0c624513a10ecd543cc2bc1608f7b Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Fri, 24 Jan 2025 14:18:26 +0800
Subject: [PATCH] Protocal: fixing deathlock between protocol threads and app
thread
---
src/lstack/core/lstack_lwip.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 648da58..3bb943f 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -267,7 +267,14 @@ struct pbuf *do_lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type typ
static inline bool pbuf_allow_append(struct pbuf *pbuf, uint16_t remain_size)
{
- pthread_spin_lock(&pbuf->pbuf_lock);
+ int ret;
+
+ /* Using pthread_spin_trylock to avoid deadlock between app thread and lstack threads */
+ ret = pthread_spin_trylock(&pbuf->pbuf_lock);
+ if (ret != 0) {
+ return false;
+ }
+
if (pbuf->tot_len > remain_size) {
pthread_spin_unlock(&pbuf->pbuf_lock);
return false;
--
2.33.0

View File

@ -0,0 +1,38 @@
From 9e8c4da250bb57f0ba6d59a98d0f601a853d4f7e Mon Sep 17 00:00:00 2001
From: compile_success <980965867@qq.com>
Date: Tue, 4 Mar 2025 08:14:18 +0000
Subject: [PATCH] update gazelle max numa nodes 8
---
src/common/gazelle_opt.h | 2 +-
src/common/gazelle_reg_msg.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
index 98f1afd..d6b1c44 100644
--- a/src/common/gazelle_opt.h
+++ b/src/common/gazelle_opt.h
@@ -110,6 +110,6 @@
#define SLEEP_US_BEFORE_LINK_UP 10000
#define CPUS_MAX_NUM 640
-#define GAZELLE_MAX_NUMA_NODES 4
+#define GAZELLE_MAX_NUMA_NODES 8
#endif /* _GAZELLE_OPT_H_ */
diff --git a/src/common/gazelle_reg_msg.h b/src/common/gazelle_reg_msg.h
index 2ba47cc..ecd1e35 100644
--- a/src/common/gazelle_reg_msg.h
+++ b/src/common/gazelle_reg_msg.h
@@ -33,7 +33,7 @@
#define OPT_VDEV "--vdev"
#define VDEV_ARG_IFACE "iface"
-#define GAZELLE_MAX_NUMA_NODES 4
+#define GAZELLE_MAX_NUMA_NODES 8
#define SOCKET_MEM_STRLEN (GAZELLE_MAX_NUMA_NODES * 10)
/* types for msg from lstack to ltran */
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.2
Release: 83
Release: 84
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -333,6 +333,11 @@ Patch9313: 0313-DUMP-fix-abnomal-printing-in-the-dump-process.patch
Patch9314: 0314-fix-the-memory-leak-when-using-strdup.patch
Patch9315: 0315-Stack-unset-stack_stop-while-stacks-exit-by-rpc-mess.patch
Patch9316: 0316-SIGNAL-block-SIGSEGV-during-exit-process.patch
Patch9317: 0317-add-xdp-tx-checksum-tso-offload.patch
Patch9318: 0318-RTC-mode-fix-gazellectl-can-t-print-connenct-info.patch
Patch9319: 0319-Connect-fix-benchmark_dws-connect-failed.patch
Patch9320: 0320-Protocal-fixing-deathlock-between-protocol-threads-a.patch
Patch9321: 0321-update-gazelle-max-numa-nodes-8.patch
%description
%{name} is a high performance user-mode stack.
@ -374,6 +379,13 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Tue Mar 04 2025 yinbin6 <yinbin8@huawei.com> - 1.0.2-84
- update gazelle max numa nodes 8
- Protocal: fixing deathlock between protocol threads and app thread
- Connect: fix benchmark_dws connect failed
- RTC-mode: fix gazellectl can't print connenct info
- add xdp tx checksum/tso offload
* Fri Jan 17 2025 yinbin6 <yinbin8@huawei.com> - 1.0.2-83
- SIGNAL: block SIGSEGV during exit process
- Stack: unset stack_stop, while stacks exit by rpc message.