From 3b8c4f1cf6d5aabfe818db584c701e7bea4456d0 Mon Sep 17 00:00:00 2001 From: "hanyu.zly" Date: Mon, 25 Dec 2023 17:33:51 +0800 Subject: [PATCH] zebra: Temporarily block the execution of the rib_process function while the thread t_dplane is waiting to be scheduled. This allows t_dplane to prioritize freeing up the cache structures of zebra_dplane_ctx. This addresses the issue where a large number of zebra_dplane_ctx nodes are cached on the rib_dplane_q when a surge of routes is inserted in a short period of time, leading to the consumption of a significant amount of temporary memory and potentially causing system memory overload and kernel OOM (Out of Memory) problems. Signed-off-by: hanyu.zly --- zebra/zebra_rib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index c03d7e51f87a..7dc702f5ada5 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -3228,7 +3228,7 @@ static wq_item_status meta_queue_process(struct work_queue *dummy, void *data) /* Ensure there's room for more dataplane updates */ queue_limit = dplane_get_in_queue_limit(); queue_len = dplane_get_in_queue_len(); - if (queue_len > queue_limit) { + if (queue_len > queue_limit || t_dplane) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug( "rib queue: dplane queue len %u, limit %u, retrying", @@ -4974,6 +4974,7 @@ static void rib_process_dplane_results(struct event *thread) } } while (1); + t_dplane = NULL; #ifdef HAVE_SCRIPTING if (fs)