Commit 23dbcec5 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

trace: merge spdk_trace_flags into spdk_trace_file



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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 14e26b9d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,12 @@ Added `bdev_uring_rescan` RPC to allow rescaning the size of uring bdev.

Added `iscsi_get_stats` RPC method to get stat information about all active connections.

### trace

Merged `struct spdk_trace_flags` and `struct spdk_trace_histories` into
new `struct spdk_trace_file`. Also renamed `spdk_get_trace_histories_size()`
to `spdk_get_trace_file_size()`.

## v24.01

### accel
+19 −19
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ extern "C" {
}

static struct spdk_trace_parser *g_parser;
static const struct spdk_trace_flags *g_flags;
static const struct spdk_trace_file *g_file;
static struct spdk_json_write_ctx *g_json;
static bool g_print_tsc = false;

@@ -109,11 +109,11 @@ print_object_id(const struct spdk_trace_tpoint *d, struct spdk_trace_parser_entr

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

	snprintf(ids, sizeof(ids), "%c%jd%s", g_flags->object[d->object_type].id_prefix,
	snprintf(ids, sizeof(ids), "%c%jd%s", g_file->object[d->object_type].id_prefix,
		 entry->object_index, related_id);
	printf("id:    %-17s", ids);
}
@@ -132,16 +132,16 @@ print_event(struct spdk_trace_parser_entry *entry, uint64_t tsc_rate, uint64_t t
	float				us;
	size_t				i;

	d = &g_flags->tpoint[e->tpoint_id];
	d = &g_file->tpoint[e->tpoint_id];
	us = get_us_from_tsc(e->tsc - tsc_offset, tsc_rate);

	printf("%-*s ", (int)sizeof(g_flags->tname[entry->lcore]), g_flags->tname[entry->lcore]);
	printf("%-*s ", (int)sizeof(g_file->tname[entry->lcore]), g_file->tname[entry->lcore]);
	printf("%2d: %10.3f ", entry->lcore, us);
	if (g_print_tsc) {
		printf("(%9ju) ", e->tsc - tsc_offset);
	}
	if (g_flags->owner[d->owner_type].id_prefix) {
		printf("%c%02d ", g_flags->owner[d->owner_type].id_prefix, e->poller_id);
	if (g_file->owner[d->owner_type].id_prefix) {
		printf("%c%02d ", g_file->owner[d->owner_type].id_prefix, e->poller_id);
	} else {
		printf("%4s", " ");
	}
@@ -186,16 +186,16 @@ print_event_json(struct spdk_trace_parser_entry *entry, uint64_t tsc_rate, uint6
	const struct spdk_trace_tpoint *d;
	size_t i;

	d = &g_flags->tpoint[e->tpoint_id];
	d = &g_file->tpoint[e->tpoint_id];

	spdk_json_write_object_begin(g_json);
	spdk_json_write_named_uint64(g_json, "lcore", entry->lcore);
	spdk_json_write_named_uint64(g_json, "tpoint", e->tpoint_id);
	spdk_json_write_named_uint64(g_json, "tsc", e->tsc);

	if (g_flags->owner[d->owner_type].id_prefix) {
	if (g_file->owner[d->owner_type].id_prefix) {
		spdk_json_write_named_string_fmt(g_json, "poller", "%c%02d",
						 g_flags->owner[d->owner_type].id_prefix,
						 g_file->owner[d->owner_type].id_prefix,
						 e->poller_id);
	}
	if (e->size != 0) {
@@ -206,11 +206,11 @@ print_event_json(struct spdk_trace_parser_entry *entry, uint64_t tsc_rate, uint6

		spdk_json_write_named_object_begin(g_json, "object");
		if (d->new_object) {
			object_type =  g_flags->object[d->object_type].id_prefix;
			object_type =  g_file->object[d->object_type].id_prefix;
			spdk_json_write_named_string_fmt(g_json, "id", "%c%" PRIu64, object_type,
							 entry->object_index);
		} else if (d->object_type != OBJECT_NONE) {
			object_type =  g_flags->object[d->object_type].id_prefix;
			object_type =  g_file->object[d->object_type].id_prefix;
			if (entry->object_index != UINT64_MAX) {
				spdk_json_write_named_string_fmt(g_json, "id", "%c%" PRIu64,
								 object_type,
@@ -226,7 +226,7 @@ print_event_json(struct spdk_trace_parser_entry *entry, uint64_t tsc_rate, uint6
	/* Print related objects array */
	if (entry->related_index != UINT64_MAX) {
		spdk_json_write_named_string_fmt(g_json, "related", "%c%" PRIu64,
						 g_flags->object[entry->related_type].id_prefix,
						 g_file->object[entry->related_type].id_prefix,
						 entry->related_index);
	}

@@ -272,11 +272,11 @@ print_tpoint_definitions(void)
		return;
	}

	spdk_json_write_named_uint64(g_json, "tsc_rate", g_flags->tsc_rate);
	spdk_json_write_named_uint64(g_json, "tsc_rate", g_file->tsc_rate);
	spdk_json_write_named_array_begin(g_json, "tpoints");

	for (i = 0; i < SPDK_COUNTOF(g_flags->tpoint); ++i) {
		tpoint = &g_flags->tpoint[i];
	for (i = 0; i < SPDK_COUNTOF(g_file->tpoint); ++i) {
		tpoint = &g_file->tpoint[i];
		if (tpoint->tpoint_id == 0) {
			continue;
		}
@@ -425,9 +425,9 @@ main(int argc, char **argv)
		exit(1);
	}

	g_flags = spdk_trace_parser_get_flags(g_parser);
	g_file = spdk_trace_parser_get_file(g_parser);
	if (!g_json) {
		printf("TSC Rate: %ju\n", g_flags->tsc_rate);
		printf("TSC Rate: %ju\n", g_file->tsc_rate);
	} else {
		spdk_json_write_object_begin(g_json);
		print_tpoint_definitions();
@@ -448,7 +448,7 @@ main(int argc, char **argv)
		if (entry.entry->tsc < tsc_offset) {
			continue;
		}
		process_event(&entry, g_flags->tsc_rate, tsc_offset);
		process_event(&entry, g_file->tsc_rate, tsc_offset);
	}

	if (g_json != NULL) {
+2 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ input_trace_file_mmap(struct aggr_trace_record_ctx *ctx, const char *shm_name)

	ctx->trace_file = (struct spdk_trace_file *)history_ptr;

	g_tsc_rate = ctx->trace_file->flags.tsc_rate;
	g_tsc_rate = ctx->trace_file->tsc_rate;
	g_utsc_rate = g_tsc_rate / 1000;
	if (g_tsc_rate == 0) {
		fprintf(stderr, "Invalid tsc_rate %ju\n", g_tsc_rate);
@@ -463,7 +463,7 @@ trace_files_aggregate(struct aggr_trace_record_ctx *ctx)
	}

	/* Update and append lcore offsets converged trace file */
	current_offset = sizeof(struct spdk_trace_flags);
	current_offset = sizeof(struct spdk_trace_file);
	for (i = 0; i < SPDK_TRACE_MAX_LCORE; i++) {
		lcore_port = &ctx->lcore_ports[i];
		if (lcore_port->valid) {
+5 −11
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ struct spdk_trace_history {

#define SPDK_TRACE_MAX_LCORE		128

struct spdk_trace_flags {
struct spdk_trace_file {
	uint64_t			tsc_rate;
	uint64_t			tpoint_mask[SPDK_TRACE_MAX_GROUP_ID];
	char				tname[SPDK_TRACE_MAX_LCORE][SPDK_TRACE_THREAD_NAME_LEN];
@@ -127,13 +127,6 @@ struct spdk_trace_flags {
	 * The last one is the offset of the file end.
	 */
	uint64_t			lcore_history_offsets[SPDK_TRACE_MAX_LCORE + 1];
};
extern struct spdk_trace_flags *g_trace_flags;
extern struct spdk_trace_file *g_trace_file;


struct spdk_trace_file {
	struct spdk_trace_flags flags;

	/**
	 * struct spdk_trace_history has a dynamic size determined by num_entries
@@ -143,6 +136,7 @@ struct spdk_trace_file {
	 */
	uint8_t	per_lcore_history[0];
};
extern struct spdk_trace_file *g_trace_file;

static inline uint64_t
spdk_get_trace_history_size(uint64_t num_entries)
@@ -153,7 +147,7 @@ spdk_get_trace_history_size(uint64_t num_entries)
static inline uint64_t
spdk_get_trace_file_size(struct spdk_trace_file *trace_file)
{
	return trace_file->flags.lcore_history_offsets[SPDK_TRACE_MAX_LCORE];
	return trace_file->lcore_history_offsets[SPDK_TRACE_MAX_LCORE];
}

static inline struct spdk_trace_history *
@@ -165,7 +159,7 @@ spdk_get_per_lcore_history(struct spdk_trace_file *trace_file, unsigned lcore)
		return NULL;
	}

	lcore_history_offset = trace_file->flags.lcore_history_offsets[lcore];
	lcore_history_offset = trace_file->lcore_history_offsets[lcore];
	if (lcore_history_offset == 0) {
		return NULL;
	}
@@ -181,7 +175,7 @@ void _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id,
		assert(tpoint_id < SPDK_TRACE_MAX_TPOINT_ID);					\
		if (g_trace_file == NULL ||						\
		    !((1ULL << (tpoint_id & 0x3F)) &						\
		      g_trace_file->flags.tpoint_mask[tpoint_id >> 6])) {			\
		      g_trace_file->tpoint_mask[tpoint_id >> 6])) {			\
			break;									\
		}										\
		_spdk_trace_record(tsc, tpoint_id, poller_id, size, object_id,			\
+3 −3
Original line number Diff line number Diff line
@@ -56,13 +56,13 @@ struct spdk_trace_parser *spdk_trace_parser_init(const struct spdk_trace_parser_
void spdk_trace_parser_cleanup(struct spdk_trace_parser *parser);

/**
 * Return trace flags describing the traces.
 * Return trace file describing the traces.
 *
 * \param parser Parser object to be used.
 *
 * \return Pointer to the trace flags.
 * \return Pointer to the trace file.
 */
const struct spdk_trace_flags *spdk_trace_parser_get_flags(const struct spdk_trace_parser *parser);
const struct spdk_trace_file *spdk_trace_parser_get_file(const struct spdk_trace_parser *parser);

/**
 * Return the highest tsc out of first entries across all specified cores.  This value can be used
Loading