bdevperf: Allocate tasks when job is allocated

This simplifies the initialization to only a single pass through all
cores.

Change-Id: I6fa8fec90d131f0fd9544ef8548daac52465691a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1504
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Ben Walker 2020-03-20 14:20:54 -07:00 committed by Tomasz Zawadzki
parent ded0c2d146
commit 76f49c93c5

View File

@ -1048,67 +1048,6 @@ static struct bdevperf_task *bdevperf_construct_task_on_job(struct bdevperf_job
return task;
}
static void
bdevperf_construct_jobs_tasks_done(struct spdk_io_channel_iter *i, int status)
{
if (status != 0) {
fprintf(stderr, "Bdevperf program exits due to memory allocation issue\n");
fprintf(stderr, "Use -d XXX to allocate more huge pages, e.g., -d 4096\n");
g_run_rc = status;
bdevperf_test_done(NULL);
return;
}
bdevperf_test();
}
static void
bdevperf_construct_tasks_on_reactor(struct spdk_io_channel_iter *i)
{
struct spdk_io_channel *ch;
struct bdevperf_reactor *reactor;
struct bdevperf_job *job;
struct bdevperf_task *task;
int n, task_num = g_queue_depth;
int rc = 0;
ch = spdk_io_channel_iter_get_channel(i);
reactor = spdk_io_channel_get_ctx(ch);
if (g_reset) {
task_num += 1;
}
TAILQ_FOREACH(job, &reactor->jobs, link) {
for (n = 0; n < task_num; n++) {
task = bdevperf_construct_task_on_job(job);
if (task == NULL) {
rc = -1;
goto end;
}
TAILQ_INSERT_TAIL(&job->task_list, task, link);
}
}
end:
spdk_for_each_channel_continue(i, rc);
}
static void
bdevperf_construct_jobs_tasks(void)
{
if (g_bdevperf.running_jobs == 0) {
fprintf(stderr, "No valid bdevs found.\n");
g_run_rc = -ENODEV;
bdevperf_test_done(NULL);
return;
}
/* Initialize task list for each job */
spdk_for_each_channel(&g_bdevperf, bdevperf_construct_tasks_on_reactor, NULL,
bdevperf_construct_jobs_tasks_done);
}
static void
bdevperf_job_gone(void *arg)
{
@ -1130,9 +1069,11 @@ static int
_bdevperf_construct_job(struct construct_jobs_ctx *ctx, struct bdevperf_reactor *reactor)
{
struct bdevperf_job *job;
struct bdevperf_task *task;
int block_size, data_block_size;
struct spdk_bdev *bdev = ctx->bdev;
int rc;
int task_num, n;
job = calloc(1, sizeof(struct bdevperf_job));
if (!job) {
@ -1193,6 +1134,21 @@ _bdevperf_construct_job(struct construct_jobs_ctx *ctx, struct bdevperf_reactor
TAILQ_INIT(&job->task_list);
task_num = g_queue_depth;
if (g_reset) {
task_num += 1;
}
for (n = 0; n < task_num; n++) {
task = bdevperf_construct_task_on_job(job);
if (task == NULL) {
spdk_bdev_close(job->bdev_desc);
bdevperf_free_job(job);
return -ENOMEM;
}
TAILQ_INSERT_TAIL(&job->task_list, task, link);
}
job->reactor = reactor;
TAILQ_INSERT_TAIL(&reactor->jobs, job, link);
@ -1214,7 +1170,7 @@ _bdevperf_construct_jobs_done(struct spdk_io_channel_iter *i, int status)
free(ctx);
if (--g_construct_job_count == 0) {
bdevperf_construct_jobs_tasks();
bdevperf_test();
}
}
@ -1319,7 +1275,7 @@ bdevperf_construct_jobs(void)
}
if (--g_construct_job_count == 0) {
bdevperf_construct_jobs_tasks();
bdevperf_test();
}
}