trace: inline tpoint_mask checking

This reduces overhead of spdk_trace_record calls when
tracing is not enabled.

While here, remove a couple of unit test stubs for
spdk_trace_record that weren't needed anymore.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I2cbb91e7d3311d95444d663f466d846676d2dcce

Reviewed-on: https://review.gerrithub.io/424276
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2018-08-31 14:02:11 -07:00 committed by Ben Walker
parent ec571793d4
commit 3e7356580b
5 changed files with 25 additions and 27 deletions

View File

@ -122,6 +122,7 @@ struct spdk_trace_flags {
struct spdk_trace_tpoint tpoint[SPDK_TRACE_MAX_TPOINT_ID];
};
extern struct spdk_trace_flags *g_trace_flags;
extern struct spdk_trace_histories *g_trace_histories;
struct spdk_trace_histories {
@ -129,6 +130,9 @@ struct spdk_trace_histories {
struct spdk_trace_history per_lcore_history[SPDK_TRACE_MAX_LCORE];
};
void _spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id,
uint32_t size, uint64_t object_id, uint64_t arg1);
/**
* Record the current trace state for tracing tpoints. Debug tool can read the
* information from shared memory to post-process the tpoint entries and display
@ -140,8 +144,22 @@ struct spdk_trace_histories {
* \param object_id Object id to record.
* \param arg1 Argument to record.
*/
static inline
void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
uint64_t object_id, uint64_t arg1);
uint64_t object_id, uint64_t arg1)
{
/*
* Tracepoint group ID is encoded in the tpoint_id. Lower 6 bits determine the tracepoint
* within the group, the remaining upper bits determine the tracepoint group. Each
* tracepoint group has its own tracepoint mask.
*/
if (g_trace_histories == NULL ||
!((1ULL << (tpoint_id & 0x3F)) & g_trace_histories->flags.tpoint_mask[tpoint_id >> 6])) {
return;
}
_spdk_trace_record(tpoint_id, poller_id, size, object_id, arg1);
}
/**
* Get the current tpoint mask of the given tpoint group.

View File

@ -40,27 +40,17 @@
static int g_trace_fd = -1;
static char g_shm_name[64];
static struct spdk_trace_histories *g_trace_histories;
struct spdk_trace_histories *g_trace_histories;
void
spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
uint64_t object_id, uint64_t arg1)
_spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
uint64_t object_id, uint64_t arg1)
{
struct spdk_trace_history *lcore_history;
struct spdk_trace_entry *next_entry;
uint64_t tsc;
unsigned lcore;
/*
* Tracepoint group ID is encoded in the tpoint_id. Lower 6 bits determine the tracepoint
* within the group, the remaining upper bits determine the tracepoint group. Each
* tracepoint group has its own tracepoint mask.
*/
if (g_trace_histories == NULL ||
!((1ULL << (tpoint_id & 0x3F)) & g_trace_histories->flags.tpoint_mask[tpoint_id >> 6])) {
return;
}
lcore = spdk_env_get_current_core();
if (lcore >= SPDK_TRACE_MAX_LCORE) {
return;

View File

@ -95,12 +95,6 @@ spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
return 0;
}
void
spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size, uint64_t object_id,
uint64_t arg1)
{
}
bool
spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type)
{

View File

@ -39,11 +39,6 @@
SPDK_LOG_REGISTER_COMPONENT("nvmf", SPDK_LOG_NVMF)
void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
uint64_t object_id, uint64_t arg1)
{
}
int
spdk_nvmf_transport_req_free(struct spdk_nvmf_request *req)
{

View File

@ -71,8 +71,9 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_thread_fn fn, void *
{
}
void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
uint64_t object_id, uint64_t arg1)
struct spdk_trace_histories *g_trace_histories;
void _spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id,
uint32_t size, uint64_t object_id, uint64_t arg1)
{
}