1 Star 0 Fork 96

sky/gazelle_kylin_src

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0213-discard-wakeup_num-parameter.patch 10.84 KB
一键复制 编辑 原始数据 按行查看 历史
compile_success 提交于 2023-12-04 02:54 . add select and timeout for kylin
From 7692ad1681386e5ab27006ddbdcb530dfa887121 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 20 Mar 2023 16:14:45 +0800
Subject: [PATCH] discard wakeup_num parameter
---
src/lstack/api/lstack_epoll.c | 15 +++----
src/lstack/core/lstack_cfg.c | 39 -----------------
src/lstack/core/lstack_dpdk.c | 8 ----
src/lstack/core/lstack_protocol_stack.c | 51 ++--------------------
src/lstack/include/lstack_cfg.h | 2 -
src/lstack/include/lstack_protocol_stack.h | 1 -
src/lstack/include/posix/lstack_epoll.h | 2 +-
src/lstack/lstack.conf | 3 --
8 files changed, 9 insertions(+), 112 deletions(-)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index 4a10b09..d4b4be7 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -79,7 +79,7 @@ void add_sock_event(struct lwip_sock *sock, uint32_t event)
}
}
-void wakeup_stack_epoll(struct protocol_stack *stack, bool wakeup_thread_enable)
+void wakeup_stack_epoll(struct protocol_stack *stack)
{
struct list_node *node, *temp;
@@ -97,15 +97,10 @@ void wakeup_stack_epoll(struct protocol_stack *stack, bool wakeup_thread_enable)
struct wakeup_poll *wakeup = container_of((node - stack->stack_idx), struct wakeup_poll, wakeup_list);
- if (!wakeup_thread_enable) {
- if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
- __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
- rte_mb();
- pthread_mutex_unlock(&wakeup->wait);
- stack->stats.wakeup_events++;
- }
- } else {
- gazelle_light_ring_enqueue_busrt(stack->wakeup_ring, (void **)&wakeup, 1);
+ if (__atomic_load_n(&wakeup->in_wait, __ATOMIC_ACQUIRE)) {
+ __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE);
+ rte_mb();
+ pthread_mutex_unlock(&wakeup->wait);
stack->stats.wakeup_events++;
}
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index 88f69e1..4164b0e 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -48,7 +48,6 @@ static int32_t parse_host_addr(void);
static int32_t parse_low_power_mode(void);
static int32_t parse_stack_cpu_number(void);
static int32_t parse_use_ltran(void);
-static int32_t parse_wakeup_cpu_number(void);
static int32_t parse_mask_addr(void);
static int32_t parse_devices(void);
static int32_t parse_dpdk_args(void);
@@ -104,7 +103,6 @@ static struct config_vector_t g_config_tbl[] = {
{ "dpdk_args", parse_dpdk_args },
{ "seperate_send_recv", parse_seperate_sendrecv_args },
{ "num_cpus", parse_stack_cpu_number },
- { "num_wakeup", parse_wakeup_cpu_number },
{ "low_power_mode", parse_low_power_mode },
{ "kni_switch", parse_kni_switch },
{ "listen_shadow", parse_listen_shadow },
@@ -450,9 +448,6 @@ int32_t init_stack_numa_cpuset(struct protocol_stack *stack)
CPU_SET(cfg->recv_cpus[idx], &stack_cpuset);
}
}
- for (int32_t idx = 0; idx < cfg->num_wakeup; ++idx) {
- CPU_SET(cfg->wakeup[idx], &stack_cpuset);
- }
ret = stack_idle_cpuset(stack, &stack_cpuset);
if (ret < 0) {
@@ -757,40 +752,6 @@ static int32_t parse_low_power_mode(void)
return parse_int(&g_config_params.low_power_mod, "low_power_mode", 0, 0, 1);
}
-static int32_t parse_wakeup_cpu_number(void)
-{
- const config_setting_t *cfg_args = NULL;
- const char *args = NULL;
-
- g_config_params.num_wakeup = 0;
-
- cfg_args = config_lookup(&g_config, "num_wakeup");
- if (cfg_args == NULL) {
- return 0;
- }
-
- args = config_setting_get_string(cfg_args);
- if (cfg_args == NULL) {
- return 0;
- }
-
- char *tmp_arg = strdup(args);
- int32_t cnt = separate_str_to_array(tmp_arg, g_config_params.wakeup, CFG_MAX_CPUS);
- free(tmp_arg);
- if (cnt <= 0 || cnt > CFG_MAX_CPUS) {
- return -EINVAL;
- }
- g_config_params.num_wakeup = cnt;
-
- if (g_config_params.num_wakeup < g_config_params.num_cpu) {
- LSTACK_PRE_LOG(LSTACK_ERR, "num_wakeup=%hu less than num_stack_cpu=%hu.\n", g_config_params.num_wakeup,
- g_config_params.num_cpu);
- return -EINVAL;
- }
-
- return 0;
-}
-
static int32_t parse_use_ltran(void)
{
return parse_int(&g_config_params.use_ltran, "use_ltran", 1, 0, 1);
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 7ded9e9..ebfebaa 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -237,14 +237,6 @@ int32_t create_shared_ring(struct protocol_stack *stack)
{
lockless_queue_init(&stack->rpc_queue);
- if (get_protocol_stack_group()->wakeup_enable) {
- stack->wakeup_ring = create_ring("WAKEUP_RING", VDEV_WAKEUP_QUEUE_SZ, RING_F_SP_ENQ | RING_F_SC_DEQ,
- stack->queue_id);
- if (stack->wakeup_ring == NULL) {
- return -1;
- }
- }
-
if (use_ltran()) {
stack->rx_ring = create_ring("RING_RX", VDEV_RX_QUEUE_SZ, RING_F_SP_ENQ | RING_F_SC_DEQ, stack->queue_id);
if (stack->rx_ring == NULL) {
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 5e510bd..92300ef 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -256,41 +256,6 @@ static int32_t create_thread(void *arg, char *thread_name, stack_thread_func fun
return 0;
}
-static void* gazelle_wakeup_thread(void *arg)
-{
- uint16_t queue_id = *(uint16_t *)arg;
- struct protocol_stack *stack = get_protocol_stack_group()->stacks[queue_id];
-
- struct cfg_params *cfg = get_global_cfg_params();
- int32_t lcore_id = cfg->wakeup[stack->stack_idx];
- thread_affinity_init(lcore_id);
-
- struct timespec st = {
- .tv_sec = 0,
- .tv_nsec = 1
- };
-
- LSTACK_LOG(INFO, LSTACK, "weakup_%02hu start\n", stack->queue_id);
-
- for (;;) {
- if (cfg->low_power_mod != 0 && stack->low_power) {
- nanosleep(&st, NULL);
- }
-
- struct wakeup_poll *wakeup[WAKEUP_MAX_NUM];
- uint32_t num = gazelle_light_ring_dequeue_burst(stack->wakeup_ring, (void **)wakeup, WAKEUP_MAX_NUM);
- for (uint32_t i = 0; i < num; i++) {
- if (__atomic_load_n(&wakeup[i]->in_wait, __ATOMIC_ACQUIRE)) {
- __atomic_store_n(&wakeup[i]->in_wait, false, __ATOMIC_RELEASE);
- rte_mb();
- pthread_mutex_unlock(&wakeup[i]->wait);
- }
- }
- }
-
- return NULL;
-}
-
static void* gazelle_kernelevent_thread(void *arg)
{
struct thread_params *t_params = (struct thread_params*) arg;
@@ -374,16 +339,8 @@ void wait_sem_value(sem_t *sem, int32_t wait_value)
} while (sem_val < wait_value);
}
-static int32_t create_affiliate_thread(void *arg, bool wakeup_enable)
+static int32_t create_affiliate_thread(void *arg)
{
-
- if (wakeup_enable) {
- if (create_thread(arg, "gazelleweakup", gazelle_wakeup_thread) != 0) {
- LSTACK_LOG(ERR, LSTACK, "gazelleweakup errno=%d\n", errno);
- return -1;
- }
- }
-
if (create_thread(arg, "gazellekernel", gazelle_kernelevent_thread) != 0) {
LSTACK_LOG(ERR, LSTACK, "gazellekernel errno=%d\n", errno);
return -1;
@@ -409,7 +366,7 @@ static struct protocol_stack *stack_thread_init(void *arg)
if (init_stack_numa_cpuset(stack) < 0) {
goto END;
}
- if (create_affiliate_thread(arg, stack_group->wakeup_enable) < 0) {
+ if (create_affiliate_thread(arg) < 0) {
goto END;
}
@@ -484,7 +441,6 @@ static void* gazelle_stack_thread(void *arg)
uint16_t low_power_mod = cfg->low_power_mod;
uint32_t wakeup_tick = 0;
struct protocol_stack_group *stack_group = get_protocol_stack_group();
- bool wakeup_thread_enable = stack_group->wakeup_enable;
struct protocol_stack *stack = stack_thread_init(arg);
@@ -516,7 +472,7 @@ static void* gazelle_stack_thread(void *arg)
if ((wakeup_tick & 0xf) == 0) {
wakeup_kernel_event(stack);
- wakeup_stack_epoll(stack, wakeup_thread_enable);
+ wakeup_stack_epoll(stack);
}
/* KNI requests are generally low-rate I/Os,
@@ -583,7 +539,6 @@ int32_t init_protocol_stack(void)
stack_group->stack_num = get_global_cfg_params()->num_cpu * 2;
}
- stack_group->wakeup_enable = (get_global_cfg_params()->num_wakeup > 0) ? true : false;
init_list_node(&stack_group->poll_list);
pthread_spin_init(&stack_group->poll_list_lock, PTHREAD_PROCESS_PRIVATE);
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index 5f8e6b3..16f37b4 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -67,8 +67,6 @@ struct cfg_params {
uint32_t cpus[CFG_MAX_CPUS];
uint32_t send_cpus[CFG_MAX_CPUS];
uint32_t recv_cpus[CFG_MAX_CPUS];
- uint16_t num_wakeup;
- uint32_t wakeup[CFG_MAX_CPUS];
uint8_t num_ports;
uint16_t ports[CFG_MAX_PORTS];
char log_file[PATH_MAX];
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
index 3691250..001ab47 100644
--- a/src/lstack/include/lstack_protocol_stack.h
+++ b/src/lstack/include/lstack_protocol_stack.h
@@ -95,7 +95,6 @@ struct protocol_stack_group {
struct rte_mempool *kni_pktmbuf_pool;
struct eth_params *eth_params;
struct protocol_stack *stacks[PROTOCOL_STACK_MAX];
- bool wakeup_enable;
struct list_node poll_list;
pthread_spinlock_t poll_list_lock;
sem_t sem_listen_thread;
diff --git a/src/lstack/include/posix/lstack_epoll.h b/src/lstack/include/posix/lstack_epoll.h
index 6aa9d30..d6c81a7 100644
--- a/src/lstack/include/posix/lstack_epoll.h
+++ b/src/lstack/include/posix/lstack_epoll.h
@@ -64,7 +64,7 @@ struct wakeup_poll {
struct netconn;
struct lwip_sock;
void add_sock_event(struct lwip_sock *sock, uint32_t event);
-void wakeup_stack_epoll(struct protocol_stack *stack, bool wakeup_thread_enable);
+void wakeup_stack_epoll(struct protocol_stack *stack);
int32_t lstack_epoll_create(int32_t size);
int32_t lstack_epoll_create1(int32_t flags);
int32_t lstack_epoll_ctl(int32_t epfd, int32_t op, int32_t fd, struct epoll_event *event);
diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf
index 64a2f42..81da10a 100644
--- a/src/lstack/lstack.conf
+++ b/src/lstack/lstack.conf
@@ -14,7 +14,6 @@ use_ltran=1
kni_switch=0
low_power_mode=0
-listen_shadow=0
#needed mbuf count = tcp_conn_count * mbuf_count_per_conn
tcp_conn_count = 1500
@@ -37,8 +36,6 @@ nic_read_number = 128
#each cpu core start a protocol stack thread.
num_cpus="2"
-#each cpu core start a wakeup thread.
-#num_wakeup="3"
#app worker thread bind to numa in epoll/poll.
app_bind_numa=1
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nlgwcy/gazelle_kylin_src.git
git@gitee.com:nlgwcy/gazelle_kylin_src.git
nlgwcy
gazelle_kylin_src
gazelle_kylin_src
master

搜索帮助