Re: [PATCH 10/10] engines/libblkio: Share a single blkio instance among threads in same process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/21/22 13:29, Alberto Faria wrote:
fio groups all subjobs that set option 'thread' into a single process.
Have them all share a single `struct blkio` instance, with one `struct
blkioq` per thread/subjob. This allows benchmarking multi-queue setups.

Note that `struct blkio` instances cannot be shared across different
processes.

Signed-off-by: Alberto Faria <afaria@xxxxxxxxxx>
---
  HOWTO.rst                                 |   8 +-
  engines/libblkio.c                        | 250 +++++++++++++++++++---
  examples/libblkio-io_uring.fio            |  13 +-
  examples/libblkio-virtio-blk-vfio-pci.fio |  13 +-
  fio.1                                     |   7 +-
  5 files changed, 257 insertions(+), 34 deletions(-)

diff --git a/HOWTO.rst b/HOWTO.rst
index 763f4f51..4e69abfc 100644
--- a/HOWTO.rst
+++ b/HOWTO.rst
@@ -2199,7 +2199,13 @@ I/O engine
  			:option:`libblkio_driver`. If
  			:option:`mem`/:option:`iomem` is not specified, memory
  			allocation is delegated to libblkio (and so is
-			guaranteed to work with the selected *driver*).
+			guaranteed to work with the selected *driver*). One
+			``struct blkio`` instance is used per process, so all
+			jobs setting option :option:`thread` will share a single
+			``struct blkio`` (with one queue per thread) and must
+			specify compatible options. Note that some drivers don't
+			allow several processes to access the same device or
+			file simultaneously, but allow it for threads.
I/O engine specific parameters
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/engines/libblkio.c b/engines/libblkio.c
index a80be66f..987dea4f 100644
--- a/engines/libblkio.c
+++ b/engines/libblkio.c
@@ -249,6 +249,105 @@ static int fio_blkio_set_props_from_str(struct blkio *b, const char *opt_name,
  			blkio_get_error_msg()); \
  	})
+static bool possibly_null_strs_equal(const char *a, const char *b)
+{
+	return (!a && !b) || (a && b && strcmp(a, b) == 0);
+}
+
+/*
+ * Returns the total number of subjobs using option 'thread' in the entire
+ * workload that have the given value for the 'hipri' option.
+ */
+static int total_threaded_subjobs(bool hipri)
+{
+	struct thread_data *td;
+	unsigned int i;
+	int count = 0;
+
+	for_each_td(td, i) {
+		const struct fio_blkio_options *options = td->eo;
+		if (td->o.use_thread && (bool)options->hipri == hipri)
+			++count;
+	}
+
+	return count;
+}

The loop should skip jobs not using the libblkio ioengine because, for example, some ioengines don't have any ioengine options.




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux