get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/45135/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 45135,
    "url": "http://patches.dpdk.org/api/patches/45135/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/91e8afce7b2a31e99edc659aa37309692aec8335.1537546029.git.anatoly.burakov@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<91e8afce7b2a31e99edc659aa37309692aec8335.1537546029.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/91e8afce7b2a31e99edc659aa37309692aec8335.1537546029.git.anatoly.burakov@intel.com",
    "date": "2018-09-21T16:13:51",
    "name": "[v4,02/20] mem: allow memseg lists to be marked as external",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "41ccd2e361d28af478bf9e098a24788d5f8ec1ce",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/91e8afce7b2a31e99edc659aa37309692aec8335.1537546029.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1446,
            "url": "http://patches.dpdk.org/api/series/1446/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1446",
            "date": "2018-09-21T16:13:49",
            "name": "Support externally allocated memory in DPDK",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/1446/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45135/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/45135/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 139CC1B106;\n\tFri, 21 Sep 2018 18:14:49 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id 33F745F24\n\tfor <dev@dpdk.org>; Fri, 21 Sep 2018 18:14:24 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Sep 2018 09:14:16 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga004.jf.intel.com with ESMTP; 21 Sep 2018 09:14:10 -0700",
            "from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com\n\t[10.237.217.45])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tw8LGEAli029183; Fri, 21 Sep 2018 17:14:10 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w8LGE9uS002772;\n\tFri, 21 Sep 2018 17:14:09 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w8LGE9rd002768;\n\tFri, 21 Sep 2018 17:14:09 +0100"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,285,1534834800\"; d=\"scan'208\";a=\"234868398\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Neil Horman <nhorman@tuxdriver.com>,\n\tJohn McNamara <john.mcnamara@intel.com>,\n\tMarko Kovacevic <marko.kovacevic@intel.com>,\n\tHemant Agrawal <hemant.agrawal@nxp.com>,\n\tShreyansh Jain <shreyansh.jain@nxp.com>,\n\tMatan Azrad <matan@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>,\n\tYongseok Koh <yskoh@mellanox.com>,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>,\n\tTiwei Bie <tiwei.bie@intel.com>, Zhihong Wang <zhihong.wang@intel.com>,\n\tBruce Richardson <bruce.richardson@intel.com>,\n\tOlivier Matz <olivier.matz@6wind.com>,\n\tAndrew Rybchenko <arybchenko@solarflare.com>,\n\tlaszlo.madarassy@ericsson.com, laszlo.vadkerti@ericsson.com,\n\tandras.kovacs@ericsson.com, winnie.tian@ericsson.com,\n\tdaniel.andrasi@ericsson.com, janos.kobor@ericsson.com,\n\tgeza.koblo@ericsson.com, srinath.mannam@broadcom.com,\n\tscott.branden@broadcom.com, ajit.khaparde@broadcom.com,\n\tkeith.wiles@intel.com, thomas@monjalon.net",
        "Date": "Fri, 21 Sep 2018 17:13:51 +0100",
        "Message-Id": "<91e8afce7b2a31e99edc659aa37309692aec8335.1537546029.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1537546029.git.anatoly.burakov@intel.com>",
            "<cover.1537546029.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1537546029.git.anatoly.burakov@intel.com>",
            "<cover.1537443103.git.anatoly.burakov@intel.com>\n\t<cover.1537546029.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v4 02/20] mem: allow memseg lists to be marked as\n\texternal",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When we allocate and use DPDK memory, we need to be able to\ndifferentiate between DPDK hugepage segments and segments that\nwere made part of DPDK but are externally allocated. Add such\na property to memseg lists.\n\nThis breaks the ABI, so bump the EAL library ABI version and\ndocument the change in release notes. This also breaks a few\ninternal assumptions about memory contiguousness, so adjust\nmalloc code in a few places.\n\nAll current calls for memseg walk functions were adjusted to\nignore external segments where it made sense.\n\nMempools is a special case, because we may be asked to allocate\na mempool on a specific socket, and we need to ignore all page\nsizes on other heaps or other sockets. Previously, this\nassumption of knowing all page sizes was not a problem, but it\nwill be now, so we have to match socket ID with page size when\ncalculating minimum page size for a mempool.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\nAcked-by: Andrew Rybchenko <arybchenko@solarflare.com>\n---\n\nNotes:\n    v3:\n    - Add comment to explain the process of picking up minimum\n      page sizes for mempool\n    \n    v2:\n    - Add documentation changes and ABI break\n    \n    v1:\n    - Adjust all calls to memseg walk functions to ignore external\n      segments where it made sense to do so\n\n doc/guides/rel_notes/deprecation.rst          | 15 --------\n doc/guides/rel_notes/release_18_11.rst        | 12 ++++++-\n drivers/bus/fslmc/fslmc_vfio.c                |  7 ++--\n drivers/net/mlx4/mlx4_mr.c                    |  3 ++\n drivers/net/mlx5/mlx5.c                       |  5 ++-\n drivers/net/mlx5/mlx5_mr.c                    |  3 ++\n drivers/net/virtio/virtio_user/vhost_kernel.c |  5 ++-\n lib/librte_eal/bsdapp/eal/Makefile            |  2 +-\n lib/librte_eal/bsdapp/eal/eal.c               |  3 ++\n lib/librte_eal/bsdapp/eal/eal_memory.c        |  7 ++--\n lib/librte_eal/common/eal_common_memory.c     |  3 ++\n .../common/include/rte_eal_memconfig.h        |  1 +\n lib/librte_eal/common/include/rte_memory.h    |  9 +++++\n lib/librte_eal/common/malloc_elem.c           | 10 ++++--\n lib/librte_eal/common/malloc_heap.c           |  9 +++--\n lib/librte_eal/common/rte_malloc.c            |  2 +-\n lib/librte_eal/linuxapp/eal/Makefile          |  2 +-\n lib/librte_eal/linuxapp/eal/eal.c             | 10 +++++-\n lib/librte_eal/linuxapp/eal/eal_memalloc.c    |  9 +++++\n lib/librte_eal/linuxapp/eal/eal_vfio.c        | 17 ++++++---\n lib/librte_eal/meson.build                    |  2 +-\n lib/librte_mempool/rte_mempool.c              | 35 ++++++++++++++-----\n test/test/test_malloc.c                       |  3 ++\n test/test/test_memzone.c                      |  3 ++\n 24 files changed, 133 insertions(+), 44 deletions(-)",
    "diff": "diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst\nindex 138335dfb..d2aec64d1 100644\n--- a/doc/guides/rel_notes/deprecation.rst\n+++ b/doc/guides/rel_notes/deprecation.rst\n@@ -11,21 +11,6 @@ API and ABI deprecation notices are to be posted here.\n Deprecation Notices\n -------------------\n \n-* eal: certain structures will change in EAL on account of upcoming external\n-  memory support. Aside from internal changes leading to an ABI break, the\n-  following externally visible changes will also be implemented:\n-\n-  - ``rte_memseg_list`` will change to include a boolean flag indicating\n-    whether a particular memseg list is externally allocated. This will have\n-    implications for any users of memseg-walk-related functions, as they will\n-    now have to skip externally allocated segments in most cases if the intent\n-    is to only iterate over internal DPDK memory.\n-  - ``socket_id`` parameter across the entire DPDK will gain additional meaning,\n-    as some socket ID's will now be representing externally allocated memory. No\n-    changes will be required for existing code as backwards compatibility will\n-    be kept, and those who do not use this feature will not see these extra\n-    socket ID's.\n-\n * eal: both declaring and identifying devices will be streamlined in v18.11.\n   New functions will appear to query a specific port from buses, classes of\n   device and device drivers. Device declaration will be made coherent with the\ndiff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst\nindex bc9b74ec4..e96ec9b43 100644\n--- a/doc/guides/rel_notes/release_18_11.rst\n+++ b/doc/guides/rel_notes/release_18_11.rst\n@@ -91,6 +91,13 @@ API Changes\n   flag the MAC can be properly configured in any case. This is particularly\n   important for bonding.\n \n+* eal: The following API changes were made in 18.11:\n+\n+  - ``rte_memseg_list`` structure now has an additional flag indicating whether\n+    the memseg list is externally allocated. This will have implications for any\n+    users of memseg-walk-related functions, as they will now have to skip\n+    externally allocated segments in most cases if the intent is to only iterate\n+    over internal DPDK memory.\n \n ABI Changes\n -----------\n@@ -107,6 +114,9 @@ ABI Changes\n    =========================================================\n \n \n+* eal: EAL library ABI version was changed due to previously announced work on\n+       supporting external memory in DPDK.\n+\n Removed Items\n -------------\n \n@@ -152,7 +162,7 @@ The libraries prepended with a plus sign were incremented in this version.\n      librte_compressdev.so.1\n      librte_cryptodev.so.5\n      librte_distributor.so.1\n-     librte_eal.so.8\n+   + librte_eal.so.9\n      librte_ethdev.so.10\n      librte_eventdev.so.4\n      librte_flow_classify.so.1\ndiff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c\nindex 4c2cd2a87..2e9244fb7 100644\n--- a/drivers/bus/fslmc/fslmc_vfio.c\n+++ b/drivers/bus/fslmc/fslmc_vfio.c\n@@ -317,12 +317,15 @@ fslmc_unmap_dma(uint64_t vaddr, uint64_t iovaddr __rte_unused, size_t len)\n }\n \n static int\n-fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,\n-\t\t const struct rte_memseg *ms, void *arg)\n+fslmc_dmamap_seg(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n+\t\tvoid *arg)\n {\n \tint *n_segs = arg;\n \tint ret;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tret = fslmc_map_dma(ms->addr_64, ms->iova, ms->len);\n \tif (ret)\n \t\tDPAA2_BUS_ERR(\"Unable to VFIO map (addr=%p, len=%zu)\",\ndiff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c\nindex d23d3c613..9f5d790b6 100644\n--- a/drivers/net/mlx4/mlx4_mr.c\n+++ b/drivers/net/mlx4/mlx4_mr.c\n@@ -496,6 +496,9 @@ mr_find_contig_memsegs_cb(const struct rte_memseg_list *msl,\n {\n \tstruct mr_find_contig_memsegs_data *data = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (data->addr < ms->addr_64 || data->addr >= ms->addr_64 + len)\n \t\treturn 0;\n \t/* Found, save it and stop walking. */\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 30d4e70a7..c90e1d8ce 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -568,11 +568,14 @@ static struct rte_pci_driver mlx5_driver;\n static void *uar_base;\n \n static int\n-find_lower_va_bound(const struct rte_memseg_list *msl __rte_unused,\n+find_lower_va_bound(const struct rte_memseg_list *msl,\n \t\tconst struct rte_memseg *ms, void *arg)\n {\n \tvoid **addr = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (*addr == NULL)\n \t\t*addr = ms->addr;\n \telse\ndiff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c\nindex 1d1bcb5fe..fd4345f9c 100644\n--- a/drivers/net/mlx5/mlx5_mr.c\n+++ b/drivers/net/mlx5/mlx5_mr.c\n@@ -486,6 +486,9 @@ mr_find_contig_memsegs_cb(const struct rte_memseg_list *msl,\n {\n \tstruct mr_find_contig_memsegs_data *data = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (data->addr < ms->addr_64 || data->addr >= ms->addr_64 + len)\n \t\treturn 0;\n \t/* Found, save it and stop walking. */\ndiff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c\nindex d1be82162..91cd545b2 100644\n--- a/drivers/net/virtio/virtio_user/vhost_kernel.c\n+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c\n@@ -75,13 +75,16 @@ struct walk_arg {\n \tuint32_t region_nr;\n };\n static int\n-add_memory_region(const struct rte_memseg_list *msl __rte_unused,\n+add_memory_region(const struct rte_memseg_list *msl,\n \t\tconst struct rte_memseg *ms, size_t len, void *arg)\n {\n \tstruct walk_arg *wa = arg;\n \tstruct vhost_memory_region *mr;\n \tvoid *start_addr;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (wa->region_nr >= max_regions)\n \t\treturn -1;\n \ndiff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex d27da3d15..97bff4852 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -22,7 +22,7 @@ LDLIBS += -lrte_kvargs\n \n EXPORT_MAP := ../../rte_eal_version.map\n \n-LIBABIVER := 8\n+LIBABIVER := 9\n \n # specific to bsdapp exec-env\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c\ndiff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex d7ae9d686..7735194a3 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -502,6 +502,9 @@ check_socket(const struct rte_memseg_list *msl, void *arg)\n {\n \tint *socket_id = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (msl->socket_id == *socket_id && msl->memseg_arr.count != 0)\n \t\treturn 1;\n \ndiff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c b/lib/librte_eal/bsdapp/eal/eal_memory.c\nindex 65ea670f9..4b092e1f2 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_memory.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c\n@@ -236,12 +236,15 @@ struct attach_walk_args {\n \tint seg_idx;\n };\n static int\n-attach_segment(const struct rte_memseg_list *msl __rte_unused,\n-\t\tconst struct rte_memseg *ms, void *arg)\n+attach_segment(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n+\t\tvoid *arg)\n {\n \tstruct attach_walk_args *wa = arg;\n \tvoid *addr;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \taddr = mmap(ms->addr, ms->len, PROT_READ | PROT_WRITE,\n \t\t\tMAP_SHARED | MAP_FIXED, wa->fd_hugepage,\n \t\t\twa->seg_idx * EAL_PAGE_SIZE);\ndiff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex 30d018209..a2461ed79 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -272,6 +272,9 @@ physmem_size(const struct rte_memseg_list *msl, void *arg)\n {\n \tuint64_t *total_len = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \t*total_len += msl->memseg_arr.count * msl->page_sz;\n \n \treturn 0;\ndiff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h\nindex 1d8b0a6fe..6baa6854f 100644\n--- a/lib/librte_eal/common/include/rte_eal_memconfig.h\n+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h\n@@ -33,6 +33,7 @@ struct rte_memseg_list {\n \tsize_t len; /**< Length of memory area covered by this memseg list. */\n \tint socket_id; /**< Socket ID for all memsegs in this list. */\n \tuint64_t page_sz; /**< Page size for all memsegs in this list. */\n+\tunsigned int external; /**< 1 if this list points to external memory */\n \tvolatile uint32_t version; /**< version number for multiprocess sync. */\n \tstruct rte_fbarray memseg_arr;\n };\ndiff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h\nindex 14bd277a4..ffdd56bfb 100644\n--- a/lib/librte_eal/common/include/rte_memory.h\n+++ b/lib/librte_eal/common/include/rte_memory.h\n@@ -215,6 +215,9 @@ typedef int (*rte_memseg_list_walk_t)(const struct rte_memseg_list *msl,\n  * @note This function read-locks the memory hotplug subsystem, and thus cannot\n  *       be used within memory-related callback functions.\n  *\n+ * @note This function will also walk through externally allocated segments. It\n+ *       is up to the user to decide whether to skip through these segments.\n+ *\n  * @param func\n  *   Iterator function\n  * @param arg\n@@ -233,6 +236,9 @@ rte_memseg_walk(rte_memseg_walk_t func, void *arg);\n  * @note This function read-locks the memory hotplug subsystem, and thus cannot\n  *       be used within memory-related callback functions.\n  *\n+ * @note This function will also walk through externally allocated segments. It\n+ *       is up to the user to decide whether to skip through these segments.\n+ *\n  * @param func\n  *   Iterator function\n  * @param arg\n@@ -251,6 +257,9 @@ rte_memseg_contig_walk(rte_memseg_contig_walk_t func, void *arg);\n  * @note This function read-locks the memory hotplug subsystem, and thus cannot\n  *       be used within memory-related callback functions.\n  *\n+ * @note This function will also walk through externally allocated segments. It\n+ *       is up to the user to decide whether to skip through these segments.\n+ *\n  * @param func\n  *   Iterator function\n  * @param arg\ndiff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c\nindex e0a8ed15b..1a74660de 100644\n--- a/lib/librte_eal/common/malloc_elem.c\n+++ b/lib/librte_eal/common/malloc_elem.c\n@@ -39,10 +39,14 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)\n \tcontig_seg_start = RTE_PTR_ALIGN_CEIL(data_start, align);\n \n \t/* if we're in IOVA as VA mode, or if we're in legacy mode with\n-\t * hugepages, all elements are IOVA-contiguous.\n+\t * hugepages, all elements are IOVA-contiguous. however, we can only\n+\t * make these assumptions about internal memory - externally allocated\n+\t * segments have to be checked.\n \t */\n-\tif (rte_eal_iova_mode() == RTE_IOVA_VA ||\n-\t\t\t(internal_config.legacy_mem && rte_eal_has_hugepages()))\n+\tif (!elem->msl->external &&\n+\t\t\t(rte_eal_iova_mode() == RTE_IOVA_VA ||\n+\t\t\t\t(internal_config.legacy_mem &&\n+\t\t\t\t\trte_eal_has_hugepages())))\n \t\treturn RTE_PTR_DIFF(data_end, contig_seg_start);\n \n \tcur_page = RTE_PTR_ALIGN_FLOOR(contig_seg_start, page_sz);\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex ac7bbb3ba..3c8e2063b 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -95,6 +95,9 @@ malloc_add_seg(const struct rte_memseg_list *msl,\n \tstruct malloc_heap *heap;\n \tint msl_idx;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \theap = &mcfg->malloc_heaps[msl->socket_id];\n \n \t/* msl is const, so find it */\n@@ -754,8 +757,10 @@ malloc_heap_free(struct malloc_elem *elem)\n \t/* anything after this is a bonus */\n \tret = 0;\n \n-\t/* ...of which we can't avail if we are in legacy mode */\n-\tif (internal_config.legacy_mem)\n+\t/* ...of which we can't avail if we are in legacy mode, or if this is an\n+\t * externally allocated segment.\n+\t */\n+\tif (internal_config.legacy_mem || msl->external)\n \t\tgoto free_unlock;\n \n \t/* check if we can free any memory back to the system */\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex b51a6d111..47ca5a742 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -223,7 +223,7 @@ rte_malloc_virt2iova(const void *addr)\n \tif (elem == NULL)\n \t\treturn RTE_BAD_IOVA;\n \n-\tif (rte_eal_iova_mode() == RTE_IOVA_VA)\n+\tif (!elem->msl->external && rte_eal_iova_mode() == RTE_IOVA_VA)\n \t\treturn (uintptr_t) addr;\n \n \tms = rte_mem_virt2memseg(addr, elem->msl);\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex fd92c75c2..5c16bc40f 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -10,7 +10,7 @@ ARCH_DIR ?= $(RTE_ARCH)\n EXPORT_MAP := ../../rte_eal_version.map\n VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)\n \n-LIBABIVER := 8\n+LIBABIVER := 9\n \n VPATH += $(RTE_SDK)/lib/librte_eal/common\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex e59ac6577..253a6aece 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -725,6 +725,9 @@ check_socket(const struct rte_memseg_list *msl, void *arg)\n {\n \tint *socket_id = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \treturn *socket_id == msl->socket_id;\n }\n \n@@ -1059,7 +1062,12 @@ mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n \t\tvoid *arg __rte_unused)\n {\n \t/* ms is const, so find this memseg */\n-\tstruct rte_memseg *found = rte_mem_virt2memseg(ms->addr, msl);\n+\tstruct rte_memseg *found;\n+\n+\tif (msl->external)\n+\t\treturn 0;\n+\n+\tfound = rte_mem_virt2memseg(ms->addr, msl);\n \n \tfound->flags &= ~RTE_MEMSEG_FLAG_DO_NOT_FREE;\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\nindex 71a6e0fd9..f6a0098af 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n@@ -1408,6 +1408,9 @@ sync_walk(const struct rte_memseg_list *msl, void *arg __rte_unused)\n \tunsigned int i;\n \tint msl_idx;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tmsl_idx = msl - mcfg->memsegs;\n \tprimary_msl = &mcfg->memsegs[msl_idx];\n \tlocal_msl = &local_memsegs[msl_idx];\n@@ -1456,6 +1459,9 @@ secondary_msl_create_walk(const struct rte_memseg_list *msl,\n \tchar name[PATH_MAX];\n \tint msl_idx, ret;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tmsl_idx = msl - mcfg->memsegs;\n \tprimary_msl = &mcfg->memsegs[msl_idx];\n \tlocal_msl = &local_memsegs[msl_idx];\n@@ -1509,6 +1515,9 @@ fd_list_create_walk(const struct rte_memseg_list *msl,\n \tunsigned int len;\n \tint msl_idx;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tmsl_idx = msl - mcfg->memsegs;\n \tlen = msl->memseg_arr.len;\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex c68dc38e0..fddbc3b54 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -1082,11 +1082,14 @@ rte_vfio_get_group_num(const char *sysfs_base,\n }\n \n static int\n-type1_map(const struct rte_memseg_list *msl __rte_unused,\n-\t\tconst struct rte_memseg *ms, void *arg)\n+type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms,\n+\t\tvoid *arg)\n {\n \tint *vfio_container_fd = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \treturn vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova,\n \t\t\tms->len, 1);\n }\n@@ -1196,11 +1199,14 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,\n }\n \n static int\n-vfio_spapr_map_walk(const struct rte_memseg_list *msl __rte_unused,\n+vfio_spapr_map_walk(const struct rte_memseg_list *msl,\n \t\tconst struct rte_memseg *ms, void *arg)\n {\n \tint *vfio_container_fd = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \treturn vfio_spapr_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova,\n \t\t\tms->len, 1);\n }\n@@ -1210,12 +1216,15 @@ struct spapr_walk_param {\n \tuint64_t hugepage_sz;\n };\n static int\n-vfio_spapr_window_size_walk(const struct rte_memseg_list *msl __rte_unused,\n+vfio_spapr_window_size_walk(const struct rte_memseg_list *msl,\n \t\tconst struct rte_memseg *ms, void *arg)\n {\n \tstruct spapr_walk_param *param = arg;\n \tuint64_t max = ms->iova + ms->len;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (max > param->window_size) {\n \t\tparam->hugepage_sz = ms->hugepage_sz;\n \t\tparam->window_size = max;\ndiff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build\nindex e1fde15d1..62ef985b9 100644\n--- a/lib/librte_eal/meson.build\n+++ b/lib/librte_eal/meson.build\n@@ -21,7 +21,7 @@ else\n \terror('unsupported system type \"@0@\"'.format(host_machine.system()))\n endif\n \n-version = 8  # the version of the EAL API\n+version = 9  # the version of the EAL API\n allow_experimental_apis = true\n deps += 'compat'\n deps += 'kvargs'\ndiff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex 03e6b5f73..2ed539f01 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -99,25 +99,44 @@ static unsigned optimize_object_size(unsigned obj_size)\n \treturn new_obj_size * RTE_MEMPOOL_ALIGN;\n }\n \n+struct pagesz_walk_arg {\n+\tint socket_id;\n+\tsize_t min;\n+};\n+\n static int\n find_min_pagesz(const struct rte_memseg_list *msl, void *arg)\n {\n-\tsize_t *min = arg;\n+\tstruct pagesz_walk_arg *wa = arg;\n+\tbool valid;\n \n-\tif (msl->page_sz < *min)\n-\t\t*min = msl->page_sz;\n+\t/*\n+\t * we need to only look at page sizes available for a particular socket\n+\t * ID.  so, we either need an exact match on socket ID (can match both\n+\t * native and external memory), or, if SOCKET_ID_ANY was specified as a\n+\t * socket ID argument, we must only look at native memory and ignore any\n+\t * page sizes associated with external memory.\n+\t */\n+\tvalid = msl->socket_id == wa->socket_id;\n+\tvalid |= wa->socket_id == SOCKET_ID_ANY && msl->external == 0;\n+\n+\tif (valid && msl->page_sz < wa->min)\n+\t\twa->min = msl->page_sz;\n \n \treturn 0;\n }\n \n static size_t\n-get_min_page_size(void)\n+get_min_page_size(int socket_id)\n {\n-\tsize_t min_pagesz = SIZE_MAX;\n+\tstruct pagesz_walk_arg wa;\n \n-\trte_memseg_list_walk(find_min_pagesz, &min_pagesz);\n+\twa.min = SIZE_MAX;\n+\twa.socket_id = socket_id;\n \n-\treturn min_pagesz == SIZE_MAX ? (size_t) getpagesize() : min_pagesz;\n+\trte_memseg_list_walk(find_min_pagesz, &wa);\n+\n+\treturn wa.min == SIZE_MAX ? (size_t) getpagesize() : wa.min;\n }\n \n \n@@ -470,7 +489,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)\n \t\tpg_sz = 0;\n \t\tpg_shift = 0;\n \t} else if (try_contig) {\n-\t\tpg_sz = get_min_page_size();\n+\t\tpg_sz = get_min_page_size(mp->socket_id);\n \t\tpg_shift = rte_bsf32(pg_sz);\n \t} else {\n \t\tpg_sz = getpagesize();\ndiff --git a/test/test/test_malloc.c b/test/test/test_malloc.c\nindex 4b5abb4e0..5e5272419 100644\n--- a/test/test/test_malloc.c\n+++ b/test/test/test_malloc.c\n@@ -711,6 +711,9 @@ check_socket_mem(const struct rte_memseg_list *msl, void *arg)\n {\n \tint32_t *socket = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \treturn *socket == msl->socket_id;\n }\n \ndiff --git a/test/test/test_memzone.c b/test/test/test_memzone.c\nindex 452d7cc5e..9fe465e62 100644\n--- a/test/test/test_memzone.c\n+++ b/test/test/test_memzone.c\n@@ -115,6 +115,9 @@ find_available_pagesz(const struct rte_memseg_list *msl, void *arg)\n {\n \tstruct walk_arg *wa = arg;\n \n+\tif (msl->external)\n+\t\treturn 0;\n+\n \tif (msl->page_sz == RTE_PGSIZE_2M)\n \t\twa->hugepage_2MB_avail = 1;\n \tif (msl->page_sz == RTE_PGSIZE_1G)\n",
    "prefixes": [
        "v4",
        "02/20"
    ]
}