vhost: extract session_vq_io_stats_update
Change-Id: Id0349d571c974e963fbbf080bd6e2fe113b13622 Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4769 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3e2c9092d4
commit
6a1ec6a640
@ -305,15 +305,31 @@ vhost_vq_used_signal(struct spdk_vhost_session *vsession,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
session_vq_io_stats_update(struct spdk_vhost_session *vsession,
|
||||||
|
struct spdk_vhost_virtqueue *virtqueue, uint64_t now)
|
||||||
|
{
|
||||||
|
uint32_t irq_delay_base = vsession->coalescing_delay_time_base;
|
||||||
|
uint32_t io_threshold = vsession->coalescing_io_rate_threshold;
|
||||||
|
int32_t irq_delay;
|
||||||
|
uint32_t req_cnt;
|
||||||
|
|
||||||
|
req_cnt = virtqueue->req_cnt + virtqueue->used_req_cnt;
|
||||||
|
if (req_cnt <= io_threshold) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
irq_delay = (irq_delay_base * (req_cnt - io_threshold)) / io_threshold;
|
||||||
|
virtqueue->irq_delay_time = (uint32_t) spdk_max(0, irq_delay);
|
||||||
|
|
||||||
|
virtqueue->req_cnt = 0;
|
||||||
|
virtqueue->next_event_time = now;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_session_io_stats(struct spdk_vhost_session *vsession, uint64_t now)
|
check_session_io_stats(struct spdk_vhost_session *vsession, uint64_t now)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_virtqueue *virtqueue;
|
struct spdk_vhost_virtqueue *virtqueue;
|
||||||
uint32_t irq_delay_base = vsession->coalescing_delay_time_base;
|
|
||||||
uint32_t io_threshold = vsession->coalescing_io_rate_threshold;
|
|
||||||
int32_t irq_delay;
|
|
||||||
uint32_t req_cnt;
|
|
||||||
uint16_t q_idx;
|
uint16_t q_idx;
|
||||||
|
|
||||||
if (now < vsession->next_stats_check_time) {
|
if (now < vsession->next_stats_check_time) {
|
||||||
@ -323,17 +339,7 @@ check_session_io_stats(struct spdk_vhost_session *vsession, uint64_t now)
|
|||||||
vsession->next_stats_check_time = now + vsession->stats_check_interval;
|
vsession->next_stats_check_time = now + vsession->stats_check_interval;
|
||||||
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
||||||
virtqueue = &vsession->virtqueue[q_idx];
|
virtqueue = &vsession->virtqueue[q_idx];
|
||||||
|
session_vq_io_stats_update(vsession, virtqueue, now);
|
||||||
req_cnt = virtqueue->req_cnt + virtqueue->used_req_cnt;
|
|
||||||
if (req_cnt <= io_threshold) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
irq_delay = (irq_delay_base * (req_cnt - io_threshold)) / io_threshold;
|
|
||||||
virtqueue->irq_delay_time = (uint32_t) spdk_max(0, irq_delay);
|
|
||||||
|
|
||||||
virtqueue->req_cnt = 0;
|
|
||||||
virtqueue->next_event_time = now;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user