Commit d1ec8ae9 authored by Jim Harris's avatar Jim Harris
Browse files

trace: add spdk_trace_tpoint_enabled()



This macro allows callers to restrict any extra prep code from executing when
its associate tpoint is not enabled.

This can be useful for certain tracepoints that need to calculate some value for
the trace point - for example, add up the lengths of an iov array. We will
use it for exactly that reason in an upcoming patch.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: If1c3f1a6801aeb62ae4bcb763838d6101464dab9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22098


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent dd1939d8
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -169,12 +169,14 @@ spdk_get_per_lcore_history(struct spdk_trace_file *trace_file, unsigned lcore)
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, ...);

#define spdk_trace_tpoint_enabled(tpoint_id)	\
	(g_trace_file != NULL  && \
	((1ULL << (tpoint_id & 0x3F)) &	g_trace_file->tpoint_mask[tpoint_id >> 6]))

#define _spdk_trace_record_tsc(tsc, tpoint_id, poller_id, size, object_id, num_args, ...)	\
	do {											\
		assert(tpoint_id < SPDK_TRACE_MAX_TPOINT_ID);					\
		if (g_trace_file == NULL ||						\
		    !((1ULL << (tpoint_id & 0x3F)) &						\
		      g_trace_file->tpoint_mask[tpoint_id >> 6])) {			\
		if (!spdk_trace_tpoint_enabled(tpoint_id)) {					\
			break;									\
		}										\
		_spdk_trace_record(tsc, tpoint_id, poller_id, size, object_id,			\