66 lines
2.3 KiB
Diff
66 lines
2.3 KiB
Diff
From 7b7dd1bdda75f8877e57f3b29432e3e1686bf9b5 Mon Sep 17 00:00:00 2001
|
|
From: jiangheng <jiangheng12@huawei.com>
|
|
Date: Mon, 7 Mar 2022 23:35:07 +0800
|
|
Subject: [PATCH 06/34] reduce replenish send_idle_ring rpc call
|
|
|
|
---
|
|
src/lstack/core/lstack_lwip.c | 4 ++--
|
|
src/lstack/core/lstack_thread_rpc.c | 2 ++
|
|
src/lstack/include/lstack_protocol_stack.h | 1 +
|
|
3 files changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index 0a71aae..a9ef824 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -240,7 +240,7 @@ void stack_replenish_send_idlembuf(struct protocol_stack *stack)
|
|
ssize_t write_lwip_data(struct lwip_sock *sock, int32_t fd, int32_t flags)
|
|
{
|
|
struct pbuf *pbuf = NULL;
|
|
- ssize_t send_ret;
|
|
+ ssize_t send_ret = 0;
|
|
ssize_t send_len = 0;
|
|
|
|
do {
|
|
@@ -327,7 +327,7 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
|
|
sock->have_event = false;
|
|
}
|
|
|
|
- if (rte_ring_free_count(sock->stack->send_idle_ring) > USED_IDLE_WATERMARK) {
|
|
+ if (rte_ring_free_count(sock->stack->send_idle_ring) > USED_IDLE_WATERMARK && !sock->stack->in_replenish) {
|
|
rpc_call_replenish_idlembuf(sock->stack);
|
|
}
|
|
|
|
diff --git a/src/lstack/core/lstack_thread_rpc.c b/src/lstack/core/lstack_thread_rpc.c
|
|
index 1ed20dd..8b3d36c 100644
|
|
--- a/src/lstack/core/lstack_thread_rpc.c
|
|
+++ b/src/lstack/core/lstack_thread_rpc.c
|
|
@@ -194,10 +194,12 @@ static void rpc_replenish_idlembuf(struct rpc_msg *msg)
|
|
{
|
|
struct protocol_stack *stack = get_protocol_stack();
|
|
stack_replenish_send_idlembuf(stack);
|
|
+ stack->in_replenish = 0;
|
|
}
|
|
|
|
void rpc_call_replenish_idlembuf(struct protocol_stack *stack)
|
|
{
|
|
+ stack->in_replenish = 1;
|
|
struct rpc_msg *msg = rpc_msg_alloc(stack->rpc_pool, rpc_replenish_idlembuf);
|
|
if (msg == NULL) {
|
|
return;
|
|
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
|
|
index 3c49bd5..1020e83 100644
|
|
--- a/src/lstack/include/lstack_protocol_stack.h
|
|
+++ b/src/lstack/include/lstack_protocol_stack.h
|
|
@@ -28,6 +28,7 @@ struct protocol_stack {
|
|
uint16_t socket_id;
|
|
uint16_t cpu_id;
|
|
volatile uint16_t conn_num;
|
|
+ volatile bool in_replenish;
|
|
|
|
// for dispatcher thread
|
|
cpu_set_t idle_cpuset;
|
|
--
|
|
1.8.3.1
|
|
|