get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45749,
    "url": "http://patches.dpdk.org/api/patches/45749/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/8c48cc1fd9233c743f9c55b21c62feb997535d69.1538384304.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": "<8c48cc1fd9233c743f9c55b21c62feb997535d69.1538384304.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/8c48cc1fd9233c743f9c55b21c62feb997535d69.1538384304.git.anatoly.burakov@intel.com",
    "date": "2018-10-01T11:05:06",
    "name": "[v7,17/21] malloc: enable event callbacks for external memory",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8d7a1d5207c008728455eed9d5065e50815a3441",
    "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/8c48cc1fd9233c743f9c55b21c62feb997535d69.1538384304.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 1613,
            "url": "http://patches.dpdk.org/api/series/1613/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1613",
            "date": "2018-10-01T11:04:49",
            "name": "Support externally allocated memory in DPDK",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/1613/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45749/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/45749/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 814061B131;\n\tMon,  1 Oct 2018 13:05:39 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id C62455F20\n\tfor <dev@dpdk.org>; Mon,  1 Oct 2018 13:05:24 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t01 Oct 2018 04:05:23 -0700",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga001.fm.intel.com with ESMTP; 01 Oct 2018 04:05:13 -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\tw91B5DdG028052; Mon, 1 Oct 2018 12:05:13 +0100",
            "from sivswdev01.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev01.ir.intel.com with ESMTP id w91B5DqE017899;\n\tMon, 1 Oct 2018 12:05:13 +0100",
            "(from aburakov@localhost)\n\tby sivswdev01.ir.intel.com with LOCAL id w91B5DOX017895;\n\tMon, 1 Oct 2018 12:05:13 +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,327,1534834800\"; d=\"scan'208\";a=\"94975727\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Hemant Agrawal <hemant.agrawal@nxp.com>,\n\tShreyansh Jain <shreyansh.jain@nxp.com>,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>,\n\tTiwei Bie <tiwei.bie@intel.com>, Zhihong Wang <zhihong.wang@intel.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, bruce.richardson@intel.com, thomas@monjalon.net,\n\tshahafs@mellanox.com, arybchenko@solarflare.com,\n\talejandro.lucero@netronome.com",
        "Date": "Mon,  1 Oct 2018 12:05:06 +0100",
        "Message-Id": "<8c48cc1fd9233c743f9c55b21c62feb997535d69.1538384304.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": [
            "<cover.1538384304.git.anatoly.burakov@intel.com>",
            "<cover.1538384304.git.anatoly.burakov@intel.com>"
        ],
        "References": [
            "<cover.1538384304.git.anatoly.burakov@intel.com>",
            "<cover.1538044725.git.anatoly.burakov@intel.com>\n\t<cover.1538384304.git.anatoly.burakov@intel.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v7 17/21] malloc: enable event callbacks for\n\texternal memory",
        "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 adding or removing external memory from the memory map, there\nmay be actions that need to be taken on account of this memory (e.g.\nDMA mapping). Add support for triggering callbacks when adding,\nremoving, attaching or detaching external memory.\n\nSome memory event callback handlers will need additional logic to\nhandle external memory regions. For example, virtio callback has to\ncompletely ignore externally allocated memory, because there is no\nway to find file descriptors backing the memory address in a\ngeneric fashion. All other callbacks have also been adjusted to\nhandle RTE_BAD_IOVA as IOVA address, as this is one of the expected\nuse cases for external memory support.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n drivers/bus/fslmc/fslmc_vfio.c                |  7 +++++\n .../net/virtio/virtio_user/virtio_user_dev.c  |  8 ++++++\n lib/librte_eal/common/malloc_heap.c           |  7 +++++\n lib/librte_eal/common/rte_malloc.c            | 27 ++++++++++++++++---\n lib/librte_eal/linuxapp/eal/eal_vfio.c        | 10 +++++--\n 5 files changed, 53 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c\nindex cb33dd891..493b6e5be 100644\n--- a/drivers/bus/fslmc/fslmc_vfio.c\n+++ b/drivers/bus/fslmc/fslmc_vfio.c\n@@ -221,6 +221,13 @@ fslmc_memevent_cb(enum rte_mem_event type, const void *addr, size_t len,\n \t\t\t\t\t\"alloc\" : \"dealloc\",\n \t\t\t\tva, virt_addr, iova_addr, map_len);\n \n+\t\t/* iova_addr may be set to RTE_BAD_IOVA */\n+\t\tif (iova_addr == RTE_BAD_IOVA) {\n+\t\t\tDPAA2_BUS_DEBUG(\"Segment has invalid iova, skipping\\n\");\n+\t\t\tcur_len += map_len;\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tif (type == RTE_MEM_EVENT_ALLOC)\n \t\t\tret = fslmc_map_dma(virt_addr, iova_addr, map_len);\n \t\telse\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 7df600b02..de813d0df 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -13,6 +13,8 @@\n #include <sys/types.h>\n #include <sys/stat.h>\n \n+#include <rte_eal_memconfig.h>\n+\n #include \"vhost.h\"\n #include \"virtio_user_dev.h\"\n #include \"../virtio_ethdev.h\"\n@@ -282,8 +284,14 @@ virtio_user_mem_event_cb(enum rte_mem_event type __rte_unused,\n \t\t\t\t\t\t void *arg)\n {\n \tstruct virtio_user_dev *dev = arg;\n+\tstruct rte_memseg_list *msl;\n \tuint16_t i;\n \n+\t/* ignore externally allocated memory */\n+\tmsl = rte_mem_virt2memseg_list(addr);\n+\tif (msl->external)\n+\t\treturn;\n+\n \tpthread_mutex_lock(&dev->mutex);\n \n \tif (dev->started == false)\ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex adc1669aa..08ec75377 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -1031,6 +1031,9 @@ destroy_seg(struct malloc_elem *elem, size_t len)\n \n \tmsl = elem->msl;\n \n+\t/* notify all subscribers that a memory area is going to be removed */\n+\teal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE, elem, len);\n+\n \t/* this element can be removed */\n \tmalloc_elem_free_list_remove(elem);\n \tmalloc_elem_hide_region(elem, elem, len);\n@@ -1120,6 +1123,10 @@ malloc_heap_add_external_memory(struct malloc_heap *heap, void *va_addr,\n \tRTE_LOG(DEBUG, EAL, \"Added segment for heap %s starting at %p\\n\",\n \t\t\theap->name, va_addr);\n \n+\t/* notify all subscribers that a new memory area has been added */\n+\teal_memalloc_mem_event_notify(RTE_MEM_EVENT_ALLOC,\n+\t\t\tva_addr, seg_len);\n+\n \treturn 0;\n }\n \ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex 72e42b337..2c19c2f87 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -25,6 +25,7 @@\n #include <rte_malloc.h>\n #include \"malloc_elem.h\"\n #include \"malloc_heap.h\"\n+#include \"eal_memalloc.h\"\n \n \n /* Free the memory space back to heap */\n@@ -441,15 +442,29 @@ sync_mem_walk(const struct rte_memseg_list *msl, void *arg)\n \t\tmsl_idx = msl - mcfg->memsegs;\n \t\tfound_msl = &mcfg->memsegs[msl_idx];\n \n-\t\tif (wa->attach)\n+\t\tif (wa->attach) {\n \t\t\tret = rte_fbarray_attach(&found_msl->memseg_arr);\n-\t\telse\n+\t\t} else {\n+\t\t\t/* notify all subscribers that a memory area is about to\n+\t\t\t * be removed\n+\t\t\t */\n+\t\t\teal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE,\n+\t\t\t\t\tmsl->base_va, msl->len);\n \t\t\tret = rte_fbarray_detach(&found_msl->memseg_arr);\n+\t\t}\n \n-\t\tif (ret < 0)\n+\t\tif (ret < 0) {\n \t\t\twa->result = -rte_errno;\n-\t\telse\n+\t\t} else {\n+\t\t\t/* notify all subscribers that a new memory area was\n+\t\t\t * added\n+\t\t\t */\n+\t\t\tif (wa->attach)\n+\t\t\t\teal_memalloc_mem_event_notify(\n+\t\t\t\t\t\tRTE_MEM_EVENT_ALLOC,\n+\t\t\t\t\t\tmsl->base_va, msl->len);\n \t\t\twa->result = 0;\n+\t\t}\n \t\treturn 1;\n \t}\n \treturn 0;\n@@ -499,6 +514,10 @@ sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)\n \t\trte_errno = -wa.result;\n \t\tret = -1;\n \t} else {\n+\t\t/* notify all subscribers that a new memory area was added */\n+\t\tif (attach)\n+\t\t\teal_memalloc_mem_event_notify(RTE_MEM_EVENT_ALLOC,\n+\t\t\t\t\tva_addr, len);\n \t\tret = 0;\n \t}\n unlock:\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex fddbc3b54..d7268e4ce 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -509,7 +509,7 @@ vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \tmsl = rte_mem_virt2memseg_list(addr);\n \n \t/* for IOVA as VA mode, no need to care for IOVA addresses */\n-\tif (rte_eal_iova_mode() == RTE_IOVA_VA) {\n+\tif (rte_eal_iova_mode() == RTE_IOVA_VA && msl->external == 0) {\n \t\tuint64_t vfio_va = (uint64_t)(uintptr_t)addr;\n \t\tif (type == RTE_MEM_EVENT_ALLOC)\n \t\t\tvfio_dma_mem_map(default_vfio_cfg, vfio_va, vfio_va,\n@@ -523,13 +523,19 @@ vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \t/* memsegs are contiguous in memory */\n \tms = rte_mem_virt2memseg(addr, msl);\n \twhile (cur_len < len) {\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}\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-\n+next:\n \t\tcur_len += ms->len;\n \t\t++ms;\n \t}\n",
    "prefixes": [
        "v7",
        "17/21"
    ]
}