stat: Fix ioprio print
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Fri, 10 Mar 2023 01:28:39 +0000 (10:28 +0900)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 15 Mar 2023 23:18:47 +0000 (19:18 -0400)
commita967e54d34afe3bb10cd521d78bcaea2dd8c7cdc
tree889305747d05bc939ad1cf701717f75f70a67556
parent4ad09b569a2689b3b67744eaccd378d013eb82a7
stat: Fix ioprio print

When using per-priority statistics for workloads using multiple
different priority values, the statistics output displays the priority
class and value (level) for each set of statistics. However, this is
done using linux priority values coding, that is, assuming that the
priority level is at most 7 (lower 3-bits). However, this is not always
the case for all OSes. E.g. dragonfly allows IO priorities up to a
value of 10.

Introduce the OS dependent ioprio_class() and ioprio() macros to extract
the fields from an ioprio value according to the OS capabilities. A
generic definition (always returning 0) for these macros in os/os.h is
added and used for all OSes that do not define these macros.

The functions show_ddir_status() and add_ddir_status_json() are modified
to use these new macros to fix per priority statistics output. The
modification includes changes to the loops over the clat_prio array to
reduce indentation levels, making the code a little cleaner.

Fixes: 692dec0cfb4b ("stat: report clat stats on a per priority granularity")
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
os/os-dragonfly.h
os/os-linux.h
os/os.h
stat.c