lib/trace: extract getting next entry to a helper function
It allows us to get rid of the `next_circual_entry` variable and will make it easier to retrieve multiple trace entries, which will be needed in subsequent patches. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I4666c9da518c2ac0b376e10aa73d1c58cff91f13 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8403 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
This commit is contained in:
parent
597688b2b1
commit
c681d76fb4
@ -45,6 +45,12 @@ static char g_shm_name[64];
|
||||
|
||||
struct spdk_trace_histories *g_trace_histories;
|
||||
|
||||
static inline struct spdk_trace_entry *
|
||||
get_trace_entry(struct spdk_trace_history *history, uint64_t offset)
|
||||
{
|
||||
return &history->entries[offset & (history->num_entries - 1)];
|
||||
}
|
||||
|
||||
void
|
||||
_spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
|
||||
uint64_t object_id, int num_args, ...)
|
||||
@ -54,7 +60,7 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
|
||||
struct spdk_trace_tpoint *tpoint;
|
||||
const char *strval;
|
||||
unsigned lcore, i, offset;
|
||||
uint64_t intval, next_circular_entry;
|
||||
uint64_t intval;
|
||||
va_list vl;
|
||||
|
||||
lcore = spdk_env_get_current_core();
|
||||
@ -70,8 +76,7 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
|
||||
lcore_history->tpoint_count[tpoint_id]++;
|
||||
|
||||
/* Get next entry index in the circular buffer */
|
||||
next_circular_entry = lcore_history->next_entry & (lcore_history->num_entries - 1);
|
||||
next_entry = &lcore_history->entries[next_circular_entry];
|
||||
next_entry = get_trace_entry(lcore_history, lcore_history->next_entry);
|
||||
next_entry->tsc = tsc;
|
||||
next_entry->tpoint_id = tpoint_id;
|
||||
next_entry->poller_id = poller_id;
|
||||
|
Loading…
Reference in New Issue
Block a user