bdevperf: Use spdk_thread_send_msg() instead of spdk_event_call()

Use spdk_thread_send_msg() for notification of bdev hotplug
and test completion instead of spdk_event_call().

Each I/O target group is associated with SPDK thread now. Hence
use spdk_thread_send_msg() to do bdevperf_target_gone() on the
specified thread. The group is held in struct io_target by the
previous patchm and remove target->lcore safely because it is
not used anymore.

Then use spdk_thread_send_msg() to notify master thread.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I88eadbdd1f120161cf484793f14f5eb0b44d010f
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478818
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@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-12 18:13:51 -05:00 committed by Jim Harris
parent 728481f491
commit bad8847f7a

View File

@ -78,7 +78,7 @@ static int g_run_rc = 0;
static bool g_shutdown = false; static bool g_shutdown = false;
static uint64_t g_shutdown_tsc; static uint64_t g_shutdown_tsc;
static bool g_zcopy = true; static bool g_zcopy = true;
static unsigned g_master_core; static struct spdk_thread *g_master_thread;
static int g_time_in_sec; static int g_time_in_sec;
static bool g_mix_specified; static bool g_mix_specified;
static const char *g_target_bdev_name; static const char *g_target_bdev_name;
@ -99,7 +99,6 @@ struct io_target {
struct spdk_io_channel *ch; struct spdk_io_channel *ch;
TAILQ_ENTRY(io_target) link; TAILQ_ENTRY(io_target) link;
struct io_target_group *group; struct io_target_group *group;
unsigned lcore;
uint64_t io_completed; uint64_t io_completed;
uint64_t prev_io_completed; uint64_t prev_io_completed;
double ema_io_per_second; double ema_io_per_second;
@ -273,9 +272,9 @@ _end_target(struct io_target *target)
} }
static void static void
_target_gone(void *arg1, void *arg2) _target_gone(void *ctx)
{ {
struct io_target *target = arg1; struct io_target *target = ctx;
_end_target(target); _end_target(target);
} }
@ -284,10 +283,10 @@ static void
bdevperf_target_gone(void *arg) bdevperf_target_gone(void *arg)
{ {
struct io_target *target = arg; struct io_target *target = arg;
struct spdk_event *event; struct io_target_group *group = target->group;
event = spdk_event_allocate(target->lcore, _target_gone, target, NULL); spdk_thread_send_msg(spdk_io_channel_get_thread(spdk_io_channel_from_ctx(group)),
spdk_event_call(event); _target_gone, target);
} }
static int static int
@ -374,7 +373,6 @@ bdevperf_construct_target(struct spdk_bdev *bdev)
} }
group = g_next_tg; group = g_next_tg;
g_next_tg = TAILQ_NEXT(g_next_tg, link); g_next_tg = TAILQ_NEXT(g_next_tg, link);
target->lcore = group->lcore;
target->group = group; target->group = group;
TAILQ_INSERT_TAIL(&group->targets, target, link); TAILQ_INSERT_TAIL(&group->targets, target, link);
g_target_count++; g_target_count++;
@ -467,9 +465,9 @@ bdevperf_test_done(void)
} }
static void static void
end_run(void *arg1, void *arg2) end_run(void *ctx)
{ {
struct io_target *target = arg1; struct io_target *target = ctx;
spdk_bdev_close(target->bdev_desc); spdk_bdev_close(target->bdev_desc);
if (--g_target_count == 0) { if (--g_target_count == 0) {
@ -510,7 +508,6 @@ bdevperf_complete(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
{ {
struct io_target *target; struct io_target *target;
struct bdevperf_task *task = cb_arg; struct bdevperf_task *task = cb_arg;
struct spdk_event *complete;
struct iovec *iovs; struct iovec *iovs;
int iovcnt; int iovcnt;
bool md_check; bool md_check;
@ -560,8 +557,7 @@ bdevperf_complete(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
TAILQ_INSERT_TAIL(&target->task_list, task, link); TAILQ_INSERT_TAIL(&target->task_list, task, link);
if (target->current_queue_depth == 0) { if (target->current_queue_depth == 0) {
spdk_put_io_channel(target->ch); spdk_put_io_channel(target->ch);
complete = spdk_event_allocate(g_master_core, end_run, target, NULL); spdk_thread_send_msg(g_master_thread, end_run, target);
spdk_event_call(complete);
} }
} }
} }
@ -1328,7 +1324,7 @@ _bdevperf_init_thread_done(void *ctx)
{ {
int rc; int rc;
g_master_core = spdk_env_get_current_core(); g_master_thread = spdk_get_thread();
if (g_wait_for_tests) { if (g_wait_for_tests) {
/* Do not perform any tests until RPC is received */ /* Do not perform any tests until RPC is received */