Commit 3e735658 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I2cbb91e7d3311d95444d663f466d846676d2dcce

Reviewed-on: https://review.gerrithub.io/424276


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent ec571793
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -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.
+3 −13
Original line number Diff line number Diff line
@@ -40,10 +40,10 @@
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,
_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;
@@ -51,16 +51,6 @@ spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
	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;
+0 −6
Original line number Diff line number Diff line
@@ -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)
{
+0 −5
Original line number Diff line number Diff line
@@ -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)
{
+3 −2
Original line number Diff line number Diff line
@@ -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)
{
}