get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 127915,
    "url": "http://patches.dpdk.org/api/patches/127915/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230601200812.672233-8-maxime.coquelin@redhat.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": "<20230601200812.672233-8-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230601200812.672233-8-maxime.coquelin@redhat.com",
    "date": "2023-06-01T20:07:53",
    "name": "[v4,07/26] vhost: add page size info to IOTLB entry",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0a673cb9cff62eabaa5ed47cb6ef9be9111e0a9a",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230601200812.672233-8-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 28308,
            "url": "http://patches.dpdk.org/api/series/28308/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28308",
            "date": "2023-06-01T20:07:46",
            "name": "Add VDUSE support to Vhost library",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/28308/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/127915/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/127915/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6F2D242C08;\n\tThu,  1 Jun 2023 22:09:08 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 44A2E42DA0;\n\tThu,  1 Jun 2023 22:08:46 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id D18CD42D53\n for <dev@dpdk.org>; Thu,  1 Jun 2023 22:08:43 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-427-ngUh9MP5MwOjwTPae5c1pQ-1; Thu, 01 Jun 2023 16:08:40 -0400",
            "from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com\n [10.11.54.4])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 00F78802E58;\n Thu,  1 Jun 2023 20:08:40 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.25])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 5F167202696C;\n Thu,  1 Jun 2023 20:08:37 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1685650123;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=sGEJh1nMhfTRX7+OJKRQZyCAdFbDueQwqgvaVGPX80o=;\n b=OtgGQoZcyrRKashSwnmaUOGnRRumXkiFZ0OpWNs8ydSV1oP+m4Wcs8kC9fpymH22hq8L9P\n T0YQYHytU/DI/MUO1BQb3PjwYVukSnqanclnR295NcexwnJIF1ecqVxzkII3X8LvnsTx6h\n o/T1x0y1js+e8xO6Mt3tXDJSNbxL3JE=",
        "X-MC-Unique": "ngUh9MP5MwOjwTPae5c1pQ-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com,\n mkp@redhat.com, fbl@redhat.com, jasowang@redhat.com,\n cunming.liang@intel.com, xieyongji@bytedance.com, echaudro@redhat.com,\n eperezma@redhat.com, amorenoz@redhat.com, lulu@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH v4 07/26] vhost: add page size info to IOTLB entry",
        "Date": "Thu,  1 Jun 2023 22:07:53 +0200",
        "Message-Id": "<20230601200812.672233-8-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20230601200812.672233-1-maxime.coquelin@redhat.com>",
        "References": "<20230601200812.672233-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.4",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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"
    },
    "content": "VDUSE will close the file descriptor after having mapped\nthe shared memory, so it will not be possible to get the\npage size afterwards.\n\nThis patch adds an new page_shift field to the IOTLB entry,\nso that the information will be passed at IOTLB cache\ninsertion time. The information is stored as a bit shift\nvalue so that IOTLB entry keeps fitting in a single\ncacheline.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n lib/vhost/iotlb.c      | 46 ++++++++++++++++++++----------------------\n lib/vhost/iotlb.h      |  2 +-\n lib/vhost/vhost.h      |  1 -\n lib/vhost/vhost_user.c |  8 +++++---\n 4 files changed, 28 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c\nindex aa5100e6e7..87986f2489 100644\n--- a/lib/vhost/iotlb.c\n+++ b/lib/vhost/iotlb.c\n@@ -19,14 +19,14 @@ struct vhost_iotlb_entry {\n \tuint64_t uaddr;\n \tuint64_t uoffset;\n \tuint64_t size;\n+\tuint8_t page_shift;\n \tuint8_t perm;\n };\n \n #define IOTLB_CACHE_SIZE 2048\n \n static bool\n-vhost_user_iotlb_share_page(struct vhost_iotlb_entry *a, struct vhost_iotlb_entry *b,\n-\t\tuint64_t align)\n+vhost_user_iotlb_share_page(struct vhost_iotlb_entry *a, struct vhost_iotlb_entry *b)\n {\n \tuint64_t a_start, a_end, b_start;\n \n@@ -38,44 +38,41 @@ vhost_user_iotlb_share_page(struct vhost_iotlb_entry *a, struct vhost_iotlb_entr\n \n \t/* Assumes entry a lower than entry b */\n \tRTE_ASSERT(a_start < b_start);\n-\ta_end = RTE_ALIGN_CEIL(a_start + a->size, align);\n-\tb_start = RTE_ALIGN_FLOOR(b_start, align);\n+\ta_end = RTE_ALIGN_CEIL(a_start + a->size, RTE_BIT64(a->page_shift));\n+\tb_start = RTE_ALIGN_FLOOR(b_start, RTE_BIT64(b->page_shift));\n \n \treturn a_end > b_start;\n }\n \n static void\n-vhost_user_iotlb_set_dump(struct virtio_net *dev, struct vhost_iotlb_entry *node)\n+vhost_user_iotlb_set_dump(struct vhost_iotlb_entry *node)\n {\n-\tuint64_t align, start;\n+\tuint64_t start;\n \n \tstart = node->uaddr + node->uoffset;\n-\talign = hua_to_alignment(dev->mem, (void *)(uintptr_t)start);\n-\n-\tmem_set_dump((void *)(uintptr_t)start, node->size, true, align);\n+\tmem_set_dump((void *)(uintptr_t)start, node->size, true, RTE_BIT64(node->page_shift));\n }\n \n static void\n-vhost_user_iotlb_clear_dump(struct virtio_net *dev, struct vhost_iotlb_entry *node,\n+vhost_user_iotlb_clear_dump(struct vhost_iotlb_entry *node,\n \t\tstruct vhost_iotlb_entry *prev, struct vhost_iotlb_entry *next)\n {\n-\tuint64_t align, start, end;\n+\tuint64_t start, end;\n \n \tstart = node->uaddr + node->uoffset;\n \tend = start + node->size;\n \n-\talign = hua_to_alignment(dev->mem, (void *)(uintptr_t)start);\n-\n \t/* Skip first page if shared with previous entry. */\n-\tif (vhost_user_iotlb_share_page(prev, node, align))\n-\t\tstart = RTE_ALIGN_CEIL(start, align);\n+\tif (vhost_user_iotlb_share_page(prev, node))\n+\t\tstart = RTE_ALIGN_CEIL(start, RTE_BIT64(node->page_shift));\n \n \t/* Skip last page if shared with next entry. */\n-\tif (vhost_user_iotlb_share_page(node, next, align))\n-\t\tend = RTE_ALIGN_FLOOR(end, align);\n+\tif (vhost_user_iotlb_share_page(node, next))\n+\t\tend = RTE_ALIGN_FLOOR(end, RTE_BIT64(node->page_shift));\n \n \tif (end > start)\n-\t\tmem_set_dump((void *)(uintptr_t)start, end - start, false, align);\n+\t\tmem_set_dump((void *)(uintptr_t)start, end - start, false,\n+\t\t\tRTE_BIT64(node->page_shift));\n }\n \n static struct vhost_iotlb_entry *\n@@ -198,7 +195,7 @@ vhost_user_iotlb_cache_remove_all(struct virtio_net *dev)\n \tvhost_user_iotlb_wr_lock_all(dev);\n \n \tRTE_TAILQ_FOREACH_SAFE(node, &dev->iotlb_list, next, temp_node) {\n-\t\tvhost_user_iotlb_clear_dump(dev, node, NULL, NULL);\n+\t\tvhost_user_iotlb_clear_dump(node, NULL, NULL);\n \n \t\tTAILQ_REMOVE(&dev->iotlb_list, node, next);\n \t\tvhost_user_iotlb_pool_put(dev, node);\n@@ -223,7 +220,7 @@ vhost_user_iotlb_cache_random_evict(struct virtio_net *dev)\n \t\tif (!entry_idx) {\n \t\t\tstruct vhost_iotlb_entry *next_node = RTE_TAILQ_NEXT(node, next);\n \n-\t\t\tvhost_user_iotlb_clear_dump(dev, node, prev_node, next_node);\n+\t\t\tvhost_user_iotlb_clear_dump(node, prev_node, next_node);\n \n \t\t\tTAILQ_REMOVE(&dev->iotlb_list, node, next);\n \t\t\tvhost_user_iotlb_pool_put(dev, node);\n@@ -239,7 +236,7 @@ vhost_user_iotlb_cache_random_evict(struct virtio_net *dev)\n \n void\n vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t uaddr,\n-\t\t\t\tuint64_t uoffset, uint64_t size, uint8_t perm)\n+\t\t\t\tuint64_t uoffset, uint64_t size, uint64_t page_size, uint8_t perm)\n {\n \tstruct vhost_iotlb_entry *node, *new_node;\n \n@@ -263,6 +260,7 @@ vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t ua\n \tnew_node->uaddr = uaddr;\n \tnew_node->uoffset = uoffset;\n \tnew_node->size = size;\n+\tnew_node->page_shift = __builtin_ctzll(page_size);\n \tnew_node->perm = perm;\n \n \tvhost_user_iotlb_wr_lock_all(dev);\n@@ -276,7 +274,7 @@ vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t ua\n \t\t\tvhost_user_iotlb_pool_put(dev, new_node);\n \t\t\tgoto unlock;\n \t\t} else if (node->iova > new_node->iova) {\n-\t\t\tvhost_user_iotlb_set_dump(dev, new_node);\n+\t\t\tvhost_user_iotlb_set_dump(new_node);\n \n \t\t\tTAILQ_INSERT_BEFORE(node, new_node, next);\n \t\t\tdev->iotlb_cache_nr++;\n@@ -284,7 +282,7 @@ vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t ua\n \t\t}\n \t}\n \n-\tvhost_user_iotlb_set_dump(dev, new_node);\n+\tvhost_user_iotlb_set_dump(new_node);\n \n \tTAILQ_INSERT_TAIL(&dev->iotlb_list, new_node, next);\n \tdev->iotlb_cache_nr++;\n@@ -313,7 +311,7 @@ vhost_user_iotlb_cache_remove(struct virtio_net *dev, uint64_t iova, uint64_t si\n \t\tif (iova < node->iova + node->size) {\n \t\t\tstruct vhost_iotlb_entry *next_node = RTE_TAILQ_NEXT(node, next);\n \n-\t\t\tvhost_user_iotlb_clear_dump(dev, node, prev_node, next_node);\n+\t\t\tvhost_user_iotlb_clear_dump(node, prev_node, next_node);\n \n \t\t\tTAILQ_REMOVE(&dev->iotlb_list, node, next);\n \t\t\tvhost_user_iotlb_pool_put(dev, node);\ndiff --git a/lib/vhost/iotlb.h b/lib/vhost/iotlb.h\nindex bee36c5903..81ca04df21 100644\n--- a/lib/vhost/iotlb.h\n+++ b/lib/vhost/iotlb.h\n@@ -58,7 +58,7 @@ vhost_user_iotlb_wr_unlock_all(struct virtio_net *dev)\n }\n \n void vhost_user_iotlb_cache_insert(struct virtio_net *dev, uint64_t iova, uint64_t uaddr,\n-\t\t\t\t\tuint64_t uoffset, uint64_t size, uint8_t perm);\n+\t\tuint64_t uoffset, uint64_t size, uint64_t page_size, uint8_t perm);\n void vhost_user_iotlb_cache_remove(struct virtio_net *dev, uint64_t iova, uint64_t size);\n uint64_t vhost_user_iotlb_cache_find(struct virtio_net *dev, uint64_t iova,\n \t\t\t\t\tuint64_t *size, uint8_t perm);\ndiff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h\nindex ee952de175..de84c115b7 100644\n--- a/lib/vhost/vhost.h\n+++ b/lib/vhost/vhost.h\n@@ -1032,7 +1032,6 @@ mbuf_is_consumed(struct rte_mbuf *m)\n \treturn true;\n }\n \n-uint64_t hua_to_alignment(struct rte_vhost_memory *mem, void *ptr);\n void mem_set_dump(void *ptr, size_t size, bool enable, uint64_t alignment);\n \n /* Versioned functions */\ndiff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex 7f88a8754f..98d8b8ac79 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -743,7 +743,7 @@ log_addr_to_gpa(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \treturn log_gpa;\n }\n \n-uint64_t\n+static uint64_t\n hua_to_alignment(struct rte_vhost_memory *mem, void *ptr)\n {\n \tstruct rte_vhost_mem_region *r;\n@@ -2632,7 +2632,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,\n \tstruct virtio_net *dev = *pdev;\n \tstruct vhost_iotlb_msg *imsg = &ctx->msg.payload.iotlb;\n \tuint16_t i;\n-\tuint64_t vva, len;\n+\tuint64_t vva, len, pg_sz;\n \n \tswitch (imsg->type) {\n \tcase VHOST_IOTLB_UPDATE:\n@@ -2641,7 +2641,9 @@ vhost_user_iotlb_msg(struct virtio_net **pdev,\n \t\tif (!vva)\n \t\t\treturn RTE_VHOST_MSG_RESULT_ERR;\n \n-\t\tvhost_user_iotlb_cache_insert(dev, imsg->iova, vva, 0, len, imsg->perm);\n+\t\tpg_sz = hua_to_alignment(dev->mem, (void *)(uintptr_t)vva);\n+\n+\t\tvhost_user_iotlb_cache_insert(dev, imsg->iova, vva, 0, len, pg_sz, imsg->perm);\n \n \t\tfor (i = 0; i < dev->nr_vring; i++) {\n \t\t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n",
    "prefixes": [
        "v4",
        "07/26"
    ]
}