fio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] t/io_uring: fixes in output
@ 2021-09-08  4:10 Andrzej Jakowski
  2021-09-08  4:10 ` [PATCH 2/2] t/io_uring: allow flexible IO threads assignment Andrzej Jakowski
  2021-09-08 12:48 ` [PATCH 1/2] t/io_uring: fixes in output Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Andrzej Jakowski @ 2021-09-08  4:10 UTC (permalink / raw)
  To: fio, axboe; +Cc: Andrzej Jakowski

Provide description of available options in usage command
and fix alignment so they look pretty.

Also remove debug output.

Signed-off-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
---
 t/io_uring.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/t/io_uring.c b/t/io_uring.c
index 3130e46..28c76b0 100644
--- a/t/io_uring.c
+++ b/t/io_uring.c
@@ -539,12 +539,16 @@ static void file_depths(char *buf)
 static void usage(char *argv)
 {
 	printf("%s [options] -- [filenames]\n"
-		" -d <int> : IO Depth, default %d\n"
-		" -s <int> : Batch submit, default %d\n"
-		" -c <int> : Batch complete, default %d\n"
-		" -b <int> : Block size, default %d\n"
-		" -p <bool> : Polled IO, default %d\n",
-		argv, DEPTH, BATCH_SUBMIT, BATCH_COMPLETE, BS, polled);
+		" -d <int>  : IO Depth, default %d\n"
+		" -s <int>  : Batch submit, default %d\n"
+		" -c <int>  : Batch complete, default %d\n"
+		" -b <int>  : Block size, default %d\n"
+		" -p <bool> : Polled IO, default %d\n"
+		" -B <bool> : Fixed buffers, default %d\n"
+		" -F <bool> : Register files, default %d\n"
+		" -n <int>  : Number of threads, default %d\n",
+		argv, DEPTH, BATCH_SUBMIT, BATCH_COMPLETE, BS, polled,
+		fixedbufs, register_files, nthreads);
 	exit(0);
 }
 
@@ -609,7 +613,6 @@ int main(int argc, char *argv[])
 
 	j = 0;
 	i = optind;
-	printf("i %d, argc %d\n", i, argc);
 	while (!do_nop && i < argc) {
 		struct file *f;
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] t/io_uring: allow flexible IO threads assignment
  2021-09-08  4:10 [PATCH 1/2] t/io_uring: fixes in output Andrzej Jakowski
