add VTune support: spin-wait stat
Change-Id: Ie25a87c4b3f781299fa744fdcff6c9a63d473935 Signed-off-by: Roman <roman.sudarikov@intel.com> Reviewed-on: https://review.gerrithub.io/365723 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
25499c4dba
commit
5b53b568e4
@ -151,6 +151,11 @@ struct spdk_bdev_fn_table {
|
|||||||
* (most likely another nested object).
|
* (most likely another nested object).
|
||||||
*/
|
*/
|
||||||
int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
|
int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
|
||||||
|
|
||||||
|
/** Get spin-time per I/O channel in microseconds.
|
||||||
|
* Optional - may be NULL.
|
||||||
|
*/
|
||||||
|
uint64_t (*get_spin_time)(struct spdk_io_channel *ch);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** bdev I/O completion status */
|
/** bdev I/O completion status */
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
|
|
||||||
#ifdef SPDK_CONFIG_VTUNE
|
#ifdef SPDK_CONFIG_VTUNE
|
||||||
#include "ittnotify.h"
|
#include "ittnotify.h"
|
||||||
|
#include "ittnotify_types.h"
|
||||||
|
int __itt_init_ittlib(const char *, __itt_group_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPDK_BDEV_IO_POOL_SIZE (64 * 1024)
|
#define SPDK_BDEV_IO_POOL_SIZE (64 * 1024)
|
||||||
@ -646,7 +648,7 @@ spdk_bdev_channel_create(void *io_device, void *ctx_buf)
|
|||||||
#ifdef SPDK_CONFIG_VTUNE
|
#ifdef SPDK_CONFIG_VTUNE
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
__itt_init_ittlib(NULL, 0);
|
||||||
name = spdk_sprintf_alloc("spdk_bdev_%s_%p", ch->bdev->name, ch);
|
name = spdk_sprintf_alloc("spdk_bdev_%s_%p", ch->bdev->name, ch);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -1264,15 +1266,17 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta
|
|||||||
#ifdef SPDK_CONFIG_VTUNE
|
#ifdef SPDK_CONFIG_VTUNE
|
||||||
uint64_t now_tsc = spdk_get_ticks();
|
uint64_t now_tsc = spdk_get_ticks();
|
||||||
if (now_tsc > (bdev_io->ch->start_tsc + bdev_io->ch->interval_tsc)) {
|
if (now_tsc > (bdev_io->ch->start_tsc + bdev_io->ch->interval_tsc)) {
|
||||||
uint64_t data[4];
|
uint64_t data[5];
|
||||||
|
|
||||||
data[0] = bdev_io->ch->stat.num_read_ops;
|
data[0] = bdev_io->ch->stat.num_read_ops;
|
||||||
data[1] = bdev_io->ch->stat.bytes_read;
|
data[1] = bdev_io->ch->stat.bytes_read;
|
||||||
data[2] = bdev_io->ch->stat.num_write_ops;
|
data[2] = bdev_io->ch->stat.num_write_ops;
|
||||||
data[3] = bdev_io->ch->stat.bytes_written;
|
data[3] = bdev_io->ch->stat.bytes_written;
|
||||||
|
data[4] = bdev_io->bdev->fn_table->get_spin_time ?
|
||||||
|
bdev_io->bdev->fn_table->get_spin_time(bdev_io->ch->channel) : 0;
|
||||||
|
|
||||||
__itt_metadata_add(g_bdev_mgr.domain, __itt_null, bdev_io->ch->handle,
|
__itt_metadata_add(g_bdev_mgr.domain, __itt_null, bdev_io->ch->handle,
|
||||||
__itt_metadata_u64, 4, data);
|
__itt_metadata_u64, 5, data);
|
||||||
|
|
||||||
memset(&bdev_io->ch->stat, 0, sizeof(bdev_io->ch->stat));
|
memset(&bdev_io->ch->stat, 0, sizeof(bdev_io->ch->stat));
|
||||||
bdev_io->ch->start_tsc = now_tsc;
|
bdev_io->ch->start_tsc = now_tsc;
|
||||||
|
@ -77,6 +77,11 @@ struct nvme_bdev {
|
|||||||
struct nvme_io_channel {
|
struct nvme_io_channel {
|
||||||
struct spdk_nvme_qpair *qpair;
|
struct spdk_nvme_qpair *qpair;
|
||||||
struct spdk_bdev_poller *poller;
|
struct spdk_bdev_poller *poller;
|
||||||
|
|
||||||
|
bool collect_spin_stat;
|
||||||
|
uint64_t spin_ticks;
|
||||||
|
uint64_t start_ticks;
|
||||||
|
uint64_t end_ticks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NVME_DEFAULT_MAX_UNMAP_BDESC_COUNT 1
|
#define NVME_DEFAULT_MAX_UNMAP_BDESC_COUNT 1
|
||||||
@ -186,9 +191,28 @@ static void
|
|||||||
bdev_nvme_poll(void *arg)
|
bdev_nvme_poll(void *arg)
|
||||||
{
|
{
|
||||||
struct nvme_io_channel *ch = arg;
|
struct nvme_io_channel *ch = arg;
|
||||||
|
int32_t num_completions;
|
||||||
|
|
||||||
if (ch->qpair != NULL) {
|
if (ch->qpair == NULL) {
|
||||||
spdk_nvme_qpair_process_completions(ch->qpair, 0);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch->collect_spin_stat && ch->start_ticks == 0) {
|
||||||
|
ch->start_ticks = spdk_get_ticks();
|
||||||
|
}
|
||||||
|
|
||||||
|
num_completions = spdk_nvme_qpair_process_completions(ch->qpair, 0);
|
||||||
|
|
||||||
|
if (ch->collect_spin_stat) {
|
||||||
|
if (num_completions > 0) {
|
||||||
|
if (ch->end_ticks != 0) {
|
||||||
|
ch->spin_ticks += (ch->end_ticks - ch->start_ticks);
|
||||||
|
ch->end_ticks = 0;
|
||||||
|
}
|
||||||
|
ch->start_ticks = 0;
|
||||||
|
} else {
|
||||||
|
ch->end_ticks = spdk_get_ticks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +447,12 @@ bdev_nvme_create_cb(void *io_device, void *ctx_buf)
|
|||||||
struct spdk_nvme_ctrlr *ctrlr = io_device;
|
struct spdk_nvme_ctrlr *ctrlr = io_device;
|
||||||
struct nvme_io_channel *ch = ctx_buf;
|
struct nvme_io_channel *ch = ctx_buf;
|
||||||
|
|
||||||
|
#ifdef SPDK_CONFIG_VTUNE
|
||||||
|
ch->collect_spin_stat = true;
|
||||||
|
#else
|
||||||
|
ch->collect_spin_stat = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
ch->qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, 0);
|
ch->qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, 0);
|
||||||
|
|
||||||
if (ch->qpair == NULL) {
|
if (ch->qpair == NULL) {
|
||||||
@ -585,12 +615,35 @@ bdev_nvme_dump_config_json(void *ctx, struct spdk_json_write_ctx *w)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t
|
||||||
|
bdev_nvme_get_spin_time(struct spdk_io_channel *ch)
|
||||||
|
{
|
||||||
|
struct nvme_io_channel *nvme_ch = spdk_io_channel_get_ctx(ch);
|
||||||
|
uint64_t spin_time;
|
||||||
|
|
||||||
|
if (!nvme_ch->collect_spin_stat) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nvme_ch->end_ticks != 0) {
|
||||||
|
nvme_ch->spin_ticks += (nvme_ch->end_ticks - nvme_ch->start_ticks);
|
||||||
|
nvme_ch->end_ticks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_time = (nvme_ch->spin_ticks * 1000000ULL) / spdk_get_ticks_hz();
|
||||||
|
nvme_ch->start_ticks = 0;
|
||||||
|
nvme_ch->spin_ticks = 0;
|
||||||
|
|
||||||
|
return spin_time;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct spdk_bdev_fn_table nvmelib_fn_table = {
|
static const struct spdk_bdev_fn_table nvmelib_fn_table = {
|
||||||
.destruct = bdev_nvme_destruct,
|
.destruct = bdev_nvme_destruct,
|
||||||
.submit_request = bdev_nvme_submit_request,
|
.submit_request = bdev_nvme_submit_request,
|
||||||
.io_type_supported = bdev_nvme_io_type_supported,
|
.io_type_supported = bdev_nvme_io_type_supported,
|
||||||
.get_io_channel = bdev_nvme_get_io_channel,
|
.get_io_channel = bdev_nvme_get_io_channel,
|
||||||
.dump_config_json = bdev_nvme_dump_config_json,
|
.dump_config_json = bdev_nvme_dump_config_json,
|
||||||
|
.get_spin_time = bdev_nvme_get_spin_time,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
Loading…
Reference in New Issue
Block a user