accel: collect statistics

This patch adds support for collecting statistics in accel framework.
Currently, it counts the following events:
 1. The number and the type of executed/failed operations.
 2. The number of executed/failed accel sequences.

For now, these statistics are only collected and there's no way of
retrieving (or resetting) them - that will be added in the following
patches.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id211067eb810e7b7d30c756a01b35eb5019c57e7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17190
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Konrad Sztyber 2023-02-27 15:41:26 +01:00 committed by Jim Harris
parent f61e421b05
commit f135f5ff7f
3 changed files with 36 additions and 3 deletions

View File

@ -138,6 +138,7 @@ struct accel_io_channel {
TAILQ_HEAD(, spdk_accel_sequence) seq_pool;
TAILQ_HEAD(, accel_buffer) buf_pool;
struct spdk_iobuf_channel iobuf;
struct accel_stats stats;
};
TAILQ_HEAD(accel_sequence_tasks, spdk_accel_task);
@ -155,6 +156,10 @@ struct spdk_accel_sequence {
TAILQ_ENTRY(spdk_accel_sequence) link;
};
#define accel_update_stats(ch, event) (ch)->stats.event++
#define accel_update_task_stats(ch, task, event) \
accel_update_stats(ch, operations[(task)->op_code].event)
static inline void
accel_sequence_set_state(struct spdk_accel_sequence *seq, enum accel_sequence_state state)
{
@ -257,6 +262,11 @@ spdk_accel_task_complete(struct spdk_accel_task *accel_task, int status)
*/
TAILQ_INSERT_HEAD(&accel_ch->task_pool, accel_task, link);
accel_update_task_stats(accel_ch, accel_task, executed);
if (spdk_unlikely(status != 0)) {
accel_update_task_stats(accel_ch, accel_task, failed);
}
cb_fn(cb_arg, status);
}
@ -288,8 +298,14 @@ accel_submit_task(struct accel_io_channel *accel_ch, struct spdk_accel_task *tas
{
struct spdk_io_channel *module_ch = accel_ch->module_ch[task->op_code];
struct spdk_accel_module_if *module = g_modules_opc[task->op_code].module;
int rc;
return module->submit_tasks(module_ch, task);
rc = module->submit_tasks(module_ch, task);
if (spdk_unlikely(rc != 0)) {
accel_update_task_stats(accel_ch, task, failed);
}
return rc;
}
/* Accel framework public API for copy function */
@ -1133,6 +1149,11 @@ accel_sequence_complete(struct spdk_accel_sequence *seq)
{
SPDK_DEBUGLOG(accel, "Completed sequence: %p with status: %d\n", seq, seq->status);
accel_update_stats(seq->ch, sequence_executed);
if (spdk_unlikely(seq->status != 0)) {
accel_update_stats(seq->ch, sequence_failed);
}
/* First notify all users that appended operations to this sequence */
accel_sequence_complete_tasks(seq);
@ -2134,6 +2155,7 @@ err:
free(accel_ch->task_pool_base);
free(accel_ch->seq_pool_base);
free(accel_ch->buf_pool_base);
return -ENOMEM;
}

View File

@ -20,6 +20,17 @@ struct module_info {
uint32_t num_ops;
};
struct accel_operation_stats {
uint64_t executed;
uint64_t failed;
};
struct accel_stats {
struct accel_operation_stats operations[ACCEL_OPC_LAST];
uint64_t sequence_executed;
uint64_t sequence_failed;
};
typedef void (*_accel_for_each_module_fn)(struct module_info *info);
void _accel_for_each_module(struct module_info *info, _accel_for_each_module_fn fn);
int _accel_get_opc_name(enum accel_opcode opcode, const char **opcode_name);