From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E3BCA04F5 for ; Wed, 11 Dec 2019 22:28:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D5DC71BECF; Wed, 11 Dec 2019 22:28:32 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 3B0311BE9E for ; Wed, 11 Dec 2019 22:28:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576099711; 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=OTAz8orZ8s018YrFKKnNsx+tiAvU9X4wIHilQJ48rFE=; b=B/QDpKXF+v96JaWEqTU6ndCvSC7rZDXp+srCL8INg1CTmeM3Q8F3SKpH9mugmP+VeZxQGZ BYYNvvWV0PnOGFfxiNXHl/T0tr1irSA6oBUwECNmeOzuktSkY2j4suFvUHp2zWLVShSidI A6Bu1pZICH1HmJxYjrmiRgfoiH4QQrY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-tYrr0KDuMjCFT-wlutO7Aw-1; Wed, 11 Dec 2019 16:28:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72E1518543A0; Wed, 11 Dec 2019 21:28:26 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E3DF10013A1; Wed, 11 Dec 2019 21:28:24 +0000 (UTC) From: Kevin Traynor To: Anatoly Burakov Cc: Olivier Matz , Bo Chen , dpdk stable Date: Wed, 11 Dec 2019 21:26:21 +0000 Message-Id: <20191211212702.27851-29-ktraynor@redhat.com> In-Reply-To: <20191211212702.27851-1-ktraynor@redhat.com> References: <20191211212702.27851-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: tYrr0KDuMjCFT-wlutO7Aw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'mempool: use actual IOVA addresses when populating' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/17/19. 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 rebasi= ng (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-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/9bf2561cb325022e05= 91a1fbebcc59867025d596 Thanks. Kevin. --- >From 9bf2561cb325022e0591a1fbebcc59867025d596 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Thu, 14 Nov 2019 13:58:20 +0000 Subject: [PATCH] mempool: use actual IOVA addresses when populating [ upstream commit 2a7fd3ef38da19b2805fecd29c527456364ae618 ] Currently, when mempool is being populated, we get IOVA address of every segment using rte_mem_virt2iova(). This works for internal memory, but does not really work for external memory, and does not work on platforms which return RTE_BAD_IOVA as a result of this call (such as FreeBSD). Moreover, even when it works, the function in question will do unnecessary pagewalks in IOVA as PA mode, as it falls back to rte_mem_virt2phy() instead of just doing a lookup in internal memseg table. To fix it, replace the call to first attempt to look through the internal memseg table (this takes care of internal and external memory), and fall back to rte_mem_virt2iova() when unable to perform VA->IOVA translation via memseg table. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Signed-off-by: Anatoly Burakov Acked-by: Olivier Matz Tested-by: Bo Chen --- lib/librte_mempool/rte_mempool.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_memp= ool.c index 683b216f9..99530a595 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -356,4 +356,17 @@ fail: } =20 +static rte_iova_t +get_iova(void *addr) +{ +=09struct rte_memseg *ms; + +=09/* try registered memory first */ +=09ms =3D rte_mem_virt2memseg(addr, NULL); +=09if (ms =3D=3D NULL || ms->iova =3D=3D RTE_BAD_IOVA) +=09=09/* fall back to actual physical address */ +=09=09return rte_mem_virt2iova(addr); +=09return ms->iova + RTE_PTR_DIFF(addr, ms->addr); +} + /* Populate the mempool with a virtual area. Return the number of * objects added, or a negative value on error. @@ -381,5 +394,5 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char = *addr, =09=09 mp->populated_size < mp->size; off +=3D phys_len) { =20 -=09=09iova =3D rte_mem_virt2iova(addr + off); +=09=09iova =3D get_iova(addr + off); =20 =09=09if (iova =3D=3D RTE_BAD_IOVA && rte_eal_has_hugepages()) { @@ -392,5 +405,5 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char = *addr, =09=09=09rte_iova_t iova_tmp; =20 -=09=09=09iova_tmp =3D rte_mem_virt2iova(addr + off + phys_len); +=09=09=09iova_tmp =3D get_iova(addr + off + phys_len); =20 =09=09=09if (iova_tmp !=3D iova + phys_len) --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-11 21:24:15.049815276 +0000 +++ 0029-mempool-use-actual-IOVA-addresses-when-populating.patch=092019-12-= 11 21:24:12.657651424 +0000 @@ -1 +1 @@ -From 2a7fd3ef38da19b2805fecd29c527456364ae618 Mon Sep 17 00:00:00 2001 +From 9bf2561cb325022e0591a1fbebcc59867025d596 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 2a7fd3ef38da19b2805fecd29c527456364ae618 ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -31 +32 @@ -index 40cae3eb6..8da2e471c 100644 +index 683b216f9..99530a595 100644 @@ -34 +35 @@ -@@ -357,4 +357,17 @@ fail: +@@ -356,4 +356,17 @@ fail: @@ -52 +53 @@ -@@ -376,5 +389,5 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char= *addr, +@@ -381,5 +394,5 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char= *addr, @@ -65 +66 @@ - =09=09=09if (iova_tmp =3D=3D RTE_BAD_IOVA || + =09=09=09if (iova_tmp !=3D iova + phys_len)