get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66041,
    "url": "http://patches.dpdk.org/api/patches/66041/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/c6550c8e66dbc7a54a0b495ecda58b0eb79c07ca.1582637079.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": "<c6550c8e66dbc7a54a0b495ecda58b0eb79c07ca.1582637079.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/c6550c8e66dbc7a54a0b495ecda58b0eb79c07ca.1582637079.git.anatoly.burakov@intel.com",
    "date": "2020-02-25T13:24:48",
    "name": "vfio: map contiguous areas in one go",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "78c44751b657dd6ed70ad45d8631a2abcbb6813a",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/c6550c8e66dbc7a54a0b495ecda58b0eb79c07ca.1582637079.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 8685,
            "url": "http://patches.dpdk.org/api/series/8685/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8685",
            "date": "2020-02-25T13:24:48",
            "name": "vfio: map contiguous areas in one go",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8685/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66041/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/66041/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 3BC07A055A;\n\tTue, 25 Feb 2020 14:24:45 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6E2151BF8D;\n\tTue, 25 Feb 2020 14:24:44 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by dpdk.org (Postfix) with ESMTP id 80B601F1C\n for <dev@dpdk.org>; Tue, 25 Feb 2020 14:24:42 +0100 (CET)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 25 Feb 2020 05:24:41 -0800",
            "from silpixa00399498.ir.intel.com (HELO\n silpixa00399498.ger.corp.intel.com) ([10.237.223.151])\n by fmsmga005.fm.intel.com with ESMTP; 25 Feb 2020 05:24:40 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.70,484,1574150400\"; d=\"scan'208\";a=\"436259426\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 25 Feb 2020 13:24:48 +0000",
        "Message-Id": "\n <c6550c8e66dbc7a54a0b495ecda58b0eb79c07ca.1582637079.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[dpdk-dev] [PATCH] vfio: map contiguous areas in one go",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Currently, when we are creating DMA mappings for memory that's\neither external or is backed by hugepages in IOVA as PA mode, we\nassume that each page is necessarily discontiguous. This may not\nactually be the case, especially for external memory, where the\nuser is able to create their own IOVA table and make it\ncontiguous. This is a problem because VFIO has a limited number\nof DMA mappings, and it does not appear to concatenate them and\ntreats each mapping as separate, even when they cover adjacent\nareas.\n\nFix this so that we always map contiguous memory in a single\nchunk, as opposed to mapping each segment separately.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/linux/eal/eal_vfio.c | 59 +++++++++++++++++++++++++----\n 1 file changed, 51 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c\nindex 01b5ef3f42..4502aefed3 100644\n--- a/lib/librte_eal/linux/eal/eal_vfio.c\n+++ b/lib/librte_eal/linux/eal/eal_vfio.c\n@@ -514,9 +514,11 @@ static void\n vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \t\tvoid *arg __rte_unused)\n {\n+\trte_iova_t iova_start, iova_expected;\n \tstruct rte_memseg_list *msl;\n \tstruct rte_memseg *ms;\n \tsize_t cur_len = 0;\n+\tuint64_t va_start;\n \n \tmsl = rte_mem_virt2memseg_list(addr);\n \n@@ -545,22 +547,63 @@ vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n #endif\n \t/* memsegs are contiguous in memory */\n \tms = rte_mem_virt2memseg(addr, msl);\n+\n+\t/*\n+\t * This memory is not guaranteed to be contiguous, but it still could\n+\t * be, or it could have some small contiguous chunks. Since the number\n+\t * of VFIO mappings is limited, and VFIO appears to not concatenate\n+\t * adjacent mappings, we have to do this ourselves.\n+\t *\n+\t * So, find contiguous chunks, then map them.\n+\t */\n+\tva_start = ms->addr_64;\n+\tiova_start = iova_expected = ms->iova;\n \twhile (cur_len < len) {\n+\t\tbool new_contig_area = ms->iova != iova_expected;\n+\t\tbool last_seg = (len - cur_len) == ms->len;\n+\t\tbool skip_last = false;\n+\n+\t\t/* only do mappings when current contiguous area ends */\n+\t\tif (new_contig_area) {\n+\t\t\tif (type == RTE_MEM_EVENT_ALLOC)\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 1);\n+\t\t\telse\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 0);\n+\t\t\tva_start = ms->addr_64;\n+\t\t\tiova_start = ms->iova;\n+\t\t}\n \t\t/* some memory segments may have invalid IOVA */\n \t\tif (ms->iova == RTE_BAD_IOVA) {\n \t\t\tRTE_LOG(DEBUG, EAL, \"Memory segment at %p has bad IOVA, skipping\\n\",\n \t\t\t\t\tms->addr);\n-\t\t\tgoto next;\n+\t\t\tskip_last = true;\n \t\t}\n-\t\tif (type == RTE_MEM_EVENT_ALLOC)\n-\t\t\tvfio_dma_mem_map(default_vfio_cfg, ms->addr_64,\n-\t\t\t\t\tms->iova, ms->len, 1);\n-\t\telse\n-\t\t\tvfio_dma_mem_map(default_vfio_cfg, ms->addr_64,\n-\t\t\t\t\tms->iova, ms->len, 0);\n-next:\n+\t\tiova_expected = ms->iova + ms->len;\n \t\tcur_len += ms->len;\n \t\t++ms;\n+\n+\t\t/*\n+\t\t * don't count previous segment, and don't attempt to\n+\t\t * dereference a potentially invalid pointer.\n+\t\t */\n+\t\tif (skip_last && !last_seg) {\n+\t\t\tiova_expected = iova_start = ms->iova;\n+\t\t\tva_start = ms->addr_64;\n+\t\t} else if (!skip_last && last_seg) {\n+\t\t\t/* this is the last segment and we're not skipping */\n+\t\t\tif (type == RTE_MEM_EVENT_ALLOC)\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 1);\n+\t\t\telse\n+\t\t\t\tvfio_dma_mem_map(default_vfio_cfg, va_start,\n+\t\t\t\t\t\tiova_start,\n+\t\t\t\t\t\tiova_expected - iova_start, 0);\n+\t\t}\n \t}\n #ifdef RTE_ARCH_PPC_64\n \tcur_len = 0;\n",
    "prefixes": []
}