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 BD46BA0C47 for ; Tue, 10 Aug 2021 17:41:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C26A411CC; Tue, 10 Aug 2021 17:41:10 +0200 (CEST) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by mails.dpdk.org (Postfix) with ESMTP id 028CC4114F for ; Tue, 10 Aug 2021 17:41:10 +0200 (CEST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id DBA393F0A4 for ; Tue, 10 Aug 2021 15:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628610069; bh=upfiBpwV5ickUqKipZwPmE/TgFatLpCScfJSEZlO44M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B9UczgBtpiVyMxoGIuawzoWVHKT5A9sEhPWnoj3OAAONav9Sm7yMfSjtfnoyyLWVy 5VCHV5KfzovkDRc+vdUY57ttAbiECzEOG0FjtidrsbMRNiaD7cVT9JiAswe8WSIKKw yvVQgVWn1b3iiCfEUwYo0CyOstHL8G8sDXKTid35VrNsRsQO4nePwHl9eeswY7/jRL hwa7N837AVLlKA1lQ8sgE7nJYqWz2gujRbfWwl7tOAv1p6HAEXYmkcPb6/GFoL6BjP lk89cwKlm/sPqD3+Cc5spWjW56Rn4LrZldFWEVqO7YGLGcTqRKUgVAY7y160ioiqjf Ju7eKAoQZst+Q== Received: by mail-ed1-f69.google.com with SMTP id p2-20020a50c9420000b02903a12bbba1ebso10897175edh.6 for ; Tue, 10 Aug 2021 08:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=upfiBpwV5ickUqKipZwPmE/TgFatLpCScfJSEZlO44M=; b=s1nLZo5crM588/OADgfpR8CvuBWgqCSkdoqmKs5UTcCWH5pfNW/2gw1pWwCrG2GxRq aiX5asTh8G9pNdTLoQjV3Iwjmc0YiLje3tws/a3Fez4EKPnWrTarkjeeAxVQxcrS8v/D Z/MmPvGaKreFgsSFC7s5haty8F8xr1XXtGbaY8Tg2LuUCITJfi+cfKtNQ29iuOC4uWo6 blYRChFuH7IvTQf/Fnevv2T8kR49vFGzu9DhkR1tyJEvyZ1o5q/2X3cFti9hMJTfzfRf F6S9Pi9Oj5GnQQwP1cbIcy6aR5DHLy0pYcsv0m99u0aiuRO2R7uUbMRK2f3MU3UhqGLI Dkag== X-Gm-Message-State: AOAM5333IAMSxN2NTGtOxnamAt+HOGwDAlq8sDKR/nXKKyf/p4qu5fI5 0mwbk69C7lUAjja8PizDkFF7fm7dhp/qsjonaIhaiNNVVKpBN5onvwNM7RhFBR7yfT33bUmrHDI 6h2skt5h2Sox/uKI3jBNDBU/2 X-Received: by 2002:a05:6402:3481:: with SMTP id v1mr5539676edc.60.1628610069621; Tue, 10 Aug 2021 08:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzomf9RHeUCzfK+K8uOt29pumU/FSjzmBDyBvklQLLR1Wgd29UnQ5+/it3hfrpyPgfJoNAJYg== X-Received: by 2002:a05:6402:3481:: with SMTP id v1mr5539658edc.60.1628610069453; Tue, 10 Aug 2021 08:41:09 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2001:67c:1560:8007::aac:c4ad]) by smtp.gmail.com with ESMTPSA id r19sm2113142edd.49.2021.08.10.08.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 08:41:08 -0700 (PDT) From: christian.ehrhardt@canonical.com To: Yunjian Wang Cc: Cheng Liu , Ferruh Yigit , Ajit Khaparde , dpdk stable Date: Tue, 10 Aug 2021 17:38:55 +0200 Message-Id: <20210810154022.749358-15-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810154022.749358-1-christian.ehrhardt@canonical.com> References: <20210810154022.749358-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'kni: fix mbuf allocation for kernel side use' has been queued to stable release 19.11.10 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/12/21. 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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/4b9355f4d0fa3a07fc2f601fc826facec95a004f Thanks. Christian Ehrhardt --- >From 4b9355f4d0fa3a07fc2f601fc826facec95a004f Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Tue, 22 Jun 2021 20:44:29 +0800 Subject: [PATCH] kni: fix mbuf allocation for kernel side use [ upstream commit 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 ] In kni_allocate_mbufs(), we alloc mbuf for alloc_q as this code. allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \ & (MAX_MBUF_BURST_NUM - 1); The value of allocq_free maybe zero, for example : The ring size is 1024. After init, write = read = 0. Then we fill kni->alloc_q to full. At this time, write = 1023, read = 0. Then the kernel send 32 packets to userspace. At this time, write = 1023, read = 32. And then the userspace receive this 32 packets. Then fill the kni->alloc_q, (32 - 1023 - 1) & 31 = 0, fill nothing. ... Then the kernel send 32 packets to userspace. At this time, write = 1023, read = 992. And then the userspace receive this 32 packets. Then fill the kni->alloc_q, (992 - 1023 - 1) & 31 = 0, fill nothing. Then the kernel send 32 packets to userspace. The kni->alloc_q only has 31 mbufs and will drop one packet. Absolutely, this is a special scene. Normally, it will fill some mbufs everytime, but may not enough for the kernel to use. In this patch, we always keep the kni->alloc_q to full for the kernel to use. Fixes: 49da4e82cf94 ("kni: allocate no more mbuf than empty slots in queue") Signed-off-by: Cheng Liu Signed-off-by: Yunjian Wang Acked-by: Ferruh Yigit Acked-by: Ajit Khaparde --- lib/librte_kni/rte_kni.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index bcf82cc2d5..e96adc14b5 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -674,8 +674,9 @@ kni_allocate_mbufs(struct rte_kni *kni) return; } - allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) - & (MAX_MBUF_BURST_NUM - 1); + allocq_free = kni_fifo_free_count(kni->alloc_q); + allocq_free = (allocq_free > MAX_MBUF_BURST_NUM) ? + MAX_MBUF_BURST_NUM : allocq_free; for (i = 0; i < allocq_free; i++) { pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); if (unlikely(pkts[i] == NULL)) { -- 2.32.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-08-10 15:11:13.672319693 +0200 +++ 0015-kni-fix-mbuf-allocation-for-kernel-side-use.patch 2021-08-10 15:11:12.914637350 +0200 @@ -1 +1 @@ -From 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 Mon Sep 17 00:00:00 2001 +From 4b9355f4d0fa3a07fc2f601fc826facec95a004f Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 0db3d5551abe94bb8a7030c1b90496b290ddb7f4 ] + @@ -31 +32,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ - lib/kni/rte_kni.c | 5 +++-- + lib/librte_kni/rte_kni.c | 5 +++-- @@ -41,5 +42,5 @@ -diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c -index 9dae6a8d7c..eb24b0d0ae 100644 ---- a/lib/kni/rte_kni.c -+++ b/lib/kni/rte_kni.c -@@ -677,8 +677,9 @@ kni_allocate_mbufs(struct rte_kni *kni) +diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c +index bcf82cc2d5..e96adc14b5 100644 +--- a/lib/librte_kni/rte_kni.c ++++ b/lib/librte_kni/rte_kni.c +@@ -674,8 +674,9 @@ kni_allocate_mbufs(struct rte_kni *kni)