os-linux: add initial support for IO priority hints Add initial support for Linux to allow specifying a hint for any priority value. With this change, a priority value becomes the combination of a priority class, a priority level and a hint. The generic os.h ioprio manipulation macros, as well as the os-dragonfly.h ioprio manipulation macros are modified to ignore this hint. For all other OSes that do not support priority classes, priotity hints are ignored and always equal to 0. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com> Link: https://lore.kernel.org/r/20230721110510.44772-4-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
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>
cpus_allowed: use __NRPROCESSORS_CONF instead of __SC_NPROCESSORS_ONLN for non-sequential CPU ids When disabling SMT on some systems, the ID of some available CPU may be larger than the value of sysconf(_SC_NPROCESSORS_ONLN). Without this patch, fio complains that the expected CPU ID is invalid. Here's an example from my server: $ ./fio --cpus_allowed=14 --ioengine=libaio --direct=1 --name=test --numjobs=1 --blocksize=128k --iodepth=1 --rw=read --filename=/dev/nvme0n1 fio: CPU 14 too large (max=11) fio: failed parsing cpus_allowed=14 System information: $ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 20 On-line CPU(s) list: 0,2,4,6,8,10,12,14,16-19 Off-line CPU(s) list: 1,3,5,7,9,11,13,15 ... Model name: 12th Gen Intel(R) Core(TM) i7-12700 BIOS Model name: 12th Gen Intel(R) Core(TM) i7-12700 ... $ uname -a Linux localhost.localdomain 4.18.0-348.el8.x86_64 #1 SMP Tue Oct 19 15:14:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux $ cat /etc/redhat-release CentOS Linux release 8.5.2111 $ cat /proc/cmdline BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18.0-348.el8.x86_64 root=/dev/mapper/cl-root ro nosmt isolcpus=0,2,4,6,8,10,12,14 crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet $ cat test.c #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { printf("_SC_NPROCESSORS_ONLN=%ld _SC_NPROCESSORS_CONF=%ld\n", sysconf(_SC_NPROCESSORS_ONLN), sysconf(_SC_NPROCESSORS_CONF)); } $ gcc test.c $ ./a.out _SC_NPROCESSORS_ONLN=12 _SC_NPROCESSORS_CONF=20 Signed-off-by: mayuanpeng <mayuanpeng@dapustor.com>
Merge os-android.h into os-linux.h Reduce code duplication by merging the os-android.h and os-linux.h header files. The only functional change in this patch is that FIO_HAVE_SGIO is now defined in the Android build and hence that the sg I/O engine is enabled for Android. Signed-off-by: Bart Van Assche <bvanassche@acm.org>
os: define min/max prio class and level for systems without ioprio In order to avoid additional ifdef FIO_HAVE_IOPRIO_CLASS/FIO_HAVE_IOPRIO from being added to the code, define IOPRIO_{MIN,MAX}_PRIO_CLASS and IOPRIO_{MIN,MAX}_PRIO_CLASS as zero for systems without support for ioprio. Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Link: https://lore.kernel.org/r/20220203192814.18552-7-Niklas.Cassel@wdc.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Query Windows clock frequency and use reported max Previously FIO used the Windows lower-bound clock frequency of 64 Hz for its helper-thread. This caused IOPS/BW logs to have large drift between timestamps when not using per-unit logging for those measurements. Now query the current resolution and set to use the maximum for more accurate timestamps. Note that the resolution is automatically restored after FIO terminates. Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com>
fio: Introduce the log_prio option Introduce the log_prio option to expand priority logging from just a single bit information (priority high vs low) to the full value of the priority value used to execute IOs. When this option is set, the priority value is printed as a 16-bits hexadecimal value combining the I/O priority class and priority level as defined by the ioprio_value() helper. Similarly to the log_offset option, this option does not result in actual I/O priority logging when log_avg_msec is set. This patch also fixes a problem with the IO_U_F_PRIORITY flag, namely that this flag is used to indicate that the IO is being executed with a high priority on the device while at the same time indicating how to account for the IO completion latency (high_prio clat vs low_prio clat). With the introduction of the cmdprio_class and cmdprio options, these assumptions are not necesarilly compatible anymore. These problems are addressed as follows: * The priority_bit field of struct iosample is replaced with the 16-bits priority field representing the full io_u->ioprio value. When log_prio is set, the priority field value is logged as is. When log_prio is not set, 1 is logged as the entry's priority field if the sample priority class is IOPRIO_CLASS_RT, and 0 otherwise. * IO_U_F_PRIORITY is renamed to IO_U_F_HIGH_PRIO to indicate that a job IO has the highest priority within the job context and so must be accounted as such using high_prio clat. While fio final statistics only show accounting of high vs low IO completion latency statistics, the log_prio option allows a user to perform more detailed statistical analysis of a workload using multiple different IO priorities. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
os: introduce ioprio_value() helper Introduce the ioprio_value() helper function to calculate a priority value based on a priority class and priority level. For Linux and Android, this is defined as an integer equal to the priority class shifted left by 13 bits and or-ed with the priority level. For Dragonfly, ioprio_value() simply returns the priority level as there is no concept of priority class. Use this new helper in the io_uring and libaio engines to set IO priority when the cmdprio_percentage option is used. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio: remove raw device support As of Linux kernel commit 603e4922f1c ("remove the raw driver"), linux/raw.h is gone, and raw device support no longer exists. Because of this, fio can no longer build against the current Linux kernel headers. So, remove raw device support from fio as well. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
filesetup: fix directory creation issues - Fix double directory prefix concatenation that was happening after 95af8dd57a7a9a564f99492bb1e04bb6d13b95b1 ("filesetup: don't call create_work_dirs() for ioengine with FIO_DISKLESSIO") refactored some code - Stop always using '/' and switch to using FIO_OS_PATH_SEPARATOR when concatenating the directory value to the filename in set_name_idx() - Change the permissions directories are created with to have the execute bit so they can be entered(!) - Fix bug where filenames that were absolute unix paths would prevent the creation of intermediate directories - Remove the configure mkdir test and introduce fio_mkdir to hide mkdir platform differences - Make Windows mkdir emulation more robust against multiple slashes after the drive letter and when dealing dealing with with paths containing drive letters in general This commit makes the following work on Windows: ./fio --thread --name=doubleslashtest \ --filename='C\:\\Windows\Temp\fio.tmp' --size=4k --bs=4k --rw=read The next example now works when D:\1\ exists but D:\1\2\ doesn't: ./fio --thread --name=mkdirtest --directory='D\:\1' \ --filename='2\fio.tmp' --size=4k --bs=4k --rw=read The following now works on macOS/Linux when /tmp/1/ exists but /tmp/1/2/ doesn't: ./fio --name=mkdirtest --directory='/tmp/1' \ --filename='2/fio.tmp' --size=4k --bs=4k --rw=read Fixes https://github.com/axboe/fio/issues/784 , https://github.com/axboe/fio/issues/864 and https://github.com/axboe/fio/issues/870 Tested-by: Astolfo Rueda <astolfor@microsoft.com> Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
filesetup: add fallocate=truncate option. Fixes #833. Provides the ability to initially "layout" the file by ftruncating it to the desired size before performing IO. This is mainly useful on Windows, which serializes all writes that extend the size of a file. Using this option with a suitable iodepth allows fio to emulate the behavior of Windows Explorer file copy, which always truncates to the expected size before issuing writes for performance reasons.
sg: Clean up handling of big endian data fields Getting and setting values in SCSI commands and descriptors, which are big endian, in SG driver can use a bit of cleanup. This patch simplifies SG driver code by introducing a set of accessor functions for reading raw big endian values from SCSI buffers and another set for properly storing the local values as big endian byte sequences. The patch also adds some missing endianness conversion macros in os.h. Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
aarch64: refactor HW ARM CRC32c detection - Tweak how fio does the configure probe for hardware accelerated ARM CRC32c - Move the Linux specific runtime detection into os-linux.h making it cleaner to implement runtime probing for OSes other than Linux in the future - Make the ARCH_HAVE_CRC_CRYPTO define go into the config-host.* files the same way as most other configure defines - Set/use only the ARCH_HAVE_CRC_CRYPTO define rather than also creating/using ARCH_HAVE_ARM64_CRC_CRYPTO This commit should silence the "Fails to compile: error: sys/auxv.h file not found" compilation message that was seen on FreeBSD 12/arm64 (but note a future commit will be required to implement runtime probing and actually enable the accelerated path on that platform). Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>