linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete
@ 2014-02-28 10:27 Gu Zheng
  2014-02-28 20:52 ` Kent Overstreet
  2014-03-07 10:42 ` Gu Zheng
  0 siblings, 2 replies; 4+ messages in thread
From: Gu Zheng @ 2014-02-28 10:27 UTC (permalink / raw)
  To: Benjamin; +Cc: Kent, Jens, linux-aio, linux-kernel

Commit 5ffac122dbda8(aio: Don't use ctx->tail unnecessarily) uses
ring->tail rather than the ctx->tail, but with this change, we fetch 'tail'
only once at the start, so that we can not be aware of adding event by aio_complete
when reading events. It seems a regression.
So here we fetch the ring->tail in start of the loop each time to make it be
aware of adding event from aio_complete.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 fs/aio.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 7eaa631..f5b8551 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1029,10 +1029,14 @@ static long aio_read_events_ring(struct kioctx *ctx,
 		struct io_event *ev;
 		struct page *page;
 
-		avail = (head <= tail ?  tail : ctx->nr_events) - head;
+		ring = kmap_atomic(ctx->ring_pages[0]);
+		tail = ring->tail;
+		kunmap_atomic(ring);
+
 		if (head == tail)
 			break;
 
+		avail = (head <= tail ?  tail : ctx->nr_events) - head;
 		avail = min(avail, nr - ret);
 		avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
 			    ((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));
-- 
1.7.7


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

* Re: [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete
  2014-02-28 10:27 [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete Gu Zheng
@ 2014-02-28 20:52 ` Kent Overstreet
  2014-03-03  2:17   ` Gu Zheng
  2014-03-07 10:42 ` Gu Zheng
  1 sibling, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2014-02-28 20:52 UTC (permalink / raw)
  To: Gu Zheng; +Cc: Benjamin, Jens, linux-aio, linux-kernel

On Fri, Feb 28, 2014 at 06:27:18PM +0800, Gu Zheng wrote:
> Commit 5ffac122dbda8(aio: Don't use ctx->tail unnecessarily) uses
> ring->tail rather than the ctx->tail, but with this change, we fetch 'tail'
> only once at the start, so that we can not be aware of adding event by aio_complete
> when reading events. It seems a regression.

"Seems a regression" is not good enough. What breaks?

> So here we fetch the ring->tail in start of the loop each time to make it be
> aware of adding event from aio_complete.
> 
> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
>  fs/aio.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 7eaa631..f5b8551 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1029,10 +1029,14 @@ static long aio_read_events_ring(struct kioctx *ctx,
>  		struct io_event *ev;
>  		struct page *page;
>  
> -		avail = (head <= tail ?  tail : ctx->nr_events) - head;
> +		ring = kmap_atomic(ctx->ring_pages[0]);
> +		tail = ring->tail;
> +		kunmap_atomic(ring);
> +
>  		if (head == tail)
>  			break;
>  
> +		avail = (head <= tail ?  tail : ctx->nr_events) - head;
>  		avail = min(avail, nr - ret);
>  		avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
>  			    ((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));
> -- 
> 1.7.7
> 

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

* Re: [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete
  2014-02-28 20:52 ` Kent Overstreet
@ 2014-03-03  2:17   ` Gu Zheng
  0 siblings, 0 replies; 4+ messages in thread
From: Gu Zheng @ 2014-03-03  2:17 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: Benjamin, Jens, linux-aio, linux-kernel

Hi Kent,
Sorry for late replay.
On 03/01/2014 04:52 AM, Kent Overstreet wrote:

> On Fri, Feb 28, 2014 at 06:27:18PM +0800, Gu Zheng wrote:
>> Commit 5ffac122dbda8(aio: Don't use ctx->tail unnecessarily) uses
>> ring->tail rather than the ctx->tail, but with this change, we fetch 'tail'
>> only once at the start, so that we can not be aware of adding event by aio_complete
>> when reading events. It seems a regression.
> 
> "Seems a regression" is not good enough. What breaks? 

Previously without the commit 5ffac122dbda8, we used tail from aio context to judge
whether the ring buffer has events(have not been read) each time, as following:
avail = (head <= ctx->tail ? ctx->tail : ctx->nr_events) - head;
so that we can be aware of new events that added by aio_complete when we are reading the
current ones, and we can read the new added events together.
E.g. we want to read 10 events, only 8 events now, add 2 events added while we copying
current 8 events to userspace, and we can read the 2 new events in the next circle.
But with the commit 5ffac122dbda8, we fetch tail from ring buffer only once when we start
to read events, so that we can not be aware of events that added by aio_complete while we
are reading current events(e.g. copy currents events to user space). Such as the case
mentioned above can only read 8 events, though these are 2 new events in the ring buffer.
Is not it a regression, or am I missing something?

Regards,
Gu

> 
>> So here we fetch the ring->tail in start of the loop each time to make it be
>> aware of adding event from aio_complete.
>>
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> ---
>>  fs/aio.c |    6 +++++-
>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/aio.c b/fs/aio.c
>> index 7eaa631..f5b8551 100644
>> --- a/fs/aio.c
>> +++ b/fs/aio.c
>> @@ -1029,10 +1029,14 @@ static long aio_read_events_ring(struct kioctx *ctx,
>>  		struct io_event *ev;
>>  		struct page *page;
>>  
>> -		avail = (head <= tail ?  tail : ctx->nr_events) - head;
>> +		ring = kmap_atomic(ctx->ring_pages[0]);
>> +		tail = ring->tail;
>> +		kunmap_atomic(ring);
>> +
>>  		if (head == tail)
>>  			break;
>>  
>> +		avail = (head <= tail ?  tail : ctx->nr_events) - head;
>>  		avail = min(avail, nr - ret);
>>  		avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
>>  			    ((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));
>> -- 
>> 1.7.7
>>
> 



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

* Re: [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete
  2014-02-28 10:27 [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete Gu Zheng
  2014-02-28 20:52 ` Kent Overstreet
@ 2014-03-07 10:42 ` Gu Zheng
  1 sibling, 0 replies; 4+ messages in thread
From: Gu Zheng @ 2014-03-07 10:42 UTC (permalink / raw)
  To: Benjamin; +Cc: Kent, Jens, linux-aio, linux-kernel

ping...

On 02/28/2014 06:27 PM, Gu Zheng wrote:

> Commit 5ffac122dbda8(aio: Don't use ctx->tail unnecessarily) uses
> ring->tail rather than the ctx->tail, but with this change, we fetch 'tail'
> only once at the start, so that we can not be aware of adding event by aio_complete
> when reading events. It seems a regression.
> So here we fetch the ring->tail in start of the loop each time to make it be
> aware of adding event from aio_complete.
> 
> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
>  fs/aio.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 7eaa631..f5b8551 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1029,10 +1029,14 @@ static long aio_read_events_ring(struct kioctx *ctx,
>  		struct io_event *ev;
>  		struct page *page;
>  
> -		avail = (head <= tail ?  tail : ctx->nr_events) - head;
> +		ring = kmap_atomic(ctx->ring_pages[0]);
> +		tail = ring->tail;
> +		kunmap_atomic(ring);
> +
>  		if (head == tail)
>  			break;
>  
> +		avail = (head <= tail ?  tail : ctx->nr_events) - head;
>  		avail = min(avail, nr - ret);
>  		avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
>  			    ((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));



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

end of thread, other threads:[~2014-03-07 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-28 10:27 [PATCH 2/2] aio: make aio_read_events_ring be aware of aio_complete Gu Zheng
2014-02-28 20:52 ` Kent Overstreet
2014-03-03  2:17   ` Gu Zheng
2014-03-07 10:42 ` Gu Zheng

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).