diff --git a/0013-vhost-add-vhost-interrupt-coalescing.patch b/0013-vhost-add-vhost-interrupt-coalescing.patch index e7cf72dfea19ca978cb896f6106b84eae1309044..d611aa0870080f54c1272f12099fd5fa6b414997 100644 --- a/0013-vhost-add-vhost-interrupt-coalescing.patch +++ b/0013-vhost-add-vhost-interrupt-coalescing.patch @@ -1,20 +1,22 @@ -From 1db757114250af31f3731e38bbcf11fffdae6b56 Mon Sep 17 00:00:00 2001 +From 22f290e64efb5f65af5bb67b3602c0c7a9049bd7 Mon Sep 17 00:00:00 2001 From: Chengfei Huang Date: Wed, 21 May 2025 14:47:22 +0800 Subject: [PATCH] vhost: add vhost interrupt coalescing -Based on virtio event idx. use vhost -E option to enable +Based on virtio event idx. use vhost -E option to enable. +This patch is designed for high throughput, not recommended if low latency is +desired. --- - app/vhost/vhost.c | 4 ++++ + app/vhost/vhost.c | 4 +++ include/spdk/event.h | 2 +- - include/spdk/vhost.h | 8 +++++++ - lib/vhost/rte_vhost_user.c | 45 ++++++++++++++++++++++++++++++++++++++ + include/spdk/vhost.h | 8 +++++ + lib/vhost/rte_vhost_user.c | 60 ++++++++++++++++++++++++++++++++++++++ lib/vhost/spdk_vhost.map | 1 + - lib/vhost/vhost_internal.h | 4 ++++ - 6 files changed, 63 insertions(+), 1 deletion(-) + lib/vhost/vhost_internal.h | 4 +++ + 6 files changed, 78 insertions(+), 1 deletion(-) diff --git a/app/vhost/vhost.c b/app/vhost/vhost.c -index 992ba29..f3c36e9 100644 +index 992ba29a6203..ce510881ec98 100644 --- a/app/vhost/vhost.c +++ b/app/vhost/vhost.c @@ -16,6 +16,7 @@ vhost_usage(void) @@ -36,7 +38,7 @@ index 992ba29..f3c36e9 100644 return -EINVAL; } diff --git a/include/spdk/event.h b/include/spdk/event.h -index 6f4e7c8..6c65af1 100644 +index 6f4e7c8deaf0..6c65af1d9d1d 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -277,7 +277,7 @@ int spdk_app_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask); @@ -49,7 +51,7 @@ index 6f4e7c8..6c65af1 100644 enum spdk_app_parse_args_rvals { SPDK_APP_PARSE_ARGS_HELP = 0, diff --git a/include/spdk/vhost.h b/include/spdk/vhost.h -index 0206857..4f111fa 100644 +index 020685786487..4f111fac9b1f 100644 --- a/include/spdk/vhost.h +++ b/include/spdk/vhost.h @@ -340,6 +340,14 @@ int spdk_vhost_blk_construct(const char *name, const char *cpumask, const char * @@ -68,7 +70,7 @@ index 0206857..4f111fa 100644 } #endif diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c -index 17a3e0f..1d6cb3c 100644 +index 17a3e0f3651b..b5db1c50e5b2 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -23,6 +23,8 @@ static char g_vhost_user_dev_dirname[PATH_MAX] = ""; @@ -114,7 +116,7 @@ index 17a3e0f..1d6cb3c 100644 int vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *virtqueue) -@@ -357,6 +386,22 @@ vhost_vq_used_signal(struct spdk_vhost_session *vsession, +@@ -357,6 +386,37 @@ vhost_vq_used_signal(struct spdk_vhost_session *vsession, SPDK_DEBUGLOG(vhost_ring, "Queue %td - USED RING: sending IRQ: last used %"PRIu16"\n", virtqueue - vsession->virtqueue, virtqueue->last_used_idx); @@ -126,19 +128,34 @@ index 17a3e0f..1d6cb3c 100644 + struct rte_vhost_vring *vring = &virtqueue->vring; + struct vring_avail *avail = vring->avail; + uint16_t guest_used_event = spdk_vhost_used_event(virtqueue); -+ uint16_t target = guest_used_event + (uint16_t)(avail->idx - guest_used_event) * 1 / 4; -+ virtqueue->used_signalled_valid = true; -+ virtqueue->used_signalled = virtqueue->last_used_idx; ++ uint16_t cur_ring_size = (uint16_t)(avail->idx - guest_used_event); ++ uint16_t target; ++ ++ if(cur_ring_size == 1) { ++ // only one remained, complete it ASAP. ++ target = guest_used_event; ++ } else if (cur_ring_size > vring->size * 3 / 4) { ++ // vring almost full, let's interrupt front end quick. ++ target = guest_used_event + cur_ring_size * 1 / 8; ++ } else if (cur_ring_size > vring->size * 1 / 4) { ++ // vring isn't so full, let's interrupt front end a little slow. ++ target = guest_used_event + cur_ring_size * 1 / 4; ++ } else { ++ // vring almost empty, let's interrupt less for more queue item. ++ target = guest_used_event + cur_ring_size * 1 / 2; ++ } + + if(!spdk_need_event(target, new, old) && used_signalled_valid) { + return 0; + } ++ virtqueue->used_signalled_valid = true; ++ virtqueue->used_signalled = virtqueue->last_used_idx; + } #if RTE_VERSION < RTE_VERSION_NUM(22, 11, 0, 0) if (rte_vhost_vring_call(vsession->vid, virtqueue->vring_idx) == 0) { diff --git a/lib/vhost/spdk_vhost.map b/lib/vhost/spdk_vhost.map -index f8b9d55..0a0b2ab 100644 +index f8b9d55476bc..0a0b2ab05e88 100644 --- a/lib/vhost/spdk_vhost.map +++ b/lib/vhost/spdk_vhost.map @@ -2,6 +2,7 @@ @@ -150,7 +167,7 @@ index f8b9d55..0a0b2ab 100644 spdk_vhost_scsi_init; spdk_vhost_scsi_fini; diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h -index 04e7440..3d47dff 100644 +index 04e7440632b2..f94c9e157d46 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -66,6 +66,8 @@ struct spdk_vhost_virtqueue { @@ -169,6 +186,8 @@ index 04e7440..3d47dff 100644 +bool spdk_vhost_get_backend_interrupt_coalescing(void); + #endif /* SPDK_VHOST_INTERNAL_H */ + +base-commit: d4c2d3730293f91bc71c5fc38cc8ae27a7c7c9ce -- -2.33.0 +2.50.1 diff --git a/spdk.spec b/spdk.spec index d69b0e77fd5c79043a5d2803da0dee3a60e9c5a1..7eaa9790d0b07c20ccdad563a6132dce117fc240 100644 --- a/spdk.spec +++ b/spdk.spec @@ -4,7 +4,7 @@ Name: spdk Version: 24.01 -Release: 10 +Release: 11 Summary: Set of libraries and utilities for high performance user-mode storage License: BSD and MIT URL: http://spdk.io @@ -203,6 +203,9 @@ mv doc/output/html/ %{install_docdir} %changelog +* Tue Aug 19 2025 jiaqingtong - 24.01-11 +- optimize interrupt coalescing parameters + * Thu Jul 3 2025 wangzhiqiang - 24.01-10 - enable app