vhost: fix coalescing time calculation

irq_delay must be not less than zero.

Change-Id: I22d8a7df453f07a44a32582d8e880949824bf868
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/421685
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Pawel Wodkowski 2018-08-09 12:15:11 +02:00 committed by Jim Harris
parent 94eae4eef5
commit 9ffd5726ec

View File

@ -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;