Skip to contentSkip to conversation

aio: remove spurious ring head index modulo info->nr

PATCH In review Chen, Kenneth W 2 participants 2 messages Dec 30, 2006 – Jan 3, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aio: remove spurious ring head index modulo info->nr

In aio_read_evt(), the ring->head will never wrap info->nr because we already does the wrap when updating the ring head index:

        if (head != ring->tail) {
                ...
                head = (head + 1) % info->nr;
                ring->head = head;
        }

This makes the modulo of ring->head into local variable head unnecessary. This patch removes that bogus code.

fs/aio.c renamed from fs/aio.c.orig +2 -2
@@ -1019,7 +1019,7 @@ static int aio_read_evt(struct kioctx *i
 {
 	struct aio_ring_info *info = &ioctx->ring_info;
 	struct aio_ring *ring;
-	unsigned long head;
+	unsigned int head;
 	int ret = 0;
 
 	ring = kmap_atomic(info->ring_pages[0], KM_USER0);
@@ -1032,7 +1032,7 @@ static int aio_read_evt(struct kioctx *i
 
 	spin_lock(&info->ring_lock);
 
-	head = ring->head % info->nr;
+	head = ring->head;
 	if (head != ring->tail) {
 		struct io_event *evp = aio_ring_event(info, head, KM_USER1);
 		*ent = *evp;
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines

This makes the modulo of ring->head into local variable head unnecessary. This patch removes that bogus code.

Looks fine to me:

- z