On 2/1/22 06:13, Niklas Cassel wrote: > From: Niklas Cassel <niklas.cassel@xxxxxxx> > > 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 <niklas.cassel@xxxxxxx> > --- > backend.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > 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; > Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx> -- Damien Le Moal Western Digital Research