Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>,
	Vincent Fu <vincentfu@gmail.com>, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH 4/4] stats: Add hint information to per priority level stats
Date: Tue, 18 Jul 2023 15:45:26 +0000	[thread overview]
Message-ID: <ZLazkxGhtZkCDPZz@x1-carbon> (raw)
In-Reply-To: <20230705221302.430678-5-dlemoal@kernel.org>

On Thu, Jul 06, 2023 at 07:13:02AM +0900, Damien Le Moal wrote:
> From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> 
> Introduce the OS dependent ioprio_hint() macro to extract an IO
> priority hint from an ioprio value. This macro defaults to always
> returning 0 for OSes that do not support IO priority hints.
> 
> The json and standard output stats are modified to display the hint
> value together with the priority class and level.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> ---
>  os/os-linux.h |  4 ++++
>  os/os.h       |  3 +++
>  stat.c        | 10 +++++++---
>  3 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/os/os-linux.h b/os/os-linux.h
> index 6f241d09..b9c07891 100644
> --- a/os/os-linux.h
> +++ b/os/os-linux.h
> @@ -150,6 +150,10 @@ static inline int ioprio_value(int ioprio_class, int ioprio, int ioprio_hint)
>  		ioprio;
>  }
>  
> +#define ioprio_class(ioprio)	((ioprio) >> IOPRIO_CLASS_SHIFT)
> +#define ioprio_hint(ioprio)	(((ioprio) >> IOPRIO_HINT_SHIFT) & 0x3ff)
> +#define ioprio(ioprio)		((ioprio) & 7)

1)
ioprio_class() and ioprio() are already defined in os/os-linux.h,
so if you add these again, we will have duplicates in os/os-linux.h.
You probably only want to add ioprio_hint(), after the existing defines.


2)
Perhaps you can also change:
#define ioprio(ioprio)          ((ioprio) & 7)
to
#define ioprio(ioprio)          ((ioprio) & IOPRIO_MAX_PRIO)

and
#define ioprio_hint(ioprio)  (((ioprio) >> IOPRIO_HINT_SHIFT) & 0x3ff)
to
#define ioprio_hint(ioprio)  (((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_MAX_PRIO_HINT)

so we avoid magic numbers.


> +
>  static inline bool ioprio_value_is_class_rt(unsigned int priority)
>  {
>  	return (priority >> IOPRIO_CLASS_SHIFT) == IOPRIO_CLASS_RT;
> diff --git a/os/os.h b/os/os.h
> index 2217d5f8..0f182324 100644
> --- a/os/os.h
> +++ b/os/os.h
> @@ -120,6 +120,9 @@ extern int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu);
>  #define ioprio_value_is_class_rt(prio)	(false)
>  #define IOPRIO_MIN_PRIO_CLASS		0
>  #define IOPRIO_MAX_PRIO_CLASS		0
> +#define ioprio_hint(prio)		0

> +#define IOPRIO_MIN_PRIO_HINT		0
> +#define IOPRIO_MAX_PRIO_HINT		0

3)
The MIN_ and MAX_ define should probably go to patch 1/4,
which added the same for os/os-linux.h.


>  #endif
>  #ifndef FIO_HAVE_IOPRIO
>  #define ioprio_value(prioclass, prio, priohint)	(0)
> diff --git a/stat.c b/stat.c
> index 015b8e28..4f943602 100644
> --- a/stat.c
> +++ b/stat.c
> @@ -597,10 +597,11 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
>  				continue;
>  
>  			snprintf(buf, sizeof(buf),
> -				 "%s prio %u/%u",
> +				 "%s prio %u/%u/%u",
>  				 clat_type,
>  				 ioprio_class(ts->clat_prio[ddir][i].ioprio),
> -				 ioprio(ts->clat_prio[ddir][i].ioprio));
> +				 ioprio(ts->clat_prio[ddir][i].ioprio),
> +				 ioprio_hint(ts->clat_prio[ddir][i].ioprio));
>  			display_lat(buf, min, max, mean, dev, out);
>  		}
>  	}
> @@ -640,10 +641,11 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
>  					continue;
>  
>  				snprintf(prio_name, sizeof(prio_name),
> -					 "%s prio %u/%u (%.2f%% of IOs)",
> +					 "%s prio %u/%u/%u (%.2f%% of IOs)",
>  					 clat_type,
>  					 ioprio_class(ts->clat_prio[ddir][i].ioprio),
>  					 ioprio(ts->clat_prio[ddir][i].ioprio),
> +					 ioprio_hint(ts->clat_prio[ddir][i].ioprio),
>  					 100. * (double) prio_samples / (double) samples);
>  				show_clat_percentiles(ts->clat_prio[ddir][i].io_u_plat,
>  						prio_samples, ts->percentile_list,
> @@ -1522,6 +1524,8 @@ static void add_ddir_status_json(struct thread_stat *ts,
>  				ioprio_class(ts->clat_prio[ddir][i].ioprio));
>  			json_object_add_value_int(obj, "prio",
>  				ioprio(ts->clat_prio[ddir][i].ioprio));
> +			json_object_add_value_int(obj, "priohint",
> +				ioprio_hint(ts->clat_prio[ddir][i].ioprio));
>  
>  			tmp_object = add_ddir_lat_json(ts,
>  					ts->clat_percentiles | ts->lat_percentiles,
> -- 
> 2.41.0
> 

With the three nits fixed:
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>

  reply	other threads:[~2023-07-18 15:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 22:12 [PATCH 0/4] Add support for IO priority hints Damien Le Moal
2023-07-05 22:12 ` [PATCH 1/4] os-linux: add initial " Damien Le Moal
2023-07-18 15:44   ` Niklas Cassel
2023-07-05 22:13 ` [PATCH 2/4] options: add priohint option Damien Le Moal
2023-07-18 15:44   ` Niklas Cassel
2023-07-18 15:55     ` Niklas Cassel
2023-07-05 22:13 ` [PATCH 3/4] cmdprio: Add support for per I/O priority hint Damien Le Moal
2023-07-18 15:45   ` Niklas Cassel
2023-07-05 22:13 ` [PATCH 4/4] stats: Add hint information to per priority level stats Damien Le Moal
2023-07-18 15:45   ` Niklas Cassel [this message]
2023-07-06  8:43 ` [PATCH 0/4] Add support for IO priority hints Avri Altman
2023-07-06  8:57   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZLazkxGhtZkCDPZz@x1-carbon \
    --to=niklas.cassel@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=fio@vger.kernel.org \
    --cc=vincentfu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox