Show a patch.

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

{
    "id": 44224,
    "url": "http://patches.dpdk.org/api/patches/44224/",
    "web_url": "http://patches.dpdk.org/patch/44224/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<e044616faa33794c4f59844112137ef28b0ce57f.1536064999.git.anatoly.burakov@intel.com>",
    "date": "2018-09-04T13:11:37",
    "name": "[02/16] mem: allow memseg lists to be marked as external",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d5f798bb660f35df495efcb3db5680c41e115dc7",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/",
        "name": "Burakov, Anatoly",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44224/mbox/",
    "series": [
        {
            "id": 1170,
            "url": "http://patches.dpdk.org/api/series/1170/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1170",
            "date": "2018-09-04T13:11:35",
            "name": "Support externally allocated memory in DPDK",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1170/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44224/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44224/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 1.7.0.7",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 8807F2D13;\n\tTue,  4 Sep 2018 15:12:02 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 31E8811A4\n\tfor <dev@dpdk.org>; Tue,  4 Sep 2018 15:11:57 +0200 (CEST)",
            "from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t04 Sep 2018 06:11:56 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga007.fm.intel.com with ESMTP; 04 Sep 2018 06:11:52 -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\tw84DBqB7023350; Tue, 4 Sep 2018 14:11:52 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w84DBq4g024280;\n\tTue, 4 Sep 2018 14:11:52 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w84DBpuA024205;\n\tTue, 4 Sep 2018 14:11:51 +0100"
        ],
        "References": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<e044616faa33794c4f59844112137ef28b0ce57f.1536064999.git.anatoly.burakov@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,329,1531810800\"; d=\"scan'208\";a=\"67423757\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": [
            "<cover.1536064999.git.anatoly.burakov@intel.com>",
            "<cover.1536064999.git.anatoly.burakov@intel.com>"
        ],
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Tue,  4 Sep 2018 14:11:37 +0100",
        "Cc": "Hemant 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\tsrinath.mannam@broadcom.com, scott.branden@broadcom.com,\n\tajit.khaparde@broadcom.com, keith.wiles@intel.com, thomas@monjalon.net",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH 02/16] mem: allow memseg lists to be marked as\n\texternal"
    },
    "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\nAll current calls for memseg walk functions were adjusted to\nignore external segments where it made sense. Mempools is a\nspecial case, because we may be asked to allocate a mempool on\na specific socket, and we need to ignore all page sizes on\nother heaps or other sockets. Previously, this assumption of\nknowing all page sizes was not a problem, but it will be now,\nso we have to match socket ID with page size when calculating\nminimum page size for a mempool.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n    v1:\n    - Adjust all calls to memseg walk functions to ignore external\n      segments where it made sense to do so\n\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/eal.c               |  3 ++\n lib/librte_eal/bsdapp/eal/eal_memory.c        |  7 +++--\n lib/librte_eal/common/eal_common_memory.c     |  4 +++\n .../common/include/rte_eal_memconfig.h        |  1 +\n lib/librte_eal/common/include/rte_memory.h    |  9 ++++++\n lib/librte_eal/common/malloc_heap.c           |  9 ++++--\n lib/librte_eal/linuxapp/eal/eal.c             |  3 ++\n lib/librte_eal/linuxapp/eal/eal_memalloc.c    |  9 ++++++\n lib/librte_eal/linuxapp/eal/eal_vfio.c        | 17 +++++++---\n lib/librte_mempool/rte_mempool.c              | 31 ++++++++++++++-----\n test/test/test_malloc.c                       |  3 ++\n test/test/test_memzone.c                      |  3 ++\n 17 files changed, 102 insertions(+), 20 deletions(-)",
    "diff": "diff --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 ec63bc6e2..d9ed15880 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 b2444096c..885c59c8a 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/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 0868bf681..55a11bf4d 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;\n@@ -547,6 +550,7 @@ rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)\n \treturn ret;\n }\n \n+\n /* init memory subsystem */\n int\n rte_eal_memory_init(void)\ndiff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h\nindex 1d8b0a6fe..76faf9a4a 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+\tbool external; /**< true 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 c4b7f4cff..b381d1cb6 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_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex 12aaf2d72..8c37b9d7c 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@@ -756,8 +759,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/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex e59ac6577..729ae2060 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 \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\nindex d040a2f71..8b0bbe43f 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c\n@@ -1250,6 +1250,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@@ -1298,6 +1301,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@@ -1328,6 +1334,9 @@ secondary_lock_list_create_walk(const struct rte_memseg_list *msl,\n \tint msl_idx;\n \tint *data;\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_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex 03e6b5f73..4eae7bec6 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -99,25 +99,40 @@ 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+\tvalid = msl->socket_id == wa->socket_id;\n+\tvalid |= wa->socket_id == SOCKET_ID_ANY && !msl->external;\n+\n+\tif (!valid)\n+\t\treturn 0;\n+\n+\tif (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 +485,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": [
        "02/16"
    ]
}