From 9ffd5726ecb05d9100b1eb46b4a838a3cd92d322 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Thu, 9 Aug 2018 12:15:11 +0200 Subject: [PATCH] vhost: fix coalescing time calculation irq_delay must be not less than zero. Change-Id: I22d8a7df453f07a44a32582d8e880949824bf868 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/421685 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Dariusz Stojaczyk Reviewed-by: Jim Harris --- lib/vhost/vhost.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index b0b531da3..ef6a227a0 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -267,7 +267,8 @@ check_dev_io_stats(struct spdk_vhost_dev *vdev, uint64_t now) struct spdk_vhost_virtqueue *virtqueue; uint32_t irq_delay_base = vdev->coalescing_delay_time_base; uint32_t io_threshold = vdev->coalescing_io_rate_threshold; - uint32_t irq_delay, req_cnt; + int32_t irq_delay; + uint32_t req_cnt; uint16_t q_idx; if (now < vdev->next_stats_check_time) { @@ -284,7 +285,7 @@ check_dev_io_stats(struct spdk_vhost_dev *vdev, uint64_t now) } irq_delay = (irq_delay_base * (req_cnt - io_threshold)) / io_threshold; - virtqueue->irq_delay_time = (uint32_t) spdk_min(0, irq_delay); + virtqueue->irq_delay_time = (uint32_t) spdk_max(0, irq_delay); virtqueue->req_cnt = 0; virtqueue->next_event_time = now;