lib/thread: trace (get|put) IO channel calls

The traces record calls to spdk_(get|put)_io_channel() and saves the
reference count of the IO channel and its context.  The context, instead
of an IO channel pointer, was selected because the same pointer is often
used in other traces (e.g. nvmf's poll group), so it makes it possible
to match these traces together.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I15fe982a89685d8f6e23d406d6d48f5c2d9d604b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7232
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Konrad Sztyber 2021-04-02 11:49:21 +02:00 committed by Tomasz Zawadzki
parent db35950a13
commit 462eb754a2
2 changed files with 24 additions and 1 deletions

View File

@ -38,6 +38,7 @@
#include "spdk/queue.h"
#include "spdk/string.h"
#include "spdk/thread.h"
#include "spdk/trace.h"
#include "spdk/tree.h"
#include "spdk/util.h"
#include "spdk/fd_group.h"
@ -201,6 +202,22 @@ static uint32_t g_thread_count = 0;
static __thread struct spdk_thread *tls_thread = NULL;
#define TRACE_GROUP_THREAD 0xa
#define TRACE_THREAD_IOCH_GET SPDK_TPOINT_ID(TRACE_GROUP_THREAD, 0x0)
#define TRACE_THREAD_IOCH_PUT SPDK_TPOINT_ID(TRACE_GROUP_THREAD, 0x1)
SPDK_TRACE_REGISTER_FN(thread_trace, "thread", TRACE_GROUP_THREAD)
{
spdk_trace_register_description("THREAD_IOCH_GET",
TRACE_THREAD_IOCH_GET,
OWNER_NONE, OBJECT_NONE, 0,
SPDK_TRACE_ARG_TYPE_INT, "refcnt");
spdk_trace_register_description("THREAD_IOCH_PUT",
TRACE_THREAD_IOCH_PUT,
OWNER_NONE, OBJECT_NONE, 0,
SPDK_TRACE_ARG_TYPE_INT, "refcnt");
}
/*
* If this compare function returns zero when two next_run_ticks are equal,
* the macro RB_INSERT() returns a pointer to the element with the same
@ -2041,6 +2058,8 @@ spdk_get_io_channel(void *io_device)
* thread, so return it.
*/
pthread_mutex_unlock(&g_devlist_mutex);
spdk_trace_record(TRACE_THREAD_IOCH_GET, 0, 0,
(uint64_t)spdk_io_channel_get_ctx(ch), ch->ref);
return ch;
}
}
@ -2076,6 +2095,7 @@ spdk_get_io_channel(void *io_device)
return NULL;
}
spdk_trace_record(TRACE_THREAD_IOCH_GET, 0, 0, (uint64_t)spdk_io_channel_get_ctx(ch), 1);
return ch;
}
@ -2142,6 +2162,9 @@ spdk_put_io_channel(struct spdk_io_channel *ch)
struct spdk_thread *thread;
int rc __attribute__((unused));
spdk_trace_record(TRACE_THREAD_IOCH_PUT, 0, 0,
(uint64_t)spdk_io_channel_get_ctx(ch), ch->ref);
thread = spdk_get_thread();
if (!thread) {
SPDK_ERRLOG("called from non-SPDK thread\n");

View File

@ -59,7 +59,7 @@ DEPDIRS-conf := log util
DEPDIRS-json := log util
DEPDIRS-rdma := log util
DEPDIRS-reduce := log util
DEPDIRS-thread := log util
DEPDIRS-thread := log util trace
DEPDIRS-nvme := log sock util
ifeq ($(CONFIG_RDMA),y)