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 6D99BA034E for ; Mon, 21 Feb 2022 16:39:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6865F410F6; Mon, 21 Feb 2022 16:39:02 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id DFD8C410E0 for ; Mon, 21 Feb 2022 16:39:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645457940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=syqRk/1xdppyBqbjQ3odbqyus8fwGVl19JrKj8X1ZgQ=; b=T+5hp205PIXUEAnNzO7Z0eCS6GCLkHTFJB8ST+GI6Rh6FAQxZw1iH79G2jIS75zyE+n5Yn gfIKWDwC3+90qu8mVsAObmvFtTLaaxZQqIJMDWxj8VhntSQMCEaJs73Ji4lpRfytk/iH31 O+e49f/P69j5B8u2tlygT/rk7UCo5bc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-388-bcQWzTV7PTeys3v3Vh48_Q-1; Mon, 21 Feb 2022 10:38:57 -0500 X-MC-Unique: bcQWzTV7PTeys3v3Vh48_Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ED961846088; Mon, 21 Feb 2022 15:38:56 +0000 (UTC) Received: from rh.Home (unknown [10.39.195.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 243E578DDE; Mon, 21 Feb 2022 15:38:54 +0000 (UTC) From: Kevin Traynor To: Dmitry Kozlyuk Cc: Viacheslav Ovsiienko , dpdk stable Subject: patch 'app/testpmd: fix external buffer allocation' has been queued to stable release 21.11.1 Date: Mon, 21 Feb 2022 15:34:22 +0000 Message-Id: <20220221153625.152324-73-ktraynor@redhat.com> In-Reply-To: <20220221153625.152324-1-ktraynor@redhat.com> References: <20220221153625.152324-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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 21.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/26/22. 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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/ef94549efe574bddcc8d65a9ac66b4b4734d7ffe Thanks. Kevin --- >From ef94549efe574bddcc8d65a9ac66b4b4734d7ffe Mon Sep 17 00:00:00 2001 From: Dmitry Kozlyuk Date: Fri, 17 Dec 2021 11:58:16 +0200 Subject: [PATCH] app/testpmd: fix external buffer allocation [ upstream commit 13b196425ce371a82fa8008fa46ce66861d4202b ] External pinned buffer memory (--mp-alloc=xbuf) was allocated as multiple IOVA-contiguous memzones of 2M size and 2M alignment. Due to the malloc overhead and the alignment requirement, each 2M memzone consumed 4M of hugepage memory: 2M of usable memory + X of malloc overhead + (2M-X) padding. The allocation often failed with 2M hugepages and IOVA-as-PA if a PA-contiguous span of 2 hugepages could not be found. Also, with any hugepage size and IOVA mode memory consumption was almost 2x of the usable amount. Alignment requirement of 2M for external buffers is redundant. It was an attempt to ensure IOVA-contiguity by forcing memzones to start at hugepage boundaries, while 2M size intended to leave no unused space on the page. As shown above, this in fact caused excessive memory consumption and decreased the chance of a successful allocation. RTE_MEMZONE_F_IOVA_CONTIG already ensures IOVA-contiguity. Remove the alignment requirement. Reduce the memzone size by the malloc overhead size (4 cache lines), so that memory consumption for each memzone is (2M-X) of usable memory + X of malloc overhead = 2M. This also means that whenever there are free 2M hugepages, an IOVA-contiguous memzone can always be allocated. Fixes: 72512e1897b2 ("app/testpmd: add mempool with external data buffers") Signed-off-by: Dmitry Kozlyuk Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/testpmd.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6c387bde84..e1da961311 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -85,5 +85,11 @@ #define EXTMEM_HEAP_NAME "extmem" -#define EXTBUF_ZONE_SIZE RTE_PGSIZE_2M +/* + * Zone size with the malloc overhead (max of debug and release variants) + * must fit into the smallest supported hugepage size (2M), + * so that an IOVA-contiguous zone of this size can always be allocated + * if there are free 2M hugepages. + */ +#define EXTBUF_ZONE_SIZE (RTE_PGSIZE_2M - 4 * RTE_CACHE_LINE_SIZE) uint16_t verbose_level = 0; /**< Silent by default. */ @@ -1062,10 +1068,9 @@ setup_extbuf(uint32_t nb_mbufs, uint16_t mbuf_sz, unsigned int socket_id, break; } - mz = rte_memzone_reserve_aligned(mz_name, EXTBUF_ZONE_SIZE, - socket_id, - RTE_MEMZONE_IOVA_CONTIG | - RTE_MEMZONE_1GB | - RTE_MEMZONE_SIZE_HINT_ONLY, - EXTBUF_ZONE_SIZE); + mz = rte_memzone_reserve(mz_name, EXTBUF_ZONE_SIZE, + socket_id, + RTE_MEMZONE_IOVA_CONTIG | + RTE_MEMZONE_1GB | + RTE_MEMZONE_SIZE_HINT_ONLY); if (mz == NULL) { /* -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-02-21 15:22:46.232098310 +0000 +++ 0073-app-testpmd-fix-external-buffer-allocation.patch 2022-02-21 15:22:44.159704279 +0000 @@ -1 +1 @@ -From 13b196425ce371a82fa8008fa46ce66861d4202b Mon Sep 17 00:00:00 2001 +From ef94549efe574bddcc8d65a9ac66b4b4734d7ffe Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 13b196425ce371a82fa8008fa46ce66861d4202b ] + @@ -33 +34,0 @@ -Cc: stable@dpdk.org