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: Shuhei 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: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-01-01 16:20:44 -05:00 committed by Tomasz Zawadzki
parent bc08958b6a
commit f20617066e

View File

@ -116,6 +116,7 @@ struct io_target {
struct io_target_group { struct io_target_group {
TAILQ_HEAD(, io_target) targets; TAILQ_HEAD(, io_target) targets;
uint32_t lcore;
}; };
struct io_target_group *g_head; struct io_target_group *g_head;
@ -248,7 +249,9 @@ blockdev_heads_init(void)
} }
SPDK_ENV_FOREACH_CORE(i) { SPDK_ENV_FOREACH_CORE(i) {
g_coremap[idx++] = i; g_coremap[idx] = i;
g_head[idx].lcore = i;
idx++;
} }
return 0; return 0;
@ -388,7 +391,7 @@ bdevperf_construct_target(struct spdk_bdev *bdev)
/* Mapping each created target to lcore */ /* Mapping each created target to lcore */
index = g_target_count % spdk_env_get_core_count(); 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]; target->group = &g_head[index];
TAILQ_INSERT_HEAD(&g_head[index].targets, target, link); TAILQ_INSERT_HEAD(&g_head[index].targets, target, link);
g_target_count++; 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_io_per_second = 0;
total_mb_per_second = 0; total_mb_per_second = 0;
for (index = 0; index < spdk_env_get_core_count(); index++) { for (index = 0; index < spdk_env_get_core_count(); index++) {
target = TAILQ_FIRST(&g_head[index].targets); if (!TAILQ_EMPTY(&g_head[index].targets)) {
if (target != NULL) { lcore_id = g_head[index].lcore;
lcore_id = target->lcore;
printf("\r Logical core: %u\n", lcore_id); printf("\r Logical core: %u\n", lcore_id);
} }
TAILQ_FOREACH(target, &g_head[index].targets, link) { TAILQ_FOREACH(target, &g_head[index].targets, link) {
@ -1260,7 +1262,6 @@ static int
bdevperf_test(void) bdevperf_test(void)
{ {
uint32_t i; uint32_t i;
struct io_target *target;
struct spdk_event *event; struct spdk_event *event;
int rc; int rc;
uint32_t core_count = spdk_min(g_target_count, spdk_env_get_core_count()); 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 */ /* Send events to start all I/O */
for (i = 0; i < core_count; i++) { for (i = 0; i < core_count; i++) {
target = TAILQ_FIRST(&g_head[i].targets); if (!TAILQ_EMPTY(&g_head[i].targets)) {
if (target != NULL) { event = spdk_event_allocate(g_head[i].lcore, bdevperf_submit_on_core,
event = spdk_event_allocate(target->lcore, bdevperf_submit_on_core,
&g_head[i], NULL); &g_head[i], NULL);
spdk_event_call(event); spdk_event_call(event);
} }
@ -1341,7 +1341,6 @@ static void
spdk_bdevperf_shutdown_cb(void) spdk_bdevperf_shutdown_cb(void)
{ {
uint32_t i; uint32_t i;
struct io_target *target;
struct spdk_event *event; struct spdk_event *event;
g_shutdown = true; g_shutdown = true;
@ -1360,9 +1359,8 @@ spdk_bdevperf_shutdown_cb(void)
/* Send events to stop all I/O on each core */ /* Send events to stop all I/O on each core */
for (i = 0; i < spdk_env_get_core_count(); i++) { for (i = 0; i < spdk_env_get_core_count(); i++) {
target = TAILQ_FIRST(&g_head[i].targets); if (!TAILQ_EMPTY(&g_head[i].targets)) {
if (target != NULL) { event = spdk_event_allocate(g_head[i].lcore, bdevperf_stop_io_on_core,
event = spdk_event_allocate(target->lcore, bdevperf_stop_io_on_core,
&g_head[i], NULL); &g_head[i], NULL);
spdk_event_call(event); spdk_event_call(event);
} }