From: Niklas Cassel Date: Thu, 3 Feb 2022 19:28:24 +0000 (+0000) Subject: backend: do ioprio_set() before calling the ioengine init callback X-Git-Tag: fio-3.30~75 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=61b20c5c7b86d2c0840237843002c073345e34fd;hp=13f475ad58ff97e5ca0ecd311a6f039f74d51c12;p=fio.git backend: do ioprio_set() before calling the ioengine init callback To be able to report clat stats on a per priority granularity (instead of only high/low priority), we need to do ioprio_set(), and the matching td->ioprio assignment, before calling the io engine init callback. When a thread is using more than a single priority (e.g. option cmdprio_percentage is used), fio_cmdprio_init() will need to allocate and initialize an array that will hold the clat stats for all the different priorities that will be used by the struct td. For fio_cmdprio_init() to be able to initialize a per priority clat array properly, we need to assign td->ioprio before calling td_io_init(). Signed-off-by: Niklas Cassel Reviewed-by: Damien Le Moal Link: https://lore.kernel.org/r/20220203192814.18552-3-Niklas.Cassel@wdc.com Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index c167f908..f7398b23 100644 --- a/backend.c +++ b/backend.c @@ -1777,6 +1777,17 @@ static void *thread_main(void *data) if (!init_iolog(td)) goto err; + /* ioprio_set() has to be done before td_io_init() */ + if (fio_option_is_set(o, ioprio) || + fio_option_is_set(o, ioprio_class)) { + ret = ioprio_set(IOPRIO_WHO_PROCESS, 0, o->ioprio_class, o->ioprio); + if (ret == -1) { + td_verror(td, errno, "ioprio_set"); + goto err; + } + td->ioprio = ioprio_value(o->ioprio_class, o->ioprio); + } + if (td_io_init(td)) goto err; @@ -1789,16 +1800,6 @@ static void *thread_main(void *data) if (o->verify_async && verify_async_init(td)) goto err; - if (fio_option_is_set(o, ioprio) || - fio_option_is_set(o, ioprio_class)) { - ret = ioprio_set(IOPRIO_WHO_PROCESS, 0, o->ioprio_class, o->ioprio); - if (ret == -1) { - td_verror(td, errno, "ioprio_set"); - goto err; - } - td->ioprio = ioprio_value(o->ioprio_class, o->ioprio); - } - if (o->cgroup && cgroup_setup(td, cgroup_list, &cgroup_mnt)) goto err;