Commit f2061706 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdevperf: Hold associated core ID in struct io_target_group



Hold associated core ID in io_target_group and use it later.
This simplifies event calls in bdevperf because we don't need
to get core ID from io_target.

The next patch will delete g_coremap safely because io_target_group
manages lcore correctly now. lcore of the struct io_target will
be deleted too but it will be more later.

The subsequent patches will move bdevperf from core based to
thread based and the added core ID will be removed eventually in
this patch series. However these changes are helpful even so.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ia763a79bc3810a15485285aebb9fc15a8d48332f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478705


Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent bc08958b
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ struct io_target {

struct io_target_group {
	TAILQ_HEAD(, io_target)		targets;
	uint32_t			lcore;
};

struct io_target_group *g_head;
@@ -248,7 +249,9 @@ blockdev_heads_init(void)
	}

	SPDK_ENV_FOREACH_CORE(i) {
		g_coremap[idx++] = i;
		g_coremap[idx] = i;
		g_head[idx].lcore = i;
		idx++;
	}

	return 0;
@@ -388,7 +391,7 @@ bdevperf_construct_target(struct spdk_bdev *bdev)

	/* Mapping each created target to lcore */
	index = g_target_count % spdk_env_get_core_count();
	target->lcore = g_coremap[index];
	target->lcore = g_head[index].lcore;
	target->group = &g_head[index];
	TAILQ_INSERT_HEAD(&g_head[index].targets, target, link);
	g_target_count++;
@@ -1006,9 +1009,8 @@ performance_dump(uint64_t io_time_in_usec, uint64_t ema_period)
	total_io_per_second = 0;
	total_mb_per_second = 0;
	for (index = 0; index < spdk_env_get_core_count(); index++) {
		target = TAILQ_FIRST(&g_head[index].targets);
		if (target != NULL) {
			lcore_id = target->lcore;
		if (!TAILQ_EMPTY(&g_head[index].targets)) {
			lcore_id = g_head[index].lcore;
			printf("\r Logical core: %u\n", lcore_id);
		}
		TAILQ_FOREACH(target, &g_head[index].targets, link) {
@@ -1260,7 +1262,6 @@ static int
bdevperf_test(void)
{
	uint32_t i;
	struct io_target *target;
	struct spdk_event *event;
	int rc;
	uint32_t core_count = spdk_min(g_target_count, spdk_env_get_core_count());
@@ -1282,9 +1283,8 @@ bdevperf_test(void)

	/* Send events to start all I/O */
	for (i = 0; i < core_count; i++) {
		target = TAILQ_FIRST(&g_head[i].targets);
		if (target != NULL) {
			event = spdk_event_allocate(target->lcore, bdevperf_submit_on_core,
		if (!TAILQ_EMPTY(&g_head[i].targets)) {
			event = spdk_event_allocate(g_head[i].lcore, bdevperf_submit_on_core,
						    &g_head[i], NULL);
			spdk_event_call(event);
		}
@@ -1341,7 +1341,6 @@ static void
spdk_bdevperf_shutdown_cb(void)
{
	uint32_t i;
	struct io_target *target;
	struct spdk_event *event;

	g_shutdown = true;
@@ -1360,9 +1359,8 @@ spdk_bdevperf_shutdown_cb(void)

	/* Send events to stop all I/O on each core */
	for (i = 0; i < spdk_env_get_core_count(); i++) {
		target = TAILQ_FIRST(&g_head[i].targets);
		if (target != NULL) {
			event = spdk_event_allocate(target->lcore, bdevperf_stop_io_on_core,
		if (!TAILQ_EMPTY(&g_head[i].targets)) {
			event = spdk_event_allocate(g_head[i].lcore, bdevperf_stop_io_on_core,
						    &g_head[i], NULL);
			spdk_event_call(event);
		}