Commit ae5e1aaf authored by Krishna Kanth Reddy's avatar Krishna Kanth Reddy Committed by Tomasz Zawadzki
Browse files

lib/trace : Enable tracing support for user created threads



Only the environment created threads have the tracing support.
Added tracing support for the user created threads by reserving
lcore_history entries.

fio_plugin is modified to verify the tracing support for the user
created threads.

This allows all SPDK applications to use SPDK tracing,
even if they are not using the SPDK app framework.

Change-Id: Ib7831b30d7de420fcc4a5849f3757733755a5406
Signed-off-by: default avatarKrishna Kanth Reddy <krish.reddy@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20852


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 82c64b67
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,13 @@

## v24.01: (Upcoming Release)

### trace

Added `spdk_trace_register_user_thread` to initialize trace environment
for an user created thread.

Modified `spdk_trace_init` to take number of user created threads as a parameter.

### vhost

Added `caw_iov` field to struct `spdk_scsi_task` to support SBC-3 compare_and_write IO.
+32 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "spdk/endian.h"
#include "spdk/dif.h"
#include "spdk/util.h"
#include "spdk/trace.h"

#include "config-host.h"
#include "fio.h"
@@ -71,6 +72,7 @@ struct spdk_fio_options {
	int	initial_zone_reset;
	int	zone_append;
	int	print_qid_mappings;
	int	spdk_tracing;
	char	*log_flags;
};

@@ -503,6 +505,19 @@ fio_redirected_to_dev_null(void)
	return true;
}

static int
spdk_fio_init(struct thread_data *td)
{
	int ret = 0;
	struct spdk_fio_options *fio_options = td->eo;

	if (fio_options->spdk_tracing) {
		ret = spdk_trace_register_user_thread();
	}

	return ret;
}

/* Called once at initialization. This is responsible for gathering the size of
 * each "file", which in our case are in the form
 * 'key=value [key=value] ... ns=value'
@@ -604,6 +619,12 @@ spdk_fio_setup(struct thread_data *td)
		g_spdk_env_initialized = true;
		spdk_unaffinitize_thread();

		if (fio_options->spdk_tracing) {
			spdk_trace_init("spdk_fio_tracepoints", 65536, td->o.numjobs);
			spdk_trace_enable_tpoint_group("nvme_pcie");
			spdk_trace_enable_tpoint_group("nvme_tcp");
		}

		/* Spawn a thread to continue polling the controllers */
		rc = pthread_create(&g_ctrlr_thread_id, NULL, &spdk_fio_poll_ctrlrs, NULL);
		if (rc != 0) {
@@ -1785,6 +1806,16 @@ static struct fio_option options[] = {
		.category	= FIO_OPT_C_ENGINE,
		.group		= FIO_OPT_G_INVALID,
	},
	{
		.name		= "spdk_tracing",
		.lname		= "Enable SPDK Tracing",
		.type		= FIO_OPT_INT,
		.off1		= offsetof(struct spdk_fio_options, spdk_tracing),
		.def		= "0",
		.help		= "SPDK Tracing (0=disable, 1=enable)",
		.category	= FIO_OPT_C_ENGINE,
		.group		= FIO_OPT_G_INVALID,
	},
	{
		.name		= NULL,
	},
@@ -1804,6 +1835,7 @@ struct ioengine_ops ioengine = {
	.iomem_alloc		= spdk_fio_iomem_alloc,
	.iomem_free		= spdk_fio_iomem_free,
	.setup			= spdk_fio_setup,
	.init			= spdk_fio_init,
	.io_u_init		= spdk_fio_io_u_init,
	.io_u_free		= spdk_fio_io_u_free,
#if FIO_HAS_ZBD
+9 −1
Original line number Diff line number Diff line
@@ -279,9 +279,17 @@ void spdk_trace_clear_tpoint_group_mask(uint64_t tpoint_group_mask);
 *
 * \param shm_name Name of shared memory.
 * \param num_entries Number of trace entries per lcore.
 * \param num_threads Number of user created threads.
 * \return 0 on success, else non-zero indicates a failure.
 */
int spdk_trace_init(const char *shm_name, uint64_t num_entries);
int spdk_trace_init(const char *shm_name, uint64_t num_entries, uint32_t num_threads);

/**
 * Initialize trace environment for an user created thread.
 *
 * \return 0 on success, else non-zero indicates a failure.
 */
int spdk_trace_register_user_thread(void);

/**
 * Unmap global trace memory structs.
+1 −1
Original line number Diff line number Diff line
@@ -412,7 +412,7 @@ app_setup_trace(struct spdk_app_opts *opts)
		snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", opts->name, (int)getpid());
	}

	if (spdk_trace_init(shm_name, opts->num_entries) != 0) {
	if (spdk_trace_init(shm_name, opts->num_entries, 0) != 0) {
		return -1;
	}

+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 8
SO_VER := 9
SO_MINOR := 0

C_SRCS = trace.c trace_flags.c trace_rpc.c
Loading