bdev: support to get histogram per channel
Added new API 'spdk_bdev_histogram_get_channel' to get histogram of a specified channel for a bdev. A callback function is passed to it to process the histogram. Change-Id: If5d56cbb5fe6c39cda7882f887dcc9c6afa769ac Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15539 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
1091ed8269
commit
f192c11bbf
@ -33,6 +33,9 @@ running `bdev_nvme_set_options` RPC with `--generate-uuids` option. These identi
|
||||
are based on serial number and namespace ID and will always be the same for a given
|
||||
device.
|
||||
|
||||
A new API `spdk_bdev_channel_get_histogram` was added to get the histogram of a specified
|
||||
channel for a bdev.
|
||||
|
||||
### event
|
||||
|
||||
Added core lock file mechanism to prevent the same CPU cores from being used by multiple
|
||||
|
@ -1938,6 +1938,19 @@ void spdk_bdev_histogram_get(struct spdk_bdev *bdev, struct spdk_histogram_data
|
||||
spdk_bdev_histogram_data_cb cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
/**
|
||||
* Get histogram data of the specified channel for a bdev. The histogram passed to cb_fn
|
||||
* is only valid during the execution of cb_fn. Referencing the histogram after cb_fn
|
||||
* returns is not supported and yields undetermined behavior.
|
||||
*
|
||||
* \param bdev Block device.
|
||||
* \param ch IO channel of bdev.
|
||||
* \param cb_fn Callback function to process the histogram of the channel.
|
||||
* \param cb_arg Argument to pass to cb_fn.
|
||||
*/
|
||||
void spdk_bdev_channel_get_histogram(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||
spdk_bdev_histogram_data_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Retrieves media events. Can only be called from the context of
|
||||
* SPDK_BDEV_EVENT_MEDIA_MANAGEMENT event callback. These events are sent by
|
||||
|
@ -7634,6 +7634,21 @@ spdk_bdev_histogram_get(struct spdk_bdev *bdev, struct spdk_histogram_data *hist
|
||||
bdev_histogram_get_channel_cb);
|
||||
}
|
||||
|
||||
void
|
||||
spdk_bdev_channel_get_histogram(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||
spdk_bdev_histogram_data_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_bdev_channel *bdev_ch = __io_ch_to_bdev_ch(ch);
|
||||
int status = 0;
|
||||
|
||||
assert(cb_fn != NULL);
|
||||
|
||||
if (bdev_ch->histogram == NULL) {
|
||||
status = -EFAULT;
|
||||
}
|
||||
cb_fn(cb_arg, status, bdev_ch->histogram);
|
||||
}
|
||||
|
||||
size_t
|
||||
spdk_bdev_get_media_events(struct spdk_bdev_desc *desc, struct spdk_bdev_media_event *events,
|
||||
size_t max_events)
|
||||
|
@ -99,6 +99,7 @@
|
||||
spdk_bdev_io_get_seek_offset;
|
||||
spdk_bdev_histogram_enable;
|
||||
spdk_bdev_histogram_get;
|
||||
spdk_bdev_channel_get_histogram;
|
||||
spdk_bdev_get_media_events;
|
||||
spdk_bdev_get_memory_domains;
|
||||
spdk_bdev_readv_blocks_ext;
|
||||
|
@ -3423,6 +3423,18 @@ histogram_io_count(void *ctx, uint64_t start, uint64_t end, uint64_t count,
|
||||
g_count += count;
|
||||
}
|
||||
|
||||
static void
|
||||
histogram_channel_data_cb(void *cb_arg, int status, struct spdk_histogram_data *histogram)
|
||||
{
|
||||
spdk_histogram_data_fn cb_fn = cb_arg;
|
||||
|
||||
g_status = status;
|
||||
|
||||
if (status == 0) {
|
||||
spdk_histogram_data_iterate(histogram, cb_fn, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_histograms(void)
|
||||
{
|
||||
@ -3493,6 +3505,11 @@ bdev_histograms(void)
|
||||
spdk_histogram_data_iterate(g_histogram, histogram_io_count, NULL);
|
||||
CU_ASSERT(g_count == 2);
|
||||
|
||||
g_count = 0;
|
||||
spdk_bdev_channel_get_histogram(bdev, ch, histogram_channel_data_cb, histogram_io_count);
|
||||
CU_ASSERT(g_status == 0);
|
||||
CU_ASSERT(g_count == 2);
|
||||
|
||||
/* Disable histogram */
|
||||
spdk_bdev_histogram_enable(bdev, histogram_status_cb, NULL, false);
|
||||
poll_threads();
|
||||
@ -3504,6 +3521,9 @@ bdev_histograms(void)
|
||||
poll_threads();
|
||||
CU_ASSERT(g_status == -EFAULT);
|
||||
|
||||
spdk_bdev_channel_get_histogram(bdev, ch, histogram_channel_data_cb, NULL);
|
||||
CU_ASSERT(g_status == -EFAULT);
|
||||
|
||||
spdk_histogram_data_free(histogram);
|
||||
spdk_put_io_channel(ch);
|
||||
spdk_bdev_close(desc);
|
||||
|
Loading…
Reference in New Issue
Block a user