From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E27F941EA5 for ; Wed, 15 Mar 2023 23:47:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9F04410DD; Wed, 15 Mar 2023 23:47:36 +0100 (CET) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id 30D4640141 for ; Wed, 15 Mar 2023 23:47:35 +0100 (CET) Received: by mail-wm1-f52.google.com with SMTP id j19-20020a05600c191300b003eb3e1eb0caso2002590wmq.1 for ; Wed, 15 Mar 2023 15:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678920455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UBZmLeY58o03kSRyTn5iGFKS26mPxbHvlWPpRF6KGZ0=; b=aS9Mg71BXhCX0V2nJPDL32Md/3WLRhf5llVldlG/kTHaY87h5/OWIVVaogMws3q+6H hC4uCH1sJ/QmLgql2kN1GKe+Vkgi7gLmxZOsOhAyBQ6RptA2EKDr3S/2Myy8Y+Nm/Q4S soWmuYv6uR1srbuZas8IaiYCEw7f+fRUnS8ZV73oENDkJ1cd/vddq7/C3Q964IxGI0s8 V0XEw4vmgeZZVtZgom4zIg/pI4bx8kdbFP2SQAkp6qTHuTM1F9T/IZZZQyo3TlfMFxoY 7T96P90PsuVzHFt+oV41OvG7QLO/6nkZHNCyEJEFBs+gyegIXUw2q8OdFnZOci/NcY2K 8qYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678920455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UBZmLeY58o03kSRyTn5iGFKS26mPxbHvlWPpRF6KGZ0=; b=YKKyy0Y/zFXlnXGwmliHTkTlEInL9w/dXCgijzjsaz31z7i/gy7dIFvVaTLdPfebj0 gA8DdnXW1JKTgoaNH6/QkTHW5pL+b2LNbUTS563zTHnlyXLeQFMpe09igfcidq2un2uN 3L4M2PgOuaICAkp517ZDBXDzQrsk4vSnkorpHZYkzVDabowcKhbU8WsoHsBa4m4rBQcO mVRNy7hUlrvJ9l+ZUOYBJO98R71HNKFBY/BPxNPeZEMNjHQMHHDrAIHXPqqmu0AhkW3x klKExW8MkY3IE4DH+ycEGwnmjSSsdWas9KbWTr0iYPviKbRyw/8RFOAKPCPdGh5d45zz mDpQ== X-Gm-Message-State: AO0yUKWCGXcp/QUlEfdcyUw3X/r7NmI/HX/I0Kzx15itEu1Gmkk0+/BD L14OVq8fj77W+czoI1kqpVE= X-Google-Smtp-Source: AK7set/fB1DoxDXFkYKDtdGbof0fSy17Db6CzoqwgJ0yBD4QkNYzt0rulmju6tNvo3VcWu+swJb6aQ== X-Received: by 2002:a05:600c:3590:b0:3eb:37ce:4c3e with SMTP id p16-20020a05600c359000b003eb37ce4c3emr19342653wmq.16.1678920454885; Wed, 15 Mar 2023 15:47:34 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id hn37-20020a05600ca3a500b003ed2002fa6dsm3092680wmb.17.2023.03.15.15.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 15:47:34 -0700 (PDT) From: luca.boccassi@gmail.com To: Yangchao Zhou Cc: Ferruh Yigit , dpdk stable Subject: patch 'kni: fix possible starvation when mbufs are exhausted' has been queued to stable release 20.11.8 Date: Wed, 15 Mar 2023 22:46:12 +0000 Message-Id: <20230315224631.1025649-21-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315224631.1025649-1-luca.boccassi@gmail.com> References: <20230223093715.3926893-71-luca.boccassi@gmail.com> <20230315224631.1025649-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/17/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/5f3b9397db0710432b49e2c9cd709a84ac2e7265 Thanks. Luca Boccassi --- >From 5f3b9397db0710432b49e2c9cd709a84ac2e7265 Mon Sep 17 00:00:00 2001 From: Yangchao Zhou Date: Fri, 30 Dec 2022 12:23:38 +0800 Subject: [PATCH] kni: fix possible starvation when mbufs are exhausted [ upstream commit 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a ] In some scenarios, mbufs returned by rte_kni_rx_burst are not freed immediately. So kni_allocate_mbufs may be failed, but we don't know. Even worse, when alloc_q is completely exhausted, kni_net_tx in rte_kni.ko will drop all tx packets. kni_allocate_mbufs is never called again, even if the mbufs are eventually freed. In this patch, we try to allocate mbufs for alloc_q when it is empty. According to historical experience, the performance bottleneck of KNI is offen the usleep_range of kni thread in rte_kni.ko. The check of kni_fifo_count is trivial and the cost should be acceptable. Fixes: 3e12a98fe397 ("kni: optimize Rx burst") Signed-off-by: Yangchao Zhou Acked-by: Ferruh Yigit --- lib/librte_kni/rte_kni.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 17e4487306..f86a11d829 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -635,8 +635,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) { unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); - /* If buffers removed, allocate mbufs and then put them into alloc_q */ - if (ret) + /* If buffers removed or alloc_q is empty, allocate mbufs and then put them into alloc_q */ + if (ret || (kni_fifo_count(kni->alloc_q) == 0)) kni_allocate_mbufs(kni); return ret; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-03-15 22:44:50.839061593 +0000 +++ 0021-kni-fix-possible-starvation-when-mbufs-are-exhausted.patch 2023-03-15 22:44:49.579850177 +0000 @@ -1 +1 @@ -From 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a Mon Sep 17 00:00:00 2001 +From 5f3b9397db0710432b49e2c9cd709a84ac2e7265 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 676ed80ad98fcff39943d09b8fe21e2e01ae3d4a ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ - lib/kni/rte_kni.c | 4 ++-- + lib/librte_kni/rte_kni.c | 4 ++-- @@ -28,5 +29,5 @@ -diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c -index 8ab6c47153..bfa6a001ff 100644 ---- a/lib/kni/rte_kni.c -+++ b/lib/kni/rte_kni.c -@@ -634,8 +634,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num) +diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c +index 17e4487306..f86a11d829 100644 +--- a/lib/librte_kni/rte_kni.c ++++ b/lib/librte_kni/rte_kni.c +@@ -635,8 +635,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num)