Commit 70c17160 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Jim Harris
Browse files

trace: enable adding relations between traces



Currently we do not have any way to connect traces from different
modules in SPDK. This change modifies our trace library
and app/trace to handle adding relations between trace points
and a trace object.

Additionally this patch adds classes and fields to structs
inside trace.py to prepare it for future patches implementing
printing relation information.

Change-Id: Ia09d01244d923957d589fd37e6d4c98f9f7bbd07
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9620


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@gmail.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
parent 84ab68c1
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -123,9 +123,21 @@ print_size(uint32_t size)
}

static void
print_object_id(uint8_t type, uint64_t id)
print_object_id(const struct spdk_trace_tpoint *d, struct spdk_trace_parser_entry *entry)
{
	printf("id:    %c%-15jd ", g_flags->object[type].id_prefix, id);
	/* Set size to 128 and 256 bytes to make sure we can fit all the characters we need */
	char related_id[128] = {'\0'};
	char ids[256] = {'\0'};

	if (entry->related_type != OBJECT_NONE) {
		snprintf(related_id, sizeof(related_id), " (%c%jd)",
			 g_flags->object[entry->related_type].id_prefix,
			 entry->related_index);
	}

	snprintf(ids, sizeof(ids), "%c%jd%s", g_flags->object[d->object_type].id_prefix,
		 entry->object_index, related_id);
	printf("id:    %-17s", ids);
}

static void
@@ -159,11 +171,11 @@ print_event(struct spdk_trace_parser_entry *entry, uint64_t tsc_rate, uint64_t t
	print_size(e->size);

	if (d->new_object) {
		print_object_id(d->object_type, entry->object_index);
		print_object_id(d, entry);
	} else if (d->object_type != OBJECT_NONE) {
		if (entry->object_index != UINT64_MAX) {
			us = get_us_from_tsc(e->tsc - entry->object_start, tsc_rate);
			print_object_id(d->object_type, entry->object_index);
			print_object_id(d, entry);
			print_float("time", us);
		} else {
			printf("id:    N/A");
+17 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ struct spdk_trace_object {
#define SPDK_TRACE_ARG_TYPE_STR 2

#define SPDK_TRACE_MAX_ARGS_COUNT 5
#define SPDK_TRACE_MAX_RELATIONS 16

struct spdk_trace_argument {
	char	name[14];
@@ -106,6 +107,11 @@ struct spdk_trace_tpoint {
	uint8_t				new_object;
	uint8_t				num_args;
	struct spdk_trace_argument	args[SPDK_TRACE_MAX_ARGS_COUNT];
	/** Relations between tracepoint and trace object */
	struct {
		uint8_t object_type;
		uint8_t arg_index;
	} related_objects[SPDK_TRACE_MAX_RELATIONS];
};

struct spdk_trace_history {
@@ -375,6 +381,17 @@ struct spdk_trace_register_fn *spdk_trace_get_first_register_fn(void);
struct spdk_trace_register_fn *spdk_trace_get_next_register_fn(struct spdk_trace_register_fn
		*register_fn);

/**
 * Bind trace type to a given trace object. This allows for matching traces
 * with the same parent trace object.
 *
 * \param tpoint_id Type of trace to be bound
 * \param object_type Tracepoint object type to bind to
 * \param arg_index Index of argument containing context information
 */
void spdk_trace_tpoint_register_relation(uint16_t tpoint_id, uint8_t object_type,
		uint8_t arg_index);

/**
 * Enable trace on specific tpoint group
 *
+4 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ struct spdk_trace_parser_entry {
	uint64_t		object_start;
	/** Logical core number */
	uint16_t		lcore;
	/** Related object index */
	uint64_t		related_index;
	/** Related object type */
	uint8_t			related_type;
	/** Tracepoint arguments */
	union {
		uint64_t	integer;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 4
SO_VER := 5
SO_MINOR := 0

C_SRCS = trace.c trace_flags.c trace_rpc.c
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
	spdk_trace_disable_tpoint_group;
	spdk_trace_mask_usage;
	spdk_trace_add_register_fn;
	spdk_trace_tpoint_register_relation;

	# public variables
	g_trace_histories;
Loading