All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
To: Ketor D <d.ketor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Mark Kirkwood
	<mark.kirkwood-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org>,
	Mark Nelson <mark.nelson-4GqslpFJ+cxBDgjK7y7TUQ@public.gmane.org>,
	Mark Nelson
	<mark.a.nelson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"fio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<fio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"xan.peng" <xanpeng-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: fio rbd completions (Was: fio rbd hang for block sizes > 1M)
Date: Tue, 28 Oct 2014 11:09:17 -0600	[thread overview]
Message-ID: <544FCDBD.7070106@kernel.dk> (raw)
In-Reply-To: <CAM9_UU_o8kS1wJnDKTvd8+qkm9=93yfW3THr_8ni8C+5=TH6tg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On 2014-10-28 09:49, Ketor D wrote:
> Cannot get the new commited code from github now.
> When I get the newest code, I will test.

So here's another idea, applies on top of current -git. Basically it 
makes rbd wait for the oldest event, not just the first one in the array 
of all ios. This is the saner thing to do, as hopefully the oldest event 
will be the one to complete first. At least it has a much higher chance 
of being the right thing to do, than just waiting on a random event.

Completely untested, so you might have to fiddle a bit with it to ensure 
that it actually works...

-- 
Jens Axboe


[-- Attachment #2: rbd-time-sort.patch --]
[-- Type: text/x-patch, Size: 3060 bytes --]

diff --git a/engines/rbd.c b/engines/rbd.c
index cf7be0acd1e3..f3129044c430 100644
--- a/engines/rbd.c
+++ b/engines/rbd.c
@@ -20,6 +20,7 @@ struct rbd_data {
 	rados_ioctx_t io_ctx;
 	rbd_image_t image;
 	struct io_u **aio_events;
+	struct io_u **sort_events;
 };
 
 struct rbd_options {
@@ -80,20 +81,19 @@ static int _fio_setup_rbd_data(struct thread_data *td,
 	if (td->io_ops->data)
 		return 0;
 
-	rbd_data = malloc(sizeof(struct rbd_data));
+	rbd_data = calloc(1, sizeof(struct rbd_data));
 	if (!rbd_data)
 		goto failed;
 
-	memset(rbd_data, 0, sizeof(struct rbd_data));
-
-	rbd_data->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
+	rbd_data->aio_events = calloc(td->o.iodepth, sizeof(struct io_u *));
 	if (!rbd_data->aio_events)
 		goto failed;
 
-	memset(rbd_data->aio_events, 0, td->o.iodepth * sizeof(struct io_u *));
+	rbd_data->sort_events = calloc(td->o.iodepth, sizeof(struct io_u *));
+	if (!rbd_data->sort_events)
+		goto failed;
 
 	*rbd_data_ptr = rbd_data;
-
 	return 0;
 
 failed:
@@ -218,14 +218,32 @@ static inline int fri_check_complete(struct rbd_data *rbd_data,
 	return 0;
 }
 
+static int rbd_io_u_cmp(const void *p1, const void *p2)
+{
+	const struct io_u **a = (const struct io_u **) p1;
+	const struct io_u **b = (const struct io_u **) p2;
+	uint64_t at, bt;
+
+	at = utime_since_now(&(*a)->start_time);
+	bt = utime_since_now(&(*b)->start_time);
+
+	if (at < bt)
+		return -1;
+	else if (at == bt)
+		return 0;
+	else
+		return 1;
+}
+
 static int rbd_iter_events(struct thread_data *td, unsigned int *events,
 			   unsigned int min_evts, int wait)
 {
 	struct rbd_data *rbd_data = td->io_ops->data;
 	unsigned int this_events = 0;
 	struct io_u *io_u;
-	int i;
+	int i, sort_idx;
 
+	sort_idx = 0;
 	io_u_qiter(&td->io_u_all, io_u, i) {
 		struct fio_rbd_iou *fri = io_u->engine_data;
 
@@ -236,16 +254,39 @@ static int rbd_iter_events(struct thread_data *td, unsigned int *events,
 
 		if (fri_check_complete(rbd_data, io_u, events))
 			this_events++;
-		else if (wait) {
-			rbd_aio_wait_for_complete(fri->completion);
+		else if (wait)
+			rbd_data->sort_events[sort_idx++] = io_u;
 
-			if (fri_check_complete(rbd_data, io_u, events))
-				this_events++;
-		}
 		if (*events >= min_evts)
 			break;
 	}
 
+	if (!wait || !sort_idx)
+		return this_events;
+
+	qsort(rbd_data->sort_events, sort_idx, sizeof(struct io_u *), rbd_io_u_cmp);
+	for (i = 0; i < sort_idx; i++) {
+		struct fio_rbd_iou *fri;
+
+		io_u = rbd_data->sort_events[i];
+		fri = io_u->engine_data;
+
+		if (fri_check_complete(rbd_data, io_u, events)) {
+			this_events++;
+			continue;
+		}
+		if (!wait)
+			continue;
+
+		rbd_aio_wait_for_complete(fri->completion);
+
+		if (fri_check_complete(rbd_data, io_u, events))
+			this_events++;
+
+		if (wait && *events >= min_evts)
+			wait = 0;
+	}
+
 	return this_events;
 }
 
@@ -359,6 +400,7 @@ static void fio_rbd_cleanup(struct thread_data *td)
 	if (rbd_data) {
 		_fio_rbd_disconnect(rbd_data);
 		free(rbd_data->aio_events);
+		free(rbd_data->sort_events);
 		free(rbd_data);
 	}
 

WARNING: multiple messages have this Message-ID (diff)
From: Jens Axboe <axboe@kernel.dk>
To: Ketor D <d.ketor@gmail.com>
Cc: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>,
	Mark Nelson <mark.nelson@inktank.com>,
	Mark Nelson <mark.a.nelson@gmail.com>,
	"fio@vger.kernel.org" <fio@vger.kernel.org>,
	"xan.peng" <xanpeng@gmail.com>,
	"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: Re: fio rbd completions (Was: fio rbd hang for block sizes > 1M)
Date: Tue, 28 Oct 2014 11:09:17 -0600	[thread overview]
Message-ID: <544FCDBD.7070106@kernel.dk> (raw)
In-Reply-To: <CAM9_UU_o8kS1wJnDKTvd8+qkm9=93yfW3THr_8ni8C+5=TH6tg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On 2014-10-28 09:49, Ketor D wrote:
> Cannot get the new commited code from github now.
> When I get the newest code, I will test.

So here's another idea, applies on top of current -git. Basically it 
makes rbd wait for the oldest event, not just the first one in the array 
of all ios. This is the saner thing to do, as hopefully the oldest event 
will be the one to complete first. At least it has a much higher chance 
of being the right thing to do, than just waiting on a random event.

Completely untested, so you might have to fiddle a bit with it to ensure 
that it actually works...

-- 
Jens Axboe


[-- Attachment #2: rbd-time-sort.patch --]
[-- Type: text/x-patch, Size: 3060 bytes --]

diff --git a/engines/rbd.c b/engines/rbd.c
index cf7be0acd1e3..f3129044c430 100644
--- a/engines/rbd.c
+++ b/engines/rbd.c
@@ -20,6 +20,7 @@ struct rbd_data {
 	rados_ioctx_t io_ctx;
 	rbd_image_t image;
 	struct io_u **aio_events;
+	struct io_u **sort_events;
 };
 
 struct rbd_options {
@@ -80,20 +81,19 @@ static int _fio_setup_rbd_data(struct thread_data *td,
 	if (td->io_ops->data)
 		return 0;
 
-	rbd_data = malloc(sizeof(struct rbd_data));
+	rbd_data = calloc(1, sizeof(struct rbd_data));
 	if (!rbd_data)
 		goto failed;
 
-	memset(rbd_data, 0, sizeof(struct rbd_data));
-
-	rbd_data->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
+	rbd_data->aio_events = calloc(td->o.iodepth, sizeof(struct io_u *));
 	if (!rbd_data->aio_events)
 		goto failed;
 
-	memset(rbd_data->aio_events, 0, td->o.iodepth * sizeof(struct io_u *));
+	rbd_data->sort_events = calloc(td->o.iodepth, sizeof(struct io_u *));
+	if (!rbd_data->sort_events)
+		goto failed;
 
 	*rbd_data_ptr = rbd_data;
-
 	return 0;
 
 failed:
@@ -218,14 +218,32 @@ static inline int fri_check_complete(struct rbd_data *rbd_data,
 	return 0;
 }
 
+static int rbd_io_u_cmp(const void *p1, const void *p2)
+{
+	const struct io_u **a = (const struct io_u **) p1;
+	const struct io_u **b = (const struct io_u **) p2;
+	uint64_t at, bt;
+
+	at = utime_since_now(&(*a)->start_time);
+	bt = utime_since_now(&(*b)->start_time);
+
+	if (at < bt)
+		return -1;
+	else if (at == bt)
+		return 0;
+	else
+		return 1;
+}
+
 static int rbd_iter_events(struct thread_data *td, unsigned int *events,
 			   unsigned int min_evts, int wait)
 {
 	struct rbd_data *rbd_data = td->io_ops->data;
 	unsigned int this_events = 0;
 	struct io_u *io_u;
-	int i;
+	int i, sort_idx;
 
+	sort_idx = 0;
 	io_u_qiter(&td->io_u_all, io_u, i) {
 		struct fio_rbd_iou *fri = io_u->engine_data;
 
@@ -236,16 +254,39 @@ static int rbd_iter_events(struct thread_data *td, unsigned int *events,
 
 		if (fri_check_complete(rbd_data, io_u, events))
 			this_events++;
-		else if (wait) {
-			rbd_aio_wait_for_complete(fri->completion);
+		else if (wait)
+			rbd_data->sort_events[sort_idx++] = io_u;
 
-			if (fri_check_complete(rbd_data, io_u, events))
-				this_events++;
-		}
 		if (*events >= min_evts)
 			break;
 	}
 
+	if (!wait || !sort_idx)
+		return this_events;
+
+	qsort(rbd_data->sort_events, sort_idx, sizeof(struct io_u *), rbd_io_u_cmp);
+	for (i = 0; i < sort_idx; i++) {
+		struct fio_rbd_iou *fri;
+
+		io_u = rbd_data->sort_events[i];
+		fri = io_u->engine_data;
+
+		if (fri_check_complete(rbd_data, io_u, events)) {
+			this_events++;
+			continue;
+		}
+		if (!wait)
+			continue;
+
+		rbd_aio_wait_for_complete(fri->completion);
+
+		if (fri_check_complete(rbd_data, io_u, events))
+			this_events++;
+
+		if (wait && *events >= min_evts)
+			wait = 0;
+	}
+
 	return this_events;
 }
 
@@ -359,6 +400,7 @@ static void fio_rbd_cleanup(struct thread_data *td)
 	if (rbd_data) {
 		_fio_rbd_disconnect(rbd_data);
 		free(rbd_data->aio_events);
+		free(rbd_data->sort_events);
 		free(rbd_data);
 	}
 

  parent reply	other threads:[~2014-10-28 17:09 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24  2:38 fio rbd hang for block sizes > 1M Mark Kirkwood
2014-10-24  5:35 ` Jens Axboe
2014-10-24  6:17   ` Mark Kirkwood
2014-10-24 13:19     ` Mark Nelson
     [not found]       ` <544A51C7.40803-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-24 14:09         ` Mark Nelson
2014-10-24 14:09           ` Mark Nelson
     [not found]           ` <544A5DA6.2010709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-24 14:30             ` Jens Axboe
2014-10-24 14:30               ` Jens Axboe
2014-10-24 22:45             ` Mark Kirkwood
2014-10-24 22:45               ` Mark Kirkwood
     [not found]               ` <544AD67D.4030603-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org>
2014-10-25  0:12                 ` Mark Nelson
2014-10-25  0:12                   ` Mark Nelson
     [not found]                   ` <544AEAE7.6080603-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-10-25  0:37                     ` Mark Kirkwood
2014-10-25  0:37                       ` Mark Kirkwood
     [not found]                       ` <544AF0D2.1050405-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org>
2014-10-25  2:35                         ` Mark Kirkwood
2014-10-25  2:35                           ` Mark Kirkwood
2014-10-25  3:47                           ` Jens Axboe
2014-10-25  4:50                             ` fio rbd completions (Was: fio rbd hang for block sizes > 1M) Mark Kirkwood
2014-10-25 19:20                               ` Jens Axboe
     [not found]                                 ` <544BF808.2090800-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-25 22:25                                   ` Mark Kirkwood
2014-10-25 22:25                                     ` Mark Kirkwood
2014-10-27  9:27                                     ` Ketor D
     [not found]                                       ` <CAM9_UU_S7qhenZW34Lw3r=RHoVa1__610RRsFScgt0adi1dpFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-27 10:25                                         ` Ketor D
2014-10-27 10:25                                           ` Ketor D
2014-10-27 14:19                                           ` Jens Axboe
2014-10-27 14:15                                       ` Jens Axboe
     [not found]                                     ` <544C2371.1020403-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org>
2014-10-27 14:19                                       ` Jens Axboe
2014-10-27 14:19                                         ` Jens Axboe
     [not found]                                         ` <544E547C.30009-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-27 15:12                                           ` Ketor D
2014-10-27 15:12                                             ` Ketor D
2014-10-27 15:22                                             ` Jens Axboe
2014-10-27 15:25                                               ` Jens Axboe
2014-10-27 15:29                                                 ` Ketor D
     [not found]                                                   ` <CAM9_UU-35i9uRu9EDQSM-b7CjmxrKYV2Gz8ocrykOYk+2q++hw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-27 15:36                                                     ` Jens Axboe
2014-10-27 15:36                                                       ` Jens Axboe
2014-10-27 15:45                                                       ` Ketor D
2014-10-27 15:53                                                         ` Jens Axboe
2014-10-27 16:20                                                           ` Ketor D
     [not found]                                                           ` <CAM9_UU8x2uZZUWaPPoy+LH mUhC_3sqKZ9GPsEqDwKUkprg4kdQ@mail.gmail.com>
     [not found]                                                             ` <CAM9_UU8x2uZZUWaPPoy+LHmUhC_3sqKZ9GPsEqDwKUkprg4kdQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-27 16:55                                                               ` Jens Axboe
2014-10-27 16:55                                                                 ` Jens Axboe
2014-10-27 21:59                                                               ` Mark Kirkwood
2014-10-27 21:59                                                                 ` Mark Kirkwood
2014-10-27 22:32                                                                 ` Jens Axboe
2014-10-27 22:32                                                                   ` Jens Axboe
     [not found]                                                                   ` <544EC7F1.6010900-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-27 23:21                                                                     ` Mark Kirkwood
2014-10-27 23:21                                                                       ` Mark Kirkwood
     [not found]                                                                       ` <544ED37D.6060800-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org>
2014-10-28  3:23                                                                         ` Ketor D
2014-10-28  3:23                                                                           ` Ketor D
     [not found]                                                                           ` <CAM9_UU8MHdj+mjAWBziETxPDnwTt0JBuHrQp2Fu9YtF=msae3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-28  4:01                                                                             ` Mark Kirkwood
2014-10-28  4:01                                                                               ` Mark Kirkwood
2014-10-28  4:05                                                                           ` Jens Axboe
2014-10-28  4:49                                                                             ` Ketor D
     [not found]                                                                               ` <CAM9_UU9G5vQ68UxMakte-Wb5B9_KBo24ov7=hNHpYqEtko2nQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-28 15:14                                                                                 ` Jens Axboe
2014-10-28 15:14                                                                                   ` Jens Axboe
2014-10-28 15:49                                                                                   ` Ketor D
     [not found]                                                                                     ` <CAM9_UU_o8kS1wJnDKTvd8+qkm9=93yfW3THr_8ni8C+5=TH6tg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-28 15:53                                                                                       ` Jens Axboe
2014-10-28 15:53                                                                                         ` Jens Axboe
2014-10-28 17:09                                                                                       ` Jens Axboe [this message]
2014-10-28 17:09                                                                                         ` Jens Axboe
2014-10-28 18:43                                                                                         ` Ketor D
2014-10-29  7:15                                                                                           ` Ketor D
     [not found]                                                                                             ` <CAM9_UU8=MtUnQiembBfr8YQiDOD7TNey=mp8_H6gySenRVHy6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-29 14:31                                                                                               ` Jens Axboe
2014-10-29 14:31                                                                                                 ` Jens Axboe
     [not found]                                                                                                 ` <5450FA47.2030203-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-30  2:50                                                                                                   ` Ketor D
2014-10-30  2:50                                                                                                     ` Ketor D
2014-10-30  2:55                                                                                                     ` Jens Axboe
2014-10-30  2:55                                                                                                       ` Jens Axboe
2014-10-30  5:29                                                                                                       ` Ketor D
2014-10-30  7:44                                                                                                 ` Mark Kirkwood
2014-10-30  7:44                                                                                                   ` Mark Kirkwood
2014-10-30  8:04                                                                                                   ` Ketor D
2014-10-31  8:54                                                                                                     ` Mark Kirkwood
2014-10-31  8:54                                                                                                       ` Mark Kirkwood
2014-10-24 22:30       ` fio rbd hang for block sizes > 1M Mark Kirkwood
2014-10-24 22:38         ` Mark Nelson
2014-10-24 14:11   ` Danny Al-Gaaf
2014-10-24 14:31     ` Jens Axboe

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=544FCDBD.7070106@kernel.dk \
    --to=axboe-tswwg44o7x1aa/9udqfwiw@public.gmane.org \
    --cc=ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=d.ketor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=fio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.a.nelson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=mark.kirkwood-6STWZtX7tXAqAMOr+u8IRA@public.gmane.org \
    --cc=mark.nelson-4GqslpFJ+cxBDgjK7y7TUQ@public.gmane.org \
    --cc=xanpeng-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.