linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events
@ 2019-05-16  3:46 Jackie Liu
  2019-05-16  3:46 ` [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait Jackie Liu
  2019-05-16 14:12 ` [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Jackie Liu @ 2019-05-16  3:46 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Jackie Liu

Whenever smp_rmb is required to use io_cqring_events,
keep smp_rmb inside the function io_cqring_events.

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 fs/io_uring.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 84efb89..516f036 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2044,6 +2044,8 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
 
 static unsigned io_cqring_events(struct io_cq_ring *ring)
 {
+	/* See comment at the top of this file */
+	smp_rmb();
 	return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head);
 }
 
@@ -2059,8 +2061,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
 	DEFINE_WAIT(wait);
 	int ret;
 
-	/* See comment at the top of this file */
-	smp_rmb();
 	if (io_cqring_events(ring) >= min_events)
 		return 0;
 
@@ -2082,8 +2082,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
 		prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
 
 		ret = 0;
-		/* See comment at the top of this file */
-		smp_rmb();
 		if (io_cqring_events(ring) >= min_events)
 			break;
 
-- 
2.7.4




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

* [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait
  2019-05-16  3:46 [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events Jackie Liu
@ 2019-05-16  3:46 ` Jackie Liu
  2019-05-16 14:12   ` Jens Axboe
  2019-05-16 14:12 ` [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Jackie Liu @ 2019-05-16  3:46 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Jackie Liu

The previous patch has ensured that io_cqring_events contain
smp_rmb memory barriers, Now we can use wait_event_interruptible
to keep the code simple.

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 fs/io_uring.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 516f036..45df0b4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2058,7 +2058,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
 {
 	struct io_cq_ring *ring = ctx->cq_ring;
 	sigset_t ksigmask, sigsaved;
-	DEFINE_WAIT(wait);
 	int ret;
 
 	if (io_cqring_events(ring) >= min_events)
@@ -2078,21 +2077,9 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
 			return ret;
 	}
 
-	do {
-		prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE);
-
-		ret = 0;
-		if (io_cqring_events(ring) >= min_events)
-			break;
-
-		schedule();
-
+	ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events);
+	if (ret == -ERESTARTSYS)
 		ret = -EINTR;
-		if (signal_pending(current))
-			break;
-	} while (1);
-
-	finish_wait(&ctx->wait, &wait);
 
 	if (sig)
 		restore_user_sigmask(sig, &sigsaved);
-- 
2.7.4





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

* Re: [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events
  2019-05-16  3:46 [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events Jackie Liu
  2019-05-16  3:46 ` [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait Jackie Liu
@ 2019-05-16 14:12 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-05-16 14:12 UTC (permalink / raw)
  To: Jackie Liu; +Cc: linux-block

On 5/15/19 9:46 PM, Jackie Liu wrote:
> Whenever smp_rmb is required to use io_cqring_events,
> keep smp_rmb inside the function io_cqring_events.

Nice cleanup. Applied, thanks.

-- 
Jens Axboe


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

* Re: [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait
  2019-05-16  3:46 ` [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait Jackie Liu
@ 2019-05-16 14:12   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-05-16 14:12 UTC (permalink / raw)
  To: Jackie Liu; +Cc: linux-block

On 5/15/19 9:46 PM, Jackie Liu wrote:
> The previous patch has ensured that io_cqring_events contain
> smp_rmb memory barriers, Now we can use wait_event_interruptible
> to keep the code simple.

Looks good, applied.

-- 
Jens Axboe


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

end of thread, other threads:[~2019-05-16 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16  3:46 [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events Jackie Liu
2019-05-16  3:46 ` [PATCH 2/2] io_uring: use wait_event_interruptible for cq_wait conditional wait Jackie Liu
2019-05-16 14:12   ` Jens Axboe
2019-05-16 14:12 ` [PATCH 1/2] io_uring: adjust smp_rmb inside io_cqring_events 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).