@ 2021-09-08  4:10 ` Andrzej Jakowski
  2021-09-08 12:50   ` Jens Axboe
  2021-09-08 12:48 ` [PATCH 1/2] t/io_uring: fixes in output Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Andrzej Jakowski @ 2021-09-08  4:10 UTC (permalink / raw)
  To: fio, axboe; +Cc: Andrzej Jakowski

This patch allows to flexibly assign IO threads to fileset. When
you specify:

t/io_uring -n 5 /dev/dev1 dev/dev2

First file/device will get 3 IO threads and second file/device
remaining 2 IO threads. When there is more files then IO threads,
IO thread may get assigned multiple files/devices.

Signed-off-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
---
 t/io_uring.c | 51 ++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/t/io_uring.c b/t/io_uring.c
index 28c76b0..6a06799 100644
--- a/t/io_uring.c
+++ b/t/io_uring.c
@@ -556,7 +556,8 @@ int main(int argc, char *argv[])
 {
 	struct submitter *s;
 	unsigned long done, calls, reap;
-	int err, i, j, flags, fd, opt;
+	int err, i, j, flags, fd, opt, threads_per_f, threads_rem = 0, nfiles;
+	struct file f;
 	char *fdepths;
 	void *ret;
 
@@ -613,37 +614,53 @@ int main(int argc, char *argv[])
 
 	j = 0;
 	i = optind;
+	nfiles = argc - i;
+	threads_per_f = nthreads / nfiles;
+	/* make sure each thread gets assigned files */
+	if (threads_per_f == 0) {
+		threads_per_f = 1;
+	} else {
+		threads_rem = nthreads - threads_per_f * nfiles;
+	}
 	while (!do_nop && i < argc) {
-		struct file *f;
+		int k, limit;
+
+		memset(&f, 0, sizeof(f));
 
-		s = get_submitter(j);
-		if (s->nr_files == MAX_FDS) {
-			printf("Max number of files (%d) reached\n", MAX_FDS);
-			break;
-		}
 		fd = open(argv[i], flags);
 		if (fd < 0) {
 			perror("open");
 			return 1;
 		}
-
-		f = &s->files[s->nr_files];
-		f->real_fd = fd;
-		if (get_file_size(f)) {
+		f.real_fd = fd;
+		if (get_file_size(&f)) {
 			printf("failed getting size of device/file\n");
 			return 1;
 		}
-		if (f->max_blocks <= 1) {
+		if (f.max_blocks <= 1) {
 			printf("Zero file/device size?\n");
 			return 1;
 		}
-		f->max_blocks--;
+		f.max_blocks--;
+
+		limit = threads_per_f;
+		limit += threads_rem > 0 ? 1 : 0;
+		for (k = 0; k < limit; k++) {
+			s = get_submitter((j + k) % nthreads);
 
-		printf("Added file %s (submitter %d)\n", argv[i], s->index);
-		s->nr_files++;
+			if (s->nr_files == MAX_FDS) {
+				printf("Max number of files (%d) reached\n", MAX_FDS);
+				break;
+			}
+
+			memcpy(&s->files[s->nr_files], &f, sizeof(f));
+
+			printf("Added file %s (submitter %d)\n", argv[i], s->index);
+			s->nr_files++;
+		}
+		threads_rem--;
 		i++;
-		if (++j >= nthreads)
-			j = 0;
+		j += limit;
 	}
 
 	if (fixedbufs) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] t/io_uring: fixes in output
  2021-09-08  4:10 [PATCH 1/2] t/io_uring: fixes in output Andrzej Jakowski
  2021-09-08  4:10 ` [PATCH 2/2] t/io_uring: allow flexible IO threads assignment Andrzej Jakowski
@ 2021-09-08 12:48 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-09-08 12:48 UTC (permalink / raw)
  To: Andrzej Jakowski, fio

On 9/7/21 10:10 PM, Andrzej Jakowski wrote:
> Provide description of available options in usage command
> and fix alignment so they look pretty.
> 
> Also remove debug output.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] t/io_uring: allow flexible IO threads assignment
  2021-09-08  4:10 ` [PATCH 2/2] t/io_uring: allow flexible IO threads assignment Andrzej Jakowski
@ 2021-09-08 12:50   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-09-08 12:50 UTC (permalink / raw)
  To: Andrzej Jakowski, fio

On 9/7/21 10:10 PM, Andrzej Jakowski wrote:
> This patch allows to flexibly assign IO threads to fileset. When
> you specify:
> 
> t/io_uring -n 5 /dev/dev1 dev/dev2
> 
> First file/device will get 3 IO threads and second file/device
> remaining 2 IO threads. When there is more files then IO threads,
> IO thread may get assigned multiple files/devices.
> 
> Signed-off-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
> ---
>  t/io_uring.c | 51 ++++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 34 insertions(+), 17 deletions(-)
> 
> diff --git a/t/io_uring.c b/t/io_uring.c
> index 28c76b0..6a06799 100644
> --- a/t/io_uring.c
> +++ b/t/io_uring.c
> @@ -556,7 +556,8 @@ int main(int argc, char *argv[])
>  {
>  	struct submitter *s;
>  	unsigned long done, calls, reap;
> -	int err, i, j, flags, fd, opt;
> +	int err, i, j, flags, fd, opt, threads_per_f, threads_rem = 0, nfiles;
> +	struct file f;
>  	char *fdepths;
>  	void *ret;
>  
> @@ -613,37 +614,53 @@ int main(int argc, char *argv[])
>  
>  	j = 0;
>  	i = optind;
> +	nfiles = argc - i;
> +	threads_per_f = nthreads / nfiles;

Can nfiles be zero?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-08 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08  4:10 [PATCH 1/2] t/io_uring: fixes in output Andrzej Jakowski
2021-09-08  4:10 ` [PATCH 2/2] t/io_uring: allow flexible IO threads assignment Andrzej Jakowski
2021-09-08 12:50   ` Jens Axboe
2021-09-08 12:48 ` [PATCH 1/2] t/io_uring: fixes in output Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).