trace: add spdk_trace_record_tsc
This is a variant of spdk_trace_record which takes a tsc parameter. This allows callers who already have the current tsc to pass it in as a parameter, saving an extra rdtsc in the trace library. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I074f4f9fdbe649ad6717f932982a574bc61f2997 Reviewed-on: https://review.gerrithub.io/424277 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:
parent
3e7356580b
commit
8dfd945b64
@ -130,13 +130,14 @@ struct spdk_trace_histories {
|
|||||||
struct spdk_trace_history per_lcore_history[SPDK_TRACE_MAX_LCORE];
|
struct spdk_trace_history per_lcore_history[SPDK_TRACE_MAX_LCORE];
|
||||||
};
|
};
|
||||||
|
|
||||||
void _spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id,
|
void _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
|
||||||
uint32_t size, uint64_t object_id, uint64_t arg1);
|
uint32_t size, uint64_t object_id, uint64_t arg1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record the current trace state for tracing tpoints. Debug tool can read the
|
* 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
|
* information from shared memory to post-process the tpoint entries and display
|
||||||
* in a human-readable format.
|
* in a human-readable format. This function will call spdk_get_ticks() to get
|
||||||
|
* the current tsc to save in the tracepoint.
|
||||||
*
|
*
|
||||||
* \param tpoint_id Tracepoint id to record.
|
* \param tpoint_id Tracepoint id to record.
|
||||||
* \param poller_id Poller id to record.
|
* \param poller_id Poller id to record.
|
||||||
@ -158,7 +159,36 @@ void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_spdk_trace_record(tpoint_id, poller_id, size, object_id, arg1);
|
_spdk_trace_record(0, tpoint_id, poller_id, size, object_id, 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
|
||||||
|
* in a human-readable format.
|
||||||
|
*
|
||||||
|
* \param tsc Current tsc.
|
||||||
|
* \param tpoint_id Tracepoint id to record.
|
||||||
|
* \param poller_id Poller id to record.
|
||||||
|
* \param size Size to record.
|
||||||
|
* \param object_id Object id to record.
|
||||||
|
* \param arg1 Argument to record.
|
||||||
|
*/
|
||||||
|
static inline
|
||||||
|
void spdk_trace_record_tsc(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
|
||||||
|
uint32_t size, 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(tsc, tpoint_id, poller_id, size, object_id, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,12 +43,11 @@ static char g_shm_name[64];
|
|||||||
struct spdk_trace_histories *g_trace_histories;
|
struct spdk_trace_histories *g_trace_histories;
|
||||||
|
|
||||||
void
|
void
|
||||||
_spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
_spdk_trace_record(uint64_t tsc, 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)
|
||||||
{
|
{
|
||||||
struct spdk_trace_history *lcore_history;
|
struct spdk_trace_history *lcore_history;
|
||||||
struct spdk_trace_entry *next_entry;
|
struct spdk_trace_entry *next_entry;
|
||||||
uint64_t tsc;
|
|
||||||
unsigned lcore;
|
unsigned lcore;
|
||||||
|
|
||||||
lcore = spdk_env_get_current_core();
|
lcore = spdk_env_get_current_core();
|
||||||
@ -57,7 +56,9 @@ _spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lcore_history = &g_trace_histories->per_lcore_history[lcore];
|
lcore_history = &g_trace_histories->per_lcore_history[lcore];
|
||||||
tsc = spdk_get_ticks();
|
if (tsc == 0) {
|
||||||
|
tsc = spdk_get_ticks();
|
||||||
|
}
|
||||||
|
|
||||||
lcore_history->tpoint_count[tpoint_id]++;
|
lcore_history->tpoint_count[tpoint_id]++;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_thread_fn fn, void *
|
|||||||
}
|
}
|
||||||
|
|
||||||
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,
|
void _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
|
||||||
uint32_t size, uint64_t object_id, uint64_t arg1)
|
uint32_t size, uint64_t object_id, uint64_t arg1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user