Commit c681d76f authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

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: default avatarKonrad 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
parent 597688b2
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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;