Commit ca051264 authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Jim Harris
Browse files

vhost: dump interrupt coalescing parameters in RPC info/config



Change-Id: I7fec9a5fe30bb64f6c76fc951a40e27cf86ecdee
Signed-off-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/415461


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 20553a1a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -162,6 +162,18 @@ const struct spdk_cpuset *spdk_vhost_dev_get_cpumask(struct spdk_vhost_dev *vdev
int spdk_vhost_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,
			      uint32_t iops_threshold);

/**
 * Get coalescing parameters.
 *
 * \see spdk_vhost_set_coalescing
 *
 * \param vdev vhost device.
 * \param delay_base_us Optional pointer to store base delay time.
 * \param iops_threshold Optional pointer to store IOPS threshold.
 */
void spdk_vhost_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us,
			       uint32_t *iops_threshold);

/**
 * Construct an empty vhost SCSI device.  This will create a
 * Unix domain socket together with a vhost-user slave server waiting
+34 −1
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ spdk_vhost_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,
			  uint32_t iops_threshold)
{
	uint64_t delay_time_base = delay_base_us * spdk_get_ticks_hz() / 1000000ULL;
	uint32_t io_rate = iops_threshold * SPDK_VHOST_DEV_STATS_CHECK_INTERVAL_MS / 1000;
	uint32_t io_rate = iops_threshold * SPDK_VHOST_DEV_STATS_CHECK_INTERVAL_MS / 1000U;

	if (delay_time_base >= UINT32_MAX) {
		SPDK_ERRLOG("Delay time of %"PRIu32" is to big\n", delay_base_us);
@@ -351,9 +351,25 @@ spdk_vhost_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,

	vdev->coalescing_delay_time_base = delay_time_base;
	vdev->coalescing_io_rate_threshold = io_rate;

	vdev->coalescing_delay_us = delay_base_us;
	vdev->coalescing_iops_threshold = iops_threshold;
	return 0;
}

void
spdk_vhost_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us,
			  uint32_t *iops_threshold)
{
	if (delay_base_us) {
		*delay_base_us = vdev->coalescing_delay_us;
	}

	if (iops_threshold) {
		*iops_threshold = vdev->coalescing_iops_threshold;
	}
}

/*
 * Enqueue id and len to used ring.
 */
@@ -1386,6 +1402,8 @@ static int
spdk_vhost_config_json_cb(struct spdk_vhost_dev *vdev, void *arg)
{
	struct spdk_vhost_write_config_json_ctx *ctx = arg;
	uint32_t delay_base_us;
	uint32_t iops_threshold;

	if (vdev == NULL) {
		spdk_json_write_array_end(ctx->w);
@@ -1395,6 +1413,21 @@ spdk_vhost_config_json_cb(struct spdk_vhost_dev *vdev, void *arg)
	}

	vdev->backend->write_config_json(vdev, ctx->w);

	spdk_vhost_get_coalescing(vdev, &delay_base_us, &iops_threshold);
	if (delay_base_us) {
		spdk_json_write_object_begin(ctx->w);
		spdk_json_write_named_string(ctx->w, "method", "set_vhost_controller_coalescing");

		spdk_json_write_named_object_begin(ctx->w, "params");
		spdk_json_write_named_string(ctx->w, "ctrlr", vdev->name);
		spdk_json_write_named_uint32(ctx->w, "delay_base_us", delay_base_us);
		spdk_json_write_named_uint32(ctx->w, "iops_threshold", iops_threshold);
		spdk_json_write_object_end(ctx->w);

		spdk_json_write_object_end(ctx->w);
	}

	return 0;
}

+6 −0
Original line number Diff line number Diff line
@@ -150,6 +150,12 @@ struct spdk_vhost_dev {

	const struct spdk_vhost_dev_backend *backend;

	/* Saved orginal values used to setup coalescing to avoid integer
	 * rounding issues during save/load config.
	 */
	uint32_t coalescing_delay_us;
	uint32_t coalescing_iops_threshold;

	uint32_t coalescing_delay_time_base;

	/* Threshold when event coalescing for virtqueue will be turned on. */
+6 −0
Original line number Diff line number Diff line
@@ -459,6 +459,8 @@ static int
spdk_rpc_get_vhost_controllers_cb(struct spdk_vhost_dev *vdev, void *arg)
{
	struct rpc_get_vhost_ctrlrs *ctx = arg;
	uint32_t delay_base_us, iops_threshold;


	if (vdev == NULL) {
		spdk_json_write_array_end(ctx->w);
@@ -467,10 +469,14 @@ spdk_rpc_get_vhost_controllers_cb(struct spdk_vhost_dev *vdev, void *arg)
		return 0;
	}

	spdk_vhost_get_coalescing(vdev, &delay_base_us, &iops_threshold);

	spdk_json_write_object_begin(ctx->w);

	spdk_json_write_named_string(ctx->w, "ctrlr", spdk_vhost_dev_get_name(vdev));
	spdk_json_write_named_string_fmt(ctx->w, "cpumask", "0x%s", spdk_cpuset_fmt(vdev->cpumask));
	spdk_json_write_named_uint32(ctx->w, "delay_base_us", delay_base_us);
	spdk_json_write_named_uint32(ctx->w, "iops_threshold", iops_threshold);

	spdk_json_write_named_object_begin(ctx->w, "backend_specific");
	spdk_vhost_dump_info_json(vdev, ctx->w);