public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikanth Karthikesan <knikanth@suse.de>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: linux-aio@kvack.org, linux-kernel@vger.kernel.org,
	Benjamin LaHaise <bcrl@kvack.org>,
	Zach Brown <zach.brown@oracle.com>
Subject: Re: [PATCH] aio: aio_complete() will never be called in interrupt context
Date: Mon, 30 Jun 2008 11:21:09 +0530	[thread overview]
Message-ID: <200806301121.10119.knikanth@suse.de> (raw)
In-Reply-To: <x49tzfft448.fsf@segfault.boston.devel.redhat.com>

On Friday 27 June 2008 18:41:03 Jeff Moyer wrote:
> Nikanth Karthikesan <knikanth@suse.de> writes:
> > aio_complete() is never called from interrupt context. It is called from
> > user context or worker threads. Remove disabling interrupts and for
> > kmap_atomic use KM_USER slots instead of KM_IRQ slots.
>
> Actually, it can be called from softirq context.  See fs/directio.c.
>

Oh, sorry for my ignorance. Will using KM_SOFTIRQ slots be fine?

Thanks
Nikanth Karthikesan

aio_complete() is never called from hardware interrupt context. Remove 
disabling interrupts and for kmap_atomic use KM_SOFTIRQ slots instead of 
KM_IRQ slots.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

Index: linux-2.6/fs/aio.c
===================================================================
--- linux-2.6.orig/fs/aio.c
+++ linux-2.6/fs/aio.c
@@ -901,7 +901,6 @@ int aio_complete(struct kiocb *iocb, lon
 	struct aio_ring_info	*info;
 	struct aio_ring	*ring;
 	struct io_event	*event;
-	unsigned long	flags;
 	unsigned long	tail;
 	int		ret;
 
@@ -924,11 +923,9 @@ int aio_complete(struct kiocb *iocb, lon
 
 	/* add a completion event to the ring buffer.
 	 * must be done holding ctx->ctx_lock to prevent
-	 * other code from messing with the tail
-	 * pointer since we might be called from irq
-	 * context.
+	 * other code from messing with the tail pointer.
 	 */
-	spin_lock_irqsave(&ctx->ctx_lock, flags);
+	spin_lock(&ctx->ctx_lock);
 
 	if (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list))
 		list_del_init(&iocb->ki_run_list);
@@ -940,10 +937,10 @@ int aio_complete(struct kiocb *iocb, lon
 	if (kiocbIsCancelled(iocb))
 		goto put_rq;
 
-	ring = kmap_atomic(info->ring_pages[0], KM_IRQ1);
+	ring = kmap_atomic(info->ring_pages[0], KM_SOFTIRQ1);
 
 	tail = info->tail;
-	event = aio_ring_event(info, tail, KM_IRQ0);
+	event = aio_ring_event(info, tail, KM_SOFTIRQ0);
 	if (++tail >= info->nr)
 		tail = 0;
 
@@ -964,8 +961,8 @@ int aio_complete(struct kiocb *iocb, lon
 	info->tail = tail;
 	ring->tail = tail;
 
-	put_aio_ring_event(event, KM_IRQ0);
-	kunmap_atomic(ring, KM_IRQ1);
+	put_aio_ring_event(event, KM_SOFTIRQ0);
+	kunmap_atomic(ring, KM_SOFTIRQ1);
 
 	pr_debug("added to ring %p at [%lu]\n", iocb, tail);
 
@@ -992,7 +989,7 @@ put_rq:
 	if (waitqueue_active(&ctx->wait))
 		wake_up(&ctx->wait);
 
-	spin_unlock_irqrestore(&ctx->ctx_lock, flags);
+	spin_unlock(&ctx->ctx_lock);
 	return ret;
 }
 





  reply	other threads:[~2008-06-30  5:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-26  4:00 [PATCH] aio: aio_complete() will never be called in interrupt context Nikanth Karthikesan
2008-06-27 13:11 ` Jeff Moyer
2008-06-30  5:51   ` Nikanth Karthikesan [this message]
2008-06-30 17:43 ` Zach Brown
2008-07-01  8:29   ` Nikanth Karthikesan
2008-07-01 19:50     ` Zach Brown
2008-07-02  5:00       ` Nikanth Karthikesan
2008-07-02 16:38         ` Zach Brown
2008-07-02 17:59           ` Benjamin LaHaise

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=200806301121.10119.knikanth@suse.de \
    --to=knikanth@suse.de \
    --cc=bcrl@kvack.org \
    --cc=jmoyer@redhat.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zach.brown@oracle.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox