[PATCH] aio: ring wrapping simplification
authorKen Chen <kenneth.w.chen@intel.com>
Sun, 1 May 2005 15:59:15 +0000 (08:59 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 1 May 2005 15:59:15 +0000 (08:59 -0700)
Since the tail pointer in aio_ring structure never wrap ring size more than
once, so a simple compare is sufficient to wrap the index around.  This avoid
a more expensive mod operation.

Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Suparna Bhattacharya <suparna@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/aio.c

index 9f807a5..40517f3 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -978,7 +978,8 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
 
        tail = info->tail;
        event = aio_ring_event(info, tail, KM_IRQ0);
-       tail = (tail + 1) % info->nr;
+       if (++tail >= info->nr)
+               tail = 0;
 
        event->obj = (u64)(unsigned long)iocb->ki_obj.user;
        event->data = iocb->ki_user_data